]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/sky/oursun.cxx
Work around apparent OSG 3.2.0 normal binding bug.
[simgear.git] / simgear / scene / sky / oursun.cxx
index 8f5db650caac60f649cb26ba02d01e001bb4a229..f959200c60b3dd0079010600bcd7f3713f2e3c76 100644 (file)
@@ -41,7 +41,8 @@
 #include <osg/Texture2D>
 #include <osgDB/ReadFile>
 
-#include <simgear/misc/PathOptions.hxx>
+#include <simgear/math/SGMath.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/screen/colors.hxx>
 #include <simgear/scene/model/model.hxx>
 #include "oursun.hxx"
@@ -68,8 +69,8 @@ SGSun::build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node )
 
     env_node = property_tree_Node;
 
-    osg::ref_ptr<osgDB::ReaderWriter::Options> options
-        = makeOptionsFromPath(path);
+    osg::ref_ptr<SGReaderWriterOptions> options;
+    options = SGReaderWriterOptions::fromPath(path.str());
     // build the ssg scene graph sub tree for the sky and connected
     // into the provide scene graph branch
     sun_transform = new osg::MatrixTransform;
@@ -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;