Fix for deleting referenced object from model registry

This should have been in the previous commit - However I managed to mess up the merging of this module due to other changes related to the DDS texture cache.
This commit is contained in:
Richard Harrison
2019-01-25 21:39:03 +00:00
committed by James Turner
parent 4a86368c8f
commit a5b32f8eb2
2 changed files with 13 additions and 11 deletions
+12 -10
View File
@@ -280,19 +280,21 @@ ModelRegistry::readImage(const string& fileName,
} }
osg::Node* DefaultCachePolicy::find(const string& fileName, osg::ref_ptr<osg::Node> DefaultCachePolicy::find(const string& fileName, const Options* opt)
const Options* opt)
{ {
Registry* registry = Registry::instance(); Registry* registry = Registry::instance();
osg::Node* cached #if OSG_VERSION_LESS_THAN(3,4,0)
= dynamic_cast<Node*>(registry->getFromObjectCache(fileName)); osg::ref_ptr<osg::Object> cachedObject = registry->getFromObjectCache(fileName);
if (cached) #else
SG_LOG(SG_IO, SG_BULK, "Got cached model \"" osg::ref_ptr<osg::Object> cachedObject = registry->getRefFromObjectCache(fileName);
<< fileName << "\""); #endif
ref_ptr<osg::Node> cachedNode = dynamic_cast<osg::Node*>(cachedObject.get());
if (cachedNode.valid())
SG_LOG(SG_IO, SG_BULK, "Got cached model \"" << fileName << "\"");
else else
SG_LOG(SG_IO, SG_BULK, "Reading model \"" SG_LOG(SG_IO, SG_BULK, "Reading model \"" << fileName << "\"");
<< fileName << "\""); return cachedNode;
return cached;
} }
void DefaultCachePolicy::addToCache(const string& fileName, void DefaultCachePolicy::addToCache(const string& fileName,
+1 -1
View File
@@ -132,7 +132,7 @@ struct DefaultProcessPolicy {
struct DefaultCachePolicy { struct DefaultCachePolicy {
DefaultCachePolicy(const std::string& extension) {} DefaultCachePolicy(const std::string& extension) {}
osg::Node* find(const std::string& fileName, osg::ref_ptr<osg::Node> find(const std::string& fileName,
const osgDB::Options* opt); const osgDB::Options* opt);
void addToCache(const std::string& filename, osg::Node* node); void addToCache(const std::string& filename, osg::Node* node);
}; };