Handling case where DistanceSwitch is empty

This commit is contained in:
Erik Broberg
2016-03-30 20:13:06 -04:00
parent 9d45463e93
commit 1d8d750635
3 changed files with 9 additions and 5 deletions

View File

@@ -26,7 +26,7 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planet.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/distanceswitch.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/distanceswitch.h
)
source_group("Header Files" FILES ${HEADER_FILES})

View File

@@ -52,6 +52,10 @@ bool DistanceSwitch::isReady() const {
}
void DistanceSwitch::render(const RenderData& data) {
if (_maxDistances.size() == 0) {
return;
}
pss pssDistanceToCamera = (data.camera.position() - data.position).length();
double distanceToCamera = pssDistanceToCamera.lengthd();

View File

@@ -22,8 +22,8 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __DDLODSWITCH_H__
#define __DDLODSWITCH_H__
#ifndef __DISTANCESWITCH_H__
#define __DISTANCESWITCH_H__
// open space includes
#include <openspace/rendering/renderable.h>
@@ -68,8 +68,8 @@ private:
std::vector<std::shared_ptr<Renderable>> _renderables;
std::vector <double> _distanceThresholds;
std::vector <double> _maxDistances;
};
} // openspace
#endif //__DDLODSWITCH_H__
#endif //__DISTANCESWITCH_H__