]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/modellib.cxx
Add preliminary spot light animation
[simgear.git] / simgear / scene / model / modellib.cxx
index 5fa40fca2e5b296f24ec315face10c32949033e0..af72e363d65d7a02e25dbad561b6ccf04b120d66 100644 (file)
@@ -65,14 +65,16 @@ void SGModelLib::setPanelFunc(panel_func pf)
 }
 
 std::string SGModelLib::findDataFile(const std::string& file, 
-  const osgDB::ReaderWriter::Options* opts,
+  const osgDB::Options* opts,
   SGPath currentPath)
 {
+  if (file.empty())
+    return file;
   SGPath p = ResourceManager::instance()->findPath(file, currentPath);
   if (p.exists()) {
     return p.str();
   }
-      
+
   // finally hand on to standard OSG behaviour
   return osgDB::findDataFile(file, opts);
 }
@@ -107,7 +109,8 @@ SGModelLib::loadModel(const string &path,
                        SGModelData *data,
                        bool load2DPanels)
 {
-    osg::ref_ptr<SGReaderWriterOptions> opt = new SGReaderWriterOptions(*(osgDB::Registry::instance()->getOptions()));
+    osg::ref_ptr<SGReaderWriterOptions> opt;
+    opt = SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions());
     opt->setPropertyNode(prop_root ? prop_root: static_propRoot.get());
     opt->setModelData(data);
     
@@ -130,18 +133,17 @@ SGModelLib::loadDeferredModel(const string &path, SGPropertyNode *prop_root,
     proxyNode->setLoadingExternalReferenceMode(osg::ProxyNode::DEFER_LOADING_TO_DATABASE_PAGER);
     proxyNode->setFileName(0, path);
 
-    osg::ref_ptr<SGReaderWriterOptions> opt
-        = new SGReaderWriterOptions(*(osgDB::Registry::instance()
-                                         ->getOptions()));
+    osg::ref_ptr<SGReaderWriterOptions> opt;
+    opt = SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions());
     opt->setPropertyNode(prop_root ? prop_root: static_propRoot.get());
     opt->setModelData(data);
     opt->setLoadPanel(static_panelFunc);
     if (SGPath(path).lower_extension() == "ac")
         opt->setInstantiateEffects(true);
     if (!prop_root || prop_root->getBoolValue("/sim/rendering/cache", true))
-        opt->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_ALL);
+        opt->setObjectCacheHint(osgDB::Options::CACHE_ALL);
     else
-        opt->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE);
+        opt->setObjectCacheHint(osgDB::Options::CACHE_NONE);
     proxyNode->setDatabaseOptions(opt.get());
 
     return proxyNode;
@@ -156,18 +158,17 @@ SGModelLib::loadPagedModel(const string &path, SGPropertyNode *prop_root,
     plod->setFileName(0, path);
     plod->setRange(0, 0.0, 50.0*SG_NM_TO_METER);
 
-    osg::ref_ptr<SGReaderWriterOptions> opt
-        = new SGReaderWriterOptions(*(osgDB::Registry::instance()
-                                         ->getOptions()));
+    osg::ref_ptr<SGReaderWriterOptions> opt;
+    opt = SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions());
     opt->setPropertyNode(prop_root ? prop_root: static_propRoot.get());
     opt->setModelData(data);
     opt->setLoadPanel(static_panelFunc);
     if (SGPath(path).lower_extension() == "ac")
         opt->setInstantiateEffects(true);
     if (!prop_root || prop_root->getBoolValue("/sim/rendering/cache", true))
-        opt->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_ALL);
+        opt->setObjectCacheHint(osgDB::Options::CACHE_ALL);
     else
-        opt->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE);
+        opt->setObjectCacheHint(osgDB::Options::CACHE_NONE);
     plod->setDatabaseOptions(opt.get());
     return plod;
 }