diff --git a/src/FDM/groundcache.cxx b/src/FDM/groundcache.cxx index dfec899cf..13ed6ea2b 100644 --- a/src/FDM/groundcache.cxx +++ b/src/FDM/groundcache.cxx @@ -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) { } diff --git a/src/Main/renderer.cxx b/src/Main/renderer.cxx index e4f0d5230..2ac532f6e 100644 --- a/src/Main/renderer.cxx +++ b/src/Main/renderer.cxx @@ -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 diff --git a/src/Scenery/tileentry.cxx b/src/Scenery/tileentry.cxx index 71c1ce258..bbec0ee6a 100644 --- a/src/Scenery/tileentry.cxx +++ b/src/Scenery/tileentry.cxx @@ -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