mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-29 08:00:56 -04:00
Keep a reference to the original scene template for as long as the instance is used
This commit is contained in:
parent
778bce3ae9
commit
41233fc8e5
@ -23,12 +23,10 @@ namespace Resource
|
||||
ObjectCache::ObjectCache():
|
||||
osg::Referenced(true)
|
||||
{
|
||||
// OSG_NOTICE<<"Constructed ObjectCache"<<std::endl;
|
||||
}
|
||||
|
||||
ObjectCache::~ObjectCache()
|
||||
{
|
||||
// OSG_NOTICE<<"Destructed ObjectCache"<<std::endl;
|
||||
}
|
||||
|
||||
void ObjectCache::addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp)
|
||||
|
@ -373,6 +373,10 @@ namespace Resource
|
||||
{
|
||||
osg::ref_ptr<const osg::Node> scene = getTemplate(name);
|
||||
osg::ref_ptr<osg::Node> cloned = osg::clone(scene.get(), SceneUtil::CopyOp());
|
||||
|
||||
// add a ref to the original template, to hint to the cache that it's still being used and should be kept in cache
|
||||
cloned->getOrCreateUserDataContainer()->addUserObject(const_cast<osg::Node*>(scene.get()));
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user