From: ehofman Date: Wed, 17 Sep 2003 17:59:28 +0000 (+0000) Subject: Initialize some variables before using them X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6079cd3df8f0dfa02bcb70d7b4ab0af29f087b22;p=simgear.git Initialize some variables before using them --- diff --git a/simgear/scene/sky/oursun.cxx b/simgear/scene/sky/oursun.cxx index 0bce1594..923ae3f8 100644 --- a/simgear/scene/sky/oursun.cxx +++ b/simgear/scene/sky/oursun.cxx @@ -113,6 +113,8 @@ static int sgSunHaloPostDraw( ssgEntity *e ) { // Constructor SGSun::SGSun( void ) { + prev_sun_angle = -9999.0; + visibility = -9999.0; } @@ -335,17 +337,14 @@ ssgBranch * SGSun::build( SGPath path, double sun_size ) { // 90 degrees = sun rise/set // 180 degrees = darkest midnight bool SGSun::repaint( double sun_angle, double new_visibility ) { - static float prev_sun_angle = 9999.0; - if ( visibility != new_visibility ) { - static double sqrt_m_log01 = sqrt( -log( 0.01 ) ); visibility = new_visibility; + + static double sqrt_m_log01 = sqrt( -log( 0.01 ) ); sun_exp2_punch_through = sqrt_m_log01 / (visibility * 15); } - if (prev_sun_angle != sun_angle) - { - + if (prev_sun_angle != sun_angle) { prev_sun_angle = sun_angle; float sun_factor = 4*cos(sun_angle); diff --git a/simgear/scene/sky/oursun.hxx b/simgear/scene/sky/oursun.hxx index 212acdc8..981c5441 100644 --- a/simgear/scene/sky/oursun.hxx +++ b/simgear/scene/sky/oursun.hxx @@ -51,6 +51,7 @@ class SGSun { GLubyte *sun_texbuf; double visibility; + double prev_sun_angle; public: