Change some osg::clone's to direct copy constructor to avoid dynamic_cast overhead

pull/145/head
scrawl 7 years ago
parent 93c582064e
commit 67e4a7e37b

@ -543,7 +543,7 @@ namespace MWRender
size_t blendMask = detectBlendMask(node);
// clone the controller, because each Animation needs its own ControllerSource
osg::ref_ptr<NifOsg::KeyframeController> cloned = osg::clone(it->second.get(), osg::CopyOp::DEEP_COPY_ALL);
osg::ref_ptr<NifOsg::KeyframeController> cloned = new NifOsg::KeyframeController(*it->second, osg::CopyOp::SHALLOW_COPY);
cloned->setSource(mAnimationTimePtr[blendMask]);
animsrc->mControllerMap[blendMask].insert(std::make_pair(bonename, cloned));
@ -1272,7 +1272,7 @@ namespace MWRender
writableStateSet = node->getOrCreateStateSet();
else
{
writableStateSet = osg::clone(node->getStateSet(), osg::CopyOp::SHALLOW_COPY);
writableStateSet = new osg::StateSet(*node->getStateSet(), osg::CopyOp::SHALLOW_COPY);
node->setStateSet(writableStateSet);
}
writableStateSet->setTextureAttributeAndModes(texUnit, textures.front(), osg::StateAttribute::ON);

@ -55,7 +55,7 @@ void overrideTexture(const std::string &texture, Resource::ResourceSystem *resou
osg::ref_ptr<osg::StateSet> stateset;
if (node->getStateSet())
stateset = osg::clone(node->getStateSet(), osg::CopyOp::SHALLOW_COPY);
stateset = new osg::StateSet(*node->getStateSet(), osg::CopyOp::SHALLOW_COPY);
else
stateset = new osg::StateSet;

@ -368,7 +368,7 @@ namespace SceneUtil
mId = sLightId++;
for (int i=0; i<2; ++i)
mLight[i] = osg::clone(copy.mLight[i].get(), copyop);
mLight[i] = new osg::Light(*copy.mLight[i].get(), copyop);
}

@ -64,7 +64,7 @@ namespace SceneUtil
void setLight(osg::Light* light)
{
mLight[0] = light;
mLight[1] = osg::clone(light);
mLight[1] = new osg::Light(*light);
}
/// Get the unique ID for this light source.

@ -15,7 +15,7 @@ namespace SceneUtil
for (int i=0; i<2; ++i) // Using SHALLOW_COPY for StateAttributes, if users want to modify it is their responsibility to set a non-shared one first
// This can be done conveniently in user implementations of the setDefaults() method
{
mStateSets[i] = osg::clone(src, osg::CopyOp::SHALLOW_COPY);
mStateSets[i] = new osg::StateSet(*src, osg::CopyOp::SHALLOW_COPY);
setDefaults(mStateSets[i]);
}
}

@ -85,7 +85,7 @@ namespace Shader
if (!node.getStateSet())
return node.getOrCreateStateSet();
osg::ref_ptr<osg::StateSet> newStateSet = osg::clone(node.getStateSet(), osg::CopyOp::SHALLOW_COPY);
osg::ref_ptr<osg::StateSet> newStateSet = new osg::StateSet(*node.getStateSet(), osg::CopyOp::SHALLOW_COPY);
node.setStateSet(newStateSet);
return newStateSet.get();
}

Loading…
Cancel
Save