]> git.mxchange.org Git - simgear.git/commitdiff
prevent division by zero
authorehofman <ehofman>
Fri, 21 Aug 2009 07:43:01 +0000 (07:43 +0000)
committerTim Moore <timoore@redhat.com>
Sun, 23 Aug 2009 19:37:03 +0000 (21:37 +0200)
simgear/scene/sky/oursun.cxx

index 8f5db650caac60f649cb26ba02d01e001bb4a229..e4249989ee6305c38b96f137e3f61ed15820abb7 100644 (file)
@@ -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;