Some changes to PR #432

This commit is contained in:
Alexander Bock
2017-12-18 16:25:02 -05:00
parent a3185a0cfa
commit db668b5342
31 changed files with 1437 additions and 1315 deletions

View File

@@ -236,11 +236,15 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
_texturePath.onChange([this]() { loadTexture(); });
if (dictionary.hasKey(FadeOutThreshouldInfo.identifier)) {
_fadeOutThreshold = static_cast<float>(dictionary.value<double>(FadeOutThreshouldInfo.identifier));
_fadeOutThreshold = static_cast<float>(
dictionary.value<double>(FadeOutThreshouldInfo.identifier)
);
}
if (dictionary.hasKey(FadeInThreshouldInfo.identifier)) {
_fadeInThreshold = static_cast<float>(dictionary.value<double>(FadeInThreshouldInfo.identifier));
_fadeInThreshold = static_cast<float>(
dictionary.value<double>(FadeInThreshouldInfo.identifier)
);
}
if (dictionary.hasKey(FadeOutThreshouldInfo.identifier) ||
@@ -299,14 +303,21 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) {
if (_fadeInThreshold > 0.0) {
float distCamera = glm::length(data.camera.positionVec3());
float funcValue = static_cast<float>((1.0 / double(_fadeInThreshold/1E24))*(distCamera / 1E24));
float funcValue = static_cast<float>(
(1.0 / double(_fadeInThreshold/1E24))*(distCamera / 1E24)
);
adjustedTransparency *= funcValue > 1.0 ? 1.0 : funcValue;
}
if (_fadeOutThreshold > -1.0) {
float distCamera = glm::distance(data.camera.positionVec3(), data.position.dvec3());
double term = std::exp((-distCamera + _size * _fadeOutThreshold) / (_size * _fadeOutThreshold));
float distCamera = glm::distance(
data.camera.positionVec3(),
data.position.dvec3()
);
double term = std::exp(
(-distCamera + _size * _fadeOutThreshold) / (_size * _fadeOutThreshold)
);
adjustedTransparency *= static_cast<float>(term / (term + 1.0));
}