From 20137613a84fb2c3f64477fe03c8d9de8b4e788c Mon Sep 17 00:00:00 2001 From: Jonas Strandstedt Date: Mon, 27 Oct 2014 18:01:46 +0100 Subject: [PATCH] Fixed Visual Studio assert error - Visual studio optimized away the assert expression causing the getvalue statement not to be called --- src/rendering/renderablefov.cpp | 9 ++++++--- src/rendering/renderablepath.cpp | 9 ++++++--- src/rendering/renderabletrail.cpp | 26 ++++++++++++++++++++------ src/util/spicemanager.cpp | 10 +++++++--- 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/rendering/renderablefov.cpp b/src/rendering/renderablefov.cpp index 485bf2e8a9..16d35e3a58 100644 --- a/src/rendering/renderablefov.cpp +++ b/src/rendering/renderablefov.cpp @@ -54,9 +54,12 @@ namespace openspace{ , _iBufferID(0) , _mode(GL_LINE_STRIP){ - assert(dictionary.getValue(keyBody , _target)); - assert(dictionary.getValue(keyObserver , _observer)); - assert(dictionary.getValue(keyFrame , _frame)); + bool b1 = dictionary.getValue(keyBody, _target); + bool b2 = dictionary.getValue(keyObserver, _observer); + bool b3 = dictionary.getValue(keyFrame, _frame); + assert(b1 == true); + assert(b2 == true); + assert(b3 == true); if (!dictionary.getValue(keyColor, _c)){ _c = glm::vec3(0.0); diff --git a/src/rendering/renderablepath.cpp b/src/rendering/renderablepath.cpp index c61fbea9f7..7178b809ec 100644 --- a/src/rendering/renderablepath.cpp +++ b/src/rendering/renderablepath.cpp @@ -55,9 +55,12 @@ namespace openspace{ , _iBufferID(0) , _mode(GL_LINE_STRIP){ - assert(dictionary.getValue(keyBody, _target)); - assert(dictionary.getValue(keyObserver, _observer)); - assert(dictionary.getValue(keyFrame, _frame)); + bool b1 = dictionary.getValue(keyBody, _target); + bool b2 = dictionary.getValue(keyObserver, _observer); + bool b3 = dictionary.getValue(keyFrame, _frame); + assert(b1 == true); + assert(b2 == true); + assert(b3 == true); /*assert(dictionary.getValue(keyTropicalOrbitPeriod, _tropic)); assert(dictionary.getValue(keyEarthOrbitRatio, _ratio)); assert(dictionary.getValue(keyDayLength, _day));//not used now, will be though. diff --git a/src/rendering/renderabletrail.cpp b/src/rendering/renderabletrail.cpp index bfa2203f85..66b31eb553 100644 --- a/src/rendering/renderabletrail.cpp +++ b/src/rendering/renderabletrail.cpp @@ -59,12 +59,26 @@ namespace openspace{ , _iBufferID(0) , _mode(GL_LINE_STRIP){ - assert(dictionary.getValue(keyBody , _target)); - assert(dictionary.getValue(keyObserver , _observer)); - assert(dictionary.getValue(keyFrame , _frame)); - assert(dictionary.getValue(keyTropicalOrbitPeriod, _tropic)); - assert(dictionary.getValue(keyEarthOrbitRatio , _ratio)); - assert(dictionary.getValue(keyDayLength , _day));//not used now, will be though. + bool b1 = dictionary.getValue(keyBody, _target); + bool b2 = dictionary.getValue(keyObserver, _observer); + bool b3 = dictionary.getValue(keyFrame, _frame); + bool b4 = dictionary.getValue(keyTropicalOrbitPeriod, _tropic); + bool b5 = dictionary.getValue(keyEarthOrbitRatio, _ratio); + bool b6 = dictionary.getValue(keyDayLength, _day); + + assert(b1 == true); + assert(b2 == true); + assert(b3 == true); + assert(b4 == true); + assert(b5 == true); + assert(b6 == true); + + //assert(dictionary.getValue(keyBody , _target)); + //assert(dictionary.getValue(keyObserver, _observer)); + //assert(dictionary.getValue(keyFrame , _frame)); + //assert(dictionary.getValue(keyTropicalOrbitPeriod, _tropic)); + //assert(dictionary.getValue(keyEarthOrbitRatio , _ratio)); + //assert(dictionary.getValue(keyDayLength , _day));//not used now, will be though. // values in modfiles set from here // http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index 6c946dc801..d83ce3100c 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -353,10 +353,14 @@ bool SpiceManager::getTargetState(const std::string& target, spkezr_c(target.c_str(), ephemerisTime, referenceFrame.c_str(), aberrationCorrection.c_str(), observer.c_str(), state, &lightTime); - position = PowerScaledCoordinate::CreatePowerScaledCoordinate(state[0], state[1], state[2]); - velocity = PowerScaledCoordinate::CreatePowerScaledCoordinate(state[3], state[4], state[5]); + bool hasError = checkForError("Error getting position for '" + + target + "' with observer '" + observer + "'"); - return true; + if (!hasError) { + position = PowerScaledCoordinate::CreatePowerScaledCoordinate(state[0], state[1], state[2]); + velocity = PowerScaledCoordinate::CreatePowerScaledCoordinate(state[3], state[4], state[5]); + } + return !hasError; } bool SpiceManager::getStateTransformMatrix(const std::string& fromFrame,