From d3572c25626b728242c2b19f9a0dc30aa1b8e8fd Mon Sep 17 00:00:00 2001 From: ehofman Date: Fri, 21 Aug 2009 07:43:01 +0000 Subject: [PATCH] prevent division by zero --- simgear/scene/sky/oursun.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/simgear/scene/sky/oursun.cxx b/simgear/scene/sky/oursun.cxx index 8f5db650..e4249989 100644 --- a/simgear/scene/sky/oursun.cxx +++ b/simgear/scene/sky/oursun.cxx @@ -231,12 +231,11 @@ SGSun::build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node ) // 90 degrees = sun rise/set // 180 degrees = darkest midnight bool SGSun::repaint( double sun_angle, double new_visibility ) { - - if ( visibility != new_visibility ) { - visibility = new_visibility; + if ( visibility != new_visibility ) { if (new_visibility < 100.0) new_visibility = 100.0; else if (new_visibility > 45000.0) new_visibility = 45000.0; + visibility = new_visibility; sun_exp2_punch_through = 2.0/log(visibility); } @@ -249,7 +248,7 @@ bool SGSun::repaint( double sun_angle, double new_visibility ) { aerosol_factor = 8000; } else { - aerosol_factor = 80.5 / log( visibility / 100 ); + aerosol_factor = 80.5 / log( visibility / 99.9 ); } // get environmental data from property tree or use defaults @@ -333,7 +332,7 @@ bool SGSun::repaint( double sun_angle, double new_visibility ) { o_halo_color[1] = 0.2 * sun_color[1] + 0.8 * scene_color[1]; o_halo_color[2] = 0.2 * sun_color[2] + 0.8 * scene_color[2]; o_halo_color[3] = blue_scat_f; - if ((new_visibility < 10000) && (blue_scat_f > 1)) { + if ((visibility < 10000) && (blue_scat_f > 1)) { o_halo_color[3] = 2 - blue_scat_f; } if (o_halo_color[3] > 1) o_halo_color[3] = 1; -- 2.39.5