]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/sky/oursun.cxx
Merge branch 'ehofman/sound'
[simgear.git] / simgear / scene / sky / oursun.cxx
index cb1c5f662d340d7702ee30388d225ba0b0f0967f..db7e73198cb69c8cf47c7ed0d738fed41cdfe8f4 100644 (file)
@@ -41,6 +41,7 @@
 #include <osg/Texture2D>
 #include <osgDB/ReadFile>
 
+#include <simgear/math/SGMath.hxx>
 #include <simgear/misc/PathOptions.hxx>
 #include <simgear/screen/colors.hxx>
 #include <simgear/scene/model/model.hxx>
@@ -231,12 +232,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 +249,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 +333,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;
@@ -419,6 +419,12 @@ bool SGSun::reposition( double rightAscension, double declination,
 
 SGVec4f
 SGSun::get_color()
+{
+    return SGVec4f((*sun_cl)[0][0], (*sun_cl)[0][1], (*sun_cl)[0][2], (*sun_cl)[0][3]);
+}
+
+SGVec4f
+SGSun::get_scene_color()
 {
     return SGVec4f((*scene_cl)[0][0], (*scene_cl)[0][1], (*scene_cl)[0][2], (*scene_cl)[0][3]);
 }