From cfedc90fdd420a0ec25ca0a2ba3f07fc242c5642 Mon Sep 17 00:00:00 2001 From: ehofman Date: Thu, 15 Jan 2004 14:23:06 +0000 Subject: [PATCH] Try to prevent a devide by zero situation --- simgear/scene/sky/sky.cxx | 17 +++++++---------- simgear/scene/sky/sky.hxx | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/simgear/scene/sky/sky.cxx b/simgear/scene/sky/sky.cxx index 059bdf46..fe6bb0ed 100644 --- a/simgear/scene/sky/sky.cxx +++ b/simgear/scene/sky/sky.cxx @@ -112,14 +112,12 @@ bool SGSky::repaint( const SGSkyColor &sc ) dome->repaint( sc.sky_color, sc.fog_color, sc.sun_angle, effective_visibility ); - oursun->repaint( sc.sun_angle, effective_visibility ); + stars->repaint( sc.sun_angle, sc.nstars, sc.star_data ); + planets->repaint( sc.sun_angle, sc.nplanets, sc.planet_data ); + oursun->repaint( sc.sun_angle, effective_visibility ); moon->repaint( sc.moon_angle ); - planets->repaint( sc.sun_angle, sc.nplanets, sc.planet_data ); - - stars->repaint( sc.sun_angle, sc.nstars, sc.star_data ); - for ( int i = 0; i < (int)cloud_layers.size(); ++i ) { if (cloud_layers[i]->getCoverage() != SGCloudLayer::SG_CLOUD_CLEAR){ cloud_layers[i]->repaint( sc.cloud_color ); @@ -148,16 +146,15 @@ bool SGSky::reposition( SGSkyState &st, double dt ) dome->reposition( st.zero_elev, st.lon, st.lat, st.spin ); + stars->reposition( st.view_pos, angle ); + planets->reposition( st.view_pos, angle ); + oursun->reposition( st.view_pos, angle, st.sun_ra, st.sun_dec, st.sun_dist ); moon->reposition( st.view_pos, angle, st.moon_ra, st.moon_dec, st.moon_dist ); - planets->reposition( st.view_pos, angle ); - - stars->reposition( st.view_pos, angle ); - for ( int i = 0; i < (int)cloud_layers.size(); ++i ) { if ( cloud_layers[i]->getCoverage() != SGCloudLayer::SG_CLOUD_CLEAR ) { cloud_layers[i]->reposition( st.zero_elev, st.view_up, @@ -176,7 +173,7 @@ void SGSky::preDraw( float alt, float fog_exp2_density ) { // FIXME: This should not be needed, but at this time (08/15/2003) // certain NVidia drivers don't seem to implement - // fgPushAttrib(FG_FOG_BIT) properly. The result is that + // glPushAttrib(FG_FOG_BIT) properly. The result is that // there is not fog when looking at the sun. glFogf ( GL_FOG_DENSITY, fog_exp2_density ); diff --git a/simgear/scene/sky/sky.hxx b/simgear/scene/sky/sky.hxx index 67e3b483..099357bd 100644 --- a/simgear/scene/sky/sky.hxx +++ b/simgear/scene/sky/sky.hxx @@ -416,7 +416,7 @@ public: * @param v visibility in meters */ inline void set_visibility( float v ) { - effective_visibility = visibility = v; + effective_visibility = visibility = (v <= 25.0) ? 25.0 : v; } }; -- 2.39.5