]> git.mxchange.org Git - flightgear.git/commitdiff
Fix for "falling through ground" problem
authortimoore <timoore>
Thu, 20 Dec 2007 23:20:51 +0000 (23:20 +0000)
committertimoore <timoore>
Thu, 20 Dec 2007 23:20:51 +0000 (23:20 +0000)
The LOD far range on the tile entry scenegraph node was initialized to
0. This meant that any traverals of active children that happened
before the tile manager updated the node would ignore the node
altogether. Among these is the groundcache traversal which was failing
at startup even though scenery was loaded.

Also added a function to dump scene graph nodes to files; very handy
in gdb.

src/FDM/groundcache.cxx
src/Main/renderer.cxx
src/Scenery/tileentry.cxx

index dfec899cfe217c35aaea72deaa0ae0f2592cbc8c..13ed6ea2b385740a990aeb3228b2d9baba768024 100644 (file)
@@ -249,8 +249,8 @@ public:
     FGGroundCache::GroundProperty oldGp = mGroundProperty;
     if (!enterNode(geode))
       return;
-
-    for(unsigned i = 0; i < geode.getNumDrawables(); ++i)
+    unsigned int numDrawables = geode.getNumDrawables();
+    for(unsigned i = 0; i < numDrawables; ++i)
       fillWith(geode.getDrawable(i));
     sphIsec = oldSphIsec;
     mGroundProperty = oldGp;
@@ -438,12 +438,14 @@ public:
 
 FGGroundCache::FGGroundCache() :
   ground_radius(0.0),
+  _type(0),
+  _material(0),
   cache_ref_time(0.0),
   wire_id(0),
   reference_wgs84_point(SGVec3d(0, 0, 0)),
   reference_vehicle_radius(0.0),
-  found_ground(false),
-  _material(0)
+  down(0.0, 0.0, 0.0),
+  found_ground(false)
 {
 }
 
index e4f0d5230acf64265f421ff873440c364c89f0c4..2ac532f6e553398a3fe57cc878857b05804955c6 100644 (file)
@@ -1077,5 +1077,11 @@ fgDumpTerrainBranchToFile(const char* filename)
                                  filename );
 }
 
+// For debugging
+bool
+fgDumpNodeToFile(osg::Node* node, const char* filename)
+{
+    return osgDB::writeNodeFile(*node, filename);
+}
 // end of renderer.cxx
     
index 71c1ce258048c4eb5916a2b5fa0a3244bbcc1552..bbec0ee6a5b18d4ac444dddfce88644aead4fac9 100644 (file)
@@ -151,6 +151,10 @@ FGTileEntry::FGTileEntry ( const SGBucket& b )
     _node->setCullCallback(new TileCullCallback);
     tileFileName += ".stg";
     _node->setName(tileFileName);
+    // Give a default LOD range so that traversals that traverse
+    // active children (like the groundcache lookup) will work before
+    // tile manager has had a chance to update this node.
+    _node->setRange(0, 0.0, 10000.0);
 }
 
 
@@ -569,6 +573,11 @@ bool ReaderWriterSTG::acceptsExtension(const string& extension) const
             || osgDB::equalCaseInsensitive(extension, "stg"));   
 }
 
+//#define SLOW_PAGER 1
+#ifdef SLOW_PAGER
+#include <unistd.h>
+#endif
+
 osgDB::ReaderWriter::ReadResult
 ReaderWriterSTG::readNode(const string& fileName,
                           const osgDB::ReaderWriter::Options* options) const
@@ -589,6 +598,10 @@ ReaderWriterSTG::readNode(const string& fileName,
     osg::Node* result
         = FGTileEntry::loadTileByName(osgDB::getNameLessExtension(stgFileName),
                                       globals->get_fg_scenery());
+    // For debugging race conditions
+#ifdef SLOW_PAGER
+    sleep(5);
+#endif
     if (result)
         return result;           // Constructor converts to ReadResult
     else