]> git.mxchange.org Git - simgear.git/commitdiff
QuadTree fix for large buildings.
authorStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Fri, 6 Nov 2015 21:38:53 +0000 (21:38 +0000)
committerStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Fri, 6 Nov 2015 21:38:53 +0000 (21:38 +0000)
QuadTree relies on a bounding box to set up correctly.

ProxyNodes don't have a BB until the model is loaded,
causing the QuadTree to collapse if the DB loader can't
keep up with the STG loader.

Fix this by creating a default BB before the model
is loaded.

simgear/scene/tgdb/ReaderWriterSTG.cxx

index 97216ec82154a59040f9a417ac0a450e7ec5ff99..b0dfc10bba45f31332352c18b85f0db3dddcddc4 100644 (file)
@@ -130,6 +130,12 @@ struct ReaderWriterSTG::_ModelBin {
                 proxy->setLoadingExternalReferenceMode(osg::ProxyNode::DEFER_LOADING_TO_DATABASE_PAGER);
                 proxy->setFileName(0, o._name);
                 proxy->setDatabaseOptions(o._options.get());
+
+                // Give the node some values so the Quadtree builder has
+                // a BoundingBox to work with prior to the model being loaded.
+                proxy->setCenter(osg::Vec3f(0.0f,0.0f,0.0f));
+                proxy->setRadius(10);
+                proxy->setCenterMode(osg::ProxyNode::UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED);
                 node = proxy;
             } else {
                 node = osgDB::readRefNodeFile(o._name, o._options.get());
@@ -292,7 +298,7 @@ struct ReaderWriterSTG::_ModelBin {
             // read a line
             std::string line;
             std::getline(stream, line);
-            
+
             // strip comments
             std::string::size_type hash_pos = line.find('#');
             if (hash_pos != std::string::npos)