From 5d754c04196f3822cf140543f146e13b6a994c6a Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Tue, 29 Dec 2015 15:49:12 +0100 Subject: [PATCH] Fix a very rare nan where r_earth/position_radius > 1.0 --- simgear/scene/sky/oursun.cxx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/simgear/scene/sky/oursun.cxx b/simgear/scene/sky/oursun.cxx index be78ca6c..1451222a 100644 --- a/simgear/scene/sky/oursun.cxx +++ b/simgear/scene/sky/oursun.cxx @@ -427,19 +427,14 @@ bool SGSun::reposition( double rightAscension, double declination, { // GST - GMT sidereal time osg::Matrix T2, RA, DEC; - // xglRotatef( ((SGD_RADIANS_TO_DEGREES * rightAscension)- 90.0), // 0.0, 0.0, 1.0); RA.makeRotate(rightAscension - 90*SGD_DEGREES_TO_RADIANS, osg::Vec3(0, 0, 1)); - // xglRotatef((SGD_RADIANS_TO_DEGREES * declination), 1.0, 0.0, 0.0); DEC.makeRotate(declination, osg::Vec3(1, 0, 0)); - // xglTranslatef(0,sun_dist); T2.makeTranslate(osg::Vec3(0, sun_dist, 0)); - sun_transform->setMatrix(T2*DEC*RA); - // Suncolor related things: if ( prev_sun_angle != sun_angle ) { if ( sun_angle == 0 ) sun_angle = 0.1; @@ -467,7 +462,7 @@ bool SGSun::reposition( double rightAscension, double declination, if ( alt_half < 0.0 ) alt_half = 0.0; //angle at which the sun is visible below the horizon - horizon_angle = acos(r_earth/position_radius); + horizon_angle = acos(min(r_earth/position_radius, 1.0)); // Push the data to the property tree, so it can be used in the enviromental code if ( env_node ){ -- 2.39.5