]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/ModelRegistry.cxx
Work around apparent OSG 3.2.0 normal binding bug.
[simgear.git] / simgear / scene / model / ModelRegistry.cxx
index 54b98a0d621a577d1a8057307ebfd7d93a87270b..58c5bc37ecab1c3f461099c92f031a1e47ccd23f 100644 (file)
@@ -64,29 +64,7 @@ using namespace osgUtil;
 using namespace osgDB;
 using namespace simgear;
 
-// Little helper class that holds an extra reference to a
-// loaded 3d model.
-// Since we clone all structural nodes from our 3d models,
-// the database pager will only see one single reference to
-// top node of the model and expire it relatively fast.
-// We attach that extra reference to every model cloned from
-// a base model in the pager. When that cloned model is deleted
-// this extra reference is deleted too. So if there are no
-// cloned models left the model will expire.
 namespace {
-class SGDatabaseReference : public Observer {
-public:
-  SGDatabaseReference(Referenced* referenced) :
-    mReferenced(referenced)
-  { }
-  virtual void objectDeleted(void*)
-  {
-    mReferenced = 0;
-  }
-private:
-  ref_ptr<Referenced> mReferenced;
-};
-
 // Set the name of a Texture to the simple name of its image
 // file. This can be used to do livery substitution after the image
 // has been deallocated.
@@ -193,7 +171,7 @@ public:
 } // namespace
 
 Node* DefaultProcessPolicy::process(Node* node, const string& filename,
-                                    const ReaderWriter::Options* opt)
+                                    const Options* opt)
 {
     TextureNameVisitor nameVisitor;
     node->accept(nameVisitor);
@@ -202,7 +180,7 @@ Node* DefaultProcessPolicy::process(Node* node, const string& filename,
 
 ReaderWriter::ReadResult
 ModelRegistry::readImage(const string& fileName,
-                         const ReaderWriter::Options* opt)
+                         const Options* opt)
 {
     CallbackMap::iterator iter
         = imageCallbackMap.find(getFileExtension(fileName));
@@ -284,10 +262,10 @@ ModelRegistry::readImage(const string& fileName,
         case GL_COMPRESSED_RED_GREEN_RGTC2_EXT:
         case GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:
 
-            SG_LOG(SG_IO, SG_ALERT, "Image \"" << fileName
-                   << "\" contains non portable compressed textures.\n"
-                   "Usage of these textures depend on an extension that"
-                   " is not guaranteed to be present.");
+            SG_LOG(SG_IO, SG_ALERT, "Image \"" << fileName << "\"\n"
+                   "uses compressed textures which cannot be supported on "
+                   "some systems.\n"
+                   "Please decompress this texture for improved portability.");
             break;
 
         default:
@@ -300,7 +278,7 @@ ModelRegistry::readImage(const string& fileName,
 
 
 osg::Node* DefaultCachePolicy::find(const string& fileName,
-                                    const ReaderWriter::Options* opt)
+                                    const Options* opt)
 {
     Registry* registry = Registry::instance();
     osg::Node* cached
@@ -336,13 +314,15 @@ OptimizeModelPolicy::OptimizeModelPolicy(const string& extension) :
     _osgOptions(Optimizer::SHARE_DUPLICATE_STATE
                 | Optimizer::MERGE_GEOMETRY
                 | Optimizer::FLATTEN_STATIC_TRANSFORMS
-                | Optimizer::TRISTRIP_GEOMETRY)
+                | Optimizer::INDEX_MESH
+                | Optimizer::VERTEX_POSTTRANSFORM
+                | Optimizer::VERTEX_PRETRANSFORM)
 {
 }
 
 osg::Node* OptimizeModelPolicy::optimize(osg::Node* node,
                                          const string& fileName,
-                                         const osgDB::ReaderWriter::Options* opt)
+                                         const osgDB::Options* opt)
 {
     osgUtil::Optimizer optimizer;
     optimizer.optimize(node, _osgOptions);
@@ -358,7 +338,7 @@ osg::Node* OptimizeModelPolicy::optimize(osg::Node* node,
 }
 
 string OSGSubstitutePolicy::substitute(const string& name,
-                                       const ReaderWriter::Options* opt)
+                                       const Options* opt)
 {
     string fileSansExtension = getNameLessExtension(name);
     string osgFileName = fileSansExtension + ".osg";
@@ -413,7 +393,7 @@ ModelRegistry::addNodeCallbackForExtension(const string& extension,
 
 ReaderWriter::ReadResult
 ModelRegistry::readNode(const string& fileName,
-                        const ReaderWriter::Options* opt)
+                        const Options* opt)
 {
     ReaderWriter::ReadResult res;
     CallbackMap::iterator iter
@@ -436,10 +416,10 @@ public:
     Referenced::setThreadSafeReferenceCounting(true);
 
     Registry* registry = Registry::instance();
-    ReaderWriter::Options* options = new ReaderWriter::Options;
-    int cacheOptions = ReaderWriter::Options::CACHE_ALL;
+    Options* options = new Options;
+    int cacheOptions = Options::CACHE_ALL;
     options->
-      setObjectCacheHint((ReaderWriter::Options::CacheHintOptions)cacheOptions);
+      setObjectCacheHint((Options::CacheHintOptions)cacheOptions);
     registry->setOptions(options);
     registry->getOrCreateSharedStateManager()->
       setShareMode(SharedStateManager::SHARE_STATESETS);
@@ -457,7 +437,7 @@ struct ACOptimizePolicy : public OptimizeModelPolicy {
         _osgOptions &= ~Optimizer::TRISTRIP_GEOMETRY;
     }
     Node* optimize(Node* node, const string& fileName,
-                   const ReaderWriter::Options* opt)
+                   const Options* opt)
     {
         ref_ptr<Node> optimized
             = OptimizeModelPolicy::optimize(node, fileName, opt);
@@ -484,7 +464,7 @@ struct ACOptimizePolicy : public OptimizeModelPolicy {
 struct ACProcessPolicy {
     ACProcessPolicy(const string& extension) {}
     Node* process(Node* node, const string& filename,
-                  const ReaderWriter::Options* opt)
+                  const Options* opt)
     {
         Matrix m(1, 0, 0, 0,
                  0, 0, 1, 0,