mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 16:29:55 +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;
|
||||
}
|
||||
|
||||
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<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()));
|
||||
cloned->getOrCreateUserDataContainer()->addUserObject(new TemplateRef(scene));
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue