mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 22:45:36 +00:00
Define template ref classes in components
This commit is contained in:
parent
3e35df49df
commit
f175beb304
4 changed files with 32 additions and 25 deletions
|
@ -249,15 +249,6 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TemplateRef : public osg::Object
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TemplateRef() {}
|
|
||||||
TemplateRef(const TemplateRef& copy, const osg::CopyOp&) : mObjects(copy.mObjects) {}
|
|
||||||
META_Object(MWRender, TemplateRef)
|
|
||||||
std::vector<osg::ref_ptr<const Object>> mObjects;
|
|
||||||
};
|
|
||||||
|
|
||||||
class RefnumSet : public osg::Object
|
class RefnumSet : public osg::Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -530,7 +521,7 @@ namespace MWRender
|
||||||
|
|
||||||
osg::ref_ptr<osg::Group> group = new osg::Group;
|
osg::ref_ptr<osg::Group> group = new osg::Group;
|
||||||
osg::ref_ptr<osg::Group> mergeGroup = new osg::Group;
|
osg::ref_ptr<osg::Group> mergeGroup = new osg::Group;
|
||||||
osg::ref_ptr<TemplateRef> templateRefs = new TemplateRef;
|
osg::ref_ptr<Resource::TemplateMultiRef> templateRefs = new Resource::TemplateMultiRef;
|
||||||
osgUtil::StateToCompile stateToCompile(0, nullptr);
|
osgUtil::StateToCompile stateToCompile(0, nullptr);
|
||||||
CopyOp copyop;
|
CopyOp copyop;
|
||||||
for (const auto& pair : nodes)
|
for (const auto& pair : nodes)
|
||||||
|
@ -596,7 +587,7 @@ namespace MWRender
|
||||||
if (numinstances > 0)
|
if (numinstances > 0)
|
||||||
{
|
{
|
||||||
// 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
|
||||||
templateRefs->mObjects.emplace_back(cnode);
|
templateRefs->addRef(cnode);
|
||||||
|
|
||||||
if (pair.second.mNeedCompile)
|
if (pair.second.mNeedCompile)
|
||||||
{
|
{
|
||||||
|
|
|
@ -110,6 +110,10 @@ namespace
|
||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
{
|
{
|
||||||
|
void TemplateMultiRef::addRef(const osg::Node* node)
|
||||||
|
{
|
||||||
|
mObjects.emplace_back(node);
|
||||||
|
}
|
||||||
|
|
||||||
class SharedStateManager : public osgDB::SharedStateManager
|
class SharedStateManager : public osgDB::SharedStateManager
|
||||||
{
|
{
|
||||||
|
@ -554,20 +558,6 @@ 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);
|
||||||
|
|
|
@ -37,6 +37,31 @@ namespace Shader
|
||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
{
|
{
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TemplateMultiRef : public osg::Object
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TemplateMultiRef() {}
|
||||||
|
TemplateMultiRef(const TemplateMultiRef& copy, const osg::CopyOp&) : mObjects(copy.mObjects) {}
|
||||||
|
void addRef(const osg::Node* node);
|
||||||
|
|
||||||
|
META_Object(Resource, TemplateMultiRef)
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<osg::ref_ptr<const Object>> mObjects;
|
||||||
|
};
|
||||||
|
|
||||||
class MultiObjectCache;
|
class MultiObjectCache;
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,7 @@ void registerSerializers()
|
||||||
const char* ignore[] = {
|
const char* ignore[] = {
|
||||||
"MWRender::PtrHolder",
|
"MWRender::PtrHolder",
|
||||||
"Resource::TemplateRef",
|
"Resource::TemplateRef",
|
||||||
|
"Resource::TemplateMultiRef",
|
||||||
"SceneUtil::CompositeStateSetUpdater",
|
"SceneUtil::CompositeStateSetUpdater",
|
||||||
"SceneUtil::LightListCallback",
|
"SceneUtil::LightListCallback",
|
||||||
"SceneUtil::LightManagerUpdateCallback",
|
"SceneUtil::LightManagerUpdateCallback",
|
||||||
|
|
Loading…
Reference in a new issue