From c4ece52ca6cccbaf309ca27707da60434337398f Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Fri, 20 Apr 2018 19:11:38 -0400 Subject: [PATCH] Requested changes for merging. Part II. --- .../rendering/atmospheredeferredcaster.cpp | 7 ++----- .../atmosphere/rendering/atmospheredeferredcaster.h | 3 +-- modules/space/rendering/renderablestars.cpp | 5 ++++- src/interaction/orbitalnavigator.cpp | 13 +++++++++---- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp index eb29abd256..5693a6d72e 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp @@ -102,7 +102,6 @@ namespace { } // namespace namespace openspace { - AtmosphereDeferredcaster::AtmosphereDeferredcaster() : _transmittanceProgramObject(nullptr) , _irradianceProgramObject(nullptr) @@ -1275,8 +1274,6 @@ namespace openspace { LDEBUG("Ended precalculations for Atmosphere effects..."); } - void AtmosphereDeferredcaster::resetAtmosphereTextures() {} - void AtmosphereDeferredcaster::createRenderQuad(GLuint* vao, GLuint* vbo, GLfloat size) { glGenVertexArrays(1, vao); glGenBuffers(1, vbo); @@ -1404,10 +1401,10 @@ namespace openspace { void AtmosphereDeferredcaster::step3DTexture( std::unique_ptr& shaderProg, - int layer, bool doCalc) + int layer, bool doCalculation) { // See OpenGL redbook 8th Edition page 556 for Layered Rendering - if (doCalc) { + if (doCalculation) { float earth2 = _atmospherePlanetRadius * _atmospherePlanetRadius; float atm2 = _atmosphereRadius * _atmosphereRadius; float diff = atm2 - earth2; diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.h b/modules/atmosphere/rendering/atmospheredeferredcaster.h index 33184628f1..c53981fdb6 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.h +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.h @@ -100,10 +100,9 @@ private: void deleteUnusedComputationTextures(); void executeCalculations(GLuint quadCalcVAO, GLenum drawBuffers[1], GLsizei vertexSize); - void resetAtmosphereTextures(); void createRenderQuad(GLuint* vao, GLuint* vbo, GLfloat size); void step3DTexture(std::unique_ptr& shaderProg, - int layer, bool doCalc = true); + int layer, bool doCalculation = true); void checkFrameBufferState(const std::string& codePosition) const; void loadAtmosphereDataIntoShaderProgram( std::unique_ptr & shaderProg diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 823d11091d..dfb5e1394a 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -699,8 +699,11 @@ bool RenderableStars::readSpeckFile() { } while (!file.eof()); // Normalize Luminosity: + int luminosityVarColumnPos = 4; for (size_t i = 0; i < _fullData.size(); i += _nValuesPerStar) { - _fullData[i + 4] = (_fullData[i + 4] - minLumValue) / (maxLumValue - minLumValue); + _fullData[i + luminosityVarColumnPos] = + (_fullData[i + luminosityVarColumnPos] - minLumValue) / + (maxLumValue - minLumValue); } return true; diff --git a/src/interaction/orbitalnavigator.cpp b/src/interaction/orbitalnavigator.cpp index 4bbac0188d..137a723720 100644 --- a/src/interaction/orbitalnavigator.cpp +++ b/src/interaction/orbitalnavigator.cpp @@ -345,8 +345,7 @@ void OrbitalNavigator::updateCameraStateFromMouseStates(Camera& camera, double d } glm::dvec3 OrbitalNavigator::cameraToSurfaceVector( - const glm::dvec3& camPos, - const glm::dvec3& centerPos, + const glm::dvec3& camPos, const glm::dvec3& centerPos, const SurfacePositionHandle& posHandle) { glm::dmat4 modelTransform = _focusNode->modelTransform(); @@ -491,16 +490,21 @@ glm::dquat OrbitalNavigator::interpolateLocalRotation(double deltaTime, else { return localCameraRotation; } + double t = _rotateToFocusNodeInterpolator.value(); _rotateToFocusNodeInterpolator.setDeltaTime(static_cast(deltaTime)); _rotateToFocusNodeInterpolator.step(); + glm::dquat result = glm::slerp( localCameraRotation, glm::dquat(glm::dvec3(0.0)), - glm::min(t * _rotateToFocusNodeInterpolator.deltaTimeScaled(), 1.0)); + glm::min(t * _rotateToFocusNodeInterpolator.deltaTimeScaled(), 1.0) + ); + if (angle(result) < 0.01) { _rotateToFocusNodeInterpolator.end(); } + return result; } @@ -520,7 +524,8 @@ double OrbitalNavigator::interpolateCameraToSurfaceDistance(double deltaTime, double result = glm::exp(glm::mix( glm::log(currentDistance), glm::log(targetDistance), - glm::min(t * _cameraToSurfaceDistanceInterpolator.deltaTimeScaled(), 1.0))); + glm::min(t * _cameraToSurfaceDistanceInterpolator.deltaTimeScaled(), 1.0)) + ); double ratio = currentDistance / targetDistance; if (glm::abs(ratio - 1.0) < 0.000001) {