mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Wrap the scene template reference in another object for const correctness and to avoid it from being serialized with the osgDB serializer
This commit is contained in:
parent
29abb62dee
commit
e90941a8b3
1 changed files with 15 additions and 1 deletions
|
@ -413,13 +413,27 @@ namespace Resource
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TemplateRef : public osg::Object
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TemplateRef(const Object* object)
|
||||||
|
: mObject(object) {}
|
||||||
|
TemplateRef() {}
|
||||||
|
TemplateRef(const TemplateRef& copy, const osg::CopyOp&) : mObject(copy.mObject) {}
|
||||||
|
|
||||||
|
META_Object(Resource, TemplateRef)
|
||||||
|
|
||||||
|
private:
|
||||||
|
osg::ref_ptr<const Object> mObject;
|
||||||
|
};
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> SceneManager::createInstance(const std::string& name)
|
osg::ref_ptr<osg::Node> SceneManager::createInstance(const std::string& name)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<const osg::Node> scene = getTemplate(name);
|
osg::ref_ptr<const osg::Node> scene = getTemplate(name);
|
||||||
osg::ref_ptr<osg::Node> cloned = osg::clone(scene.get(), SceneUtil::CopyOp());
|
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
|
// 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()));
|
cloned->getOrCreateUserDataContainer()->addUserObject(new TemplateRef(scene));
|
||||||
|
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue