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-24 16:10:58 +01:00
committed by James Turner
parent 4a86368c8f
commit a5b32f8eb2
2 changed files with 13 additions and 11 deletions

View File

@@ -280,19 +280,21 @@ ModelRegistry::readImage(const string& fileName,
}
osg::Node* DefaultCachePolicy::find(const string& fileName,
const Options* opt)
osg::ref_ptr<osg::Node> DefaultCachePolicy::find(const string& fileName, const Options* opt)
{
Registry* registry = Registry::instance();
osg::Node* cached
= dynamic_cast<Node*>(registry->getFromObjectCache(fileName));
if (cached)
SG_LOG(SG_IO, SG_BULK, "Got cached model \""
<< fileName << "\"");
#if OSG_VERSION_LESS_THAN(3,4,0)
osg::ref_ptr<osg::Object> cachedObject = registry->getFromObjectCache(fileName);
#else
osg::ref_ptr<osg::Object> cachedObject = registry->getRefFromObjectCache(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
SG_LOG(SG_IO, SG_BULK, "Reading model \""
<< fileName << "\"");
return cached;
SG_LOG(SG_IO, SG_BULK, "Reading model \"" << fileName << "\"");
return cachedNode;
}
void DefaultCachePolicy::addToCache(const string& fileName,

View File

@@ -132,7 +132,7 @@ struct DefaultProcessPolicy {
struct DefaultCachePolicy {
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);
void addToCache(const std::string& filename, osg::Node* node);
};