]> git.mxchange.org Git - simgear.git/commitdiff
Adjust LoD ranges for 3D clouds so that they become visible at maximum range, taking...
authorStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Mon, 2 Jan 2012 23:10:20 +0000 (23:10 +0000)
committerStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Mon, 2 Jan 2012 23:10:20 +0000 (23:10 +0000)
simgear/scene/sky/cloudfield.cxx
simgear/scene/sky/cloudfield.hxx

index 1a801909542aff905156f9860f974496ae4228bf..0ff07144efe23cbfa1997074752a527c6cf98934 100644 (file)
@@ -69,7 +69,8 @@ double SGCloudField::timer_dt = 0.0;
 float SGCloudField::view_distance = 20000.0f;
 bool SGCloudField::wrap = true;
 float SGCloudField::RADIUS_LEVEL_1 = 5000.0f;
-float SGCloudField::RADIUS_LEVEL_2 = 1000.0f;
+float SGCloudField::RADIUS_LEVEL_2 = 2000.0f;
+float SGCloudField::MAX_CLOUD_DEPTH = 2000.0f;
 
 SGVec3f SGCloudField::view_vec, SGCloudField::view_X, SGCloudField::view_Y;
 
@@ -186,9 +187,10 @@ void SGCloudField::applyVisRange(void)
     for (unsigned int i = 0; i < placed_root->getNumChildren(); i++) {
         osg::ref_ptr<osg::LOD> lodnode1 = (osg::LOD*) placed_root->getChild(i);
         for (unsigned int j = 0; j < lodnode1->getNumChildren(); j++) {
+            lodnode1->setRange(j, 0.0f, view_distance + RADIUS_LEVEL_1 + RADIUS_LEVEL_2 + MAX_CLOUD_DEPTH);
             osg::ref_ptr<osg::LOD> lodnode2 = (osg::LOD*) lodnode1->getChild(j);
             for (unsigned int k = 0; k < lodnode2->getNumChildren(); k++) {
-                lodnode2->setRange(k, 0.0f, view_distance);
+                lodnode2->setRange(k, 0.0f, view_distance + MAX_CLOUD_DEPTH);
             }
         }
     }
@@ -317,11 +319,11 @@ void SGCloudField::addCloudToTree(osg::ref_ptr<osg::PositionAttitudeTransform> t
     if (!found) {
         // No suitable leave node was found, so we need to add one.
         lodnode = new osg::LOD();
-        lodnode1->addChild(lodnode, 0.0f, 4*RADIUS_LEVEL_1);
+        lodnode1->addChild(lodnode, 0.0f, view_distance + RADIUS_LEVEL_1 + RADIUS_LEVEL_2 + MAX_CLOUD_DEPTH);
     }
 
     transform->setPosition(pos);
-    lodnode->addChild(transform.get(), 0.0f, view_distance);
+    lodnode->addChild(transform.get(), 0.0f, view_distance + MAX_CLOUD_DEPTH);
 
     lodnode->dirtyBound();
     lodnode1->dirtyBound();
index 1de2fce35920760345e0c8a36bdb51063c91c648..1199c9c51f46a0be1ceca26bbaff0ae2e2be997f 100644 (file)
@@ -76,6 +76,10 @@ private:
   static float RADIUS_LEVEL_1;
   static float RADIUS_LEVEL_2;
 
+  // Theoretical maximum cloud depth, used for fudging the LoD
+  // ranges to ensure that clouds become visible at maximum range
+  static float MAX_CLOUD_DEPTH;
+
        // this is a relative position only, with that we can move all clouds at once
        SGVec3f relative_position;