]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/SGPagedLOD.cxx
Improved tile cache priority scheme.
[simgear.git] / simgear / scene / model / SGPagedLOD.cxx
index bdd19c9cf7c6095cd290b9623ec8efa0103e562d..faaf42bb23f3ead4667dc06cf2b2a8800858d1ed 100644 (file)
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
+
 #include <osgDB/ReadFile>
+#include <osgDB/Input>
+#include <osgDB/ParameterOutput>
 
 #include <simgear/debug/logstream.hxx>
+#include <simgear/structure/OSGVersion.hxx>
 
 #include "modellib.hxx"
 #include "SGReaderWriterXMLOptions.hxx"
 #include "SGPagedLOD.hxx"
 
+#include <simgear/math/SGMath.hxx>
+
 using namespace osg;
 using namespace simgear;
 
@@ -43,34 +52,39 @@ SGPagedLOD::SGPagedLOD(const SGPagedLOD& plod,const CopyOp& copyop)
 
 bool SGPagedLOD::addChild(osg::Node *child)
 {
-    //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::addChild(" << getFileName(getNumChildren()) << ")");
     if (!PagedLOD::addChild(child))
         return false;
 
     setRadius(getBound().radius());
     setCenter(getBound().center());
-    // if the model was an .xml-file it will have UserData set
-    osg::ref_ptr<SGModelData> d = dynamic_cast<SGModelData*>(child->getUserData());
-    if (d.valid())
-        d->modelLoaded(getFileName(getNumChildren()-1), d->getProperties(), this);
-    else // this calls modelLoaded for non-xml models
-    {
-        SGReaderWriterXMLOptions *o=dynamic_cast<SGReaderWriterXMLOptions*>(_readerWriterOptions.get());
-        if(o)
-        {
-            d = o->getModelData();
-            if(d.valid())
-                d->modelLoaded(getFileName(getNumChildren()-1), 0, this);
-        }
-    }
     return true;
 }
 
 void SGPagedLOD::forceLoad(osgDB::DatabasePager *dbp)
 {
-    //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::forceLoad(" << getFileName(getNumChildren()) << ")");
-    setTimeStamp(getNumChildren(),0);
+    //SG_LOG(SG_GENERAL, SG_ALERT, "SGPagedLOD::forceLoad(" <<
+    //getFileName(getNumChildren()) << ")");
+    unsigned childNum = getNumChildren();
+    setTimeStamp(childNum, 0);
     double priority=1.0;
-    dbp->requestNodeFile(getFileName(getNumChildren()),this,priority,0, _readerWriterOptions.get());
+    dbp->requestNodeFile(getFileName(childNum),this,priority,0,
+                         getDatabaseRequest(childNum),
+                         _readerWriterOptions.get());
+}
+
+bool SGPagedLOD_writeLocalData(const Object& obj, osgDB::Output& fw)
+{
+    return true;
 }
 
+namespace
+{
+osgDB::RegisterDotOsgWrapperProxy sgPagedLODProxy
+(
+    new SGPagedLOD,
+    "simgear::SGPagedLOD",
+    "Object Node LOD PagedLOD SGPagedLOD Group",
+    0,
+    &SGPagedLOD_writeLocalData
+    );
+}