Fix a very rare nan where r_earth/position_radius > 1.0

This commit is contained in:
Erik Hofman 2015-12-29 15:49:12 +01:00
parent 1f23fb89c0
commit 5d754c0419

View File

@ -427,19 +427,14 @@ bool SGSun::reposition( double rightAscension, double declination,
{ {
// GST - GMT sidereal time // GST - GMT sidereal time
osg::Matrix T2, RA, DEC; osg::Matrix T2, RA, DEC;
// xglRotatef( ((SGD_RADIANS_TO_DEGREES * rightAscension)- 90.0), // xglRotatef( ((SGD_RADIANS_TO_DEGREES * rightAscension)- 90.0),
// 0.0, 0.0, 1.0); // 0.0, 0.0, 1.0);
RA.makeRotate(rightAscension - 90*SGD_DEGREES_TO_RADIANS, osg::Vec3(0, 0, 1)); 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); // xglRotatef((SGD_RADIANS_TO_DEGREES * declination), 1.0, 0.0, 0.0);
DEC.makeRotate(declination, osg::Vec3(1, 0, 0)); DEC.makeRotate(declination, osg::Vec3(1, 0, 0));
// xglTranslatef(0,sun_dist); // xglTranslatef(0,sun_dist);
T2.makeTranslate(osg::Vec3(0, sun_dist, 0)); T2.makeTranslate(osg::Vec3(0, sun_dist, 0));
sun_transform->setMatrix(T2*DEC*RA); sun_transform->setMatrix(T2*DEC*RA);
// Suncolor related things: // Suncolor related things:
if ( prev_sun_angle != sun_angle ) { if ( prev_sun_angle != sun_angle ) {
if ( sun_angle == 0 ) sun_angle = 0.1; 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; if ( alt_half < 0.0 ) alt_half = 0.0;
//angle at which the sun is visible below the horizon //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 // Push the data to the property tree, so it can be used in the enviromental code
if ( env_node ){ if ( env_node ){