mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Speed up ControllerVisitor by skipping sub graphs that have no ChildrenRequiringUpdateTraversal()
This commit is contained in:
parent
c58fc6d276
commit
a76d693627
@ -770,43 +770,46 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
|
||||
}
|
||||
}
|
||||
|
||||
boost::shared_ptr<SceneUtil::ControllerSource> src;
|
||||
if (type == ESM::PRT_Head)
|
||||
osg::Node* node = mObjectParts[type]->getNode();
|
||||
if (node->getNumChildrenRequiringUpdateTraversal() > 0)
|
||||
{
|
||||
src = mHeadAnimationTime;
|
||||
|
||||
osg::Node* node = mObjectParts[type]->getNode();
|
||||
if (node->getUserDataContainer())
|
||||
boost::shared_ptr<SceneUtil::ControllerSource> src;
|
||||
if (type == ESM::PRT_Head)
|
||||
{
|
||||
for (unsigned int i=0; i<node->getUserDataContainer()->getNumUserObjects(); ++i)
|
||||
{
|
||||
osg::Object* obj = node->getUserDataContainer()->getUserObject(i);
|
||||
if (NifOsg::TextKeyMapHolder* keys = dynamic_cast<NifOsg::TextKeyMapHolder*>(obj))
|
||||
{
|
||||
for (NifOsg::TextKeyMap::const_iterator it = keys->mTextKeys.begin(); it != keys->mTextKeys.end(); ++it)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(it->second, "talk: start"))
|
||||
mHeadAnimationTime->setTalkStart(it->first);
|
||||
if (Misc::StringUtils::ciEqual(it->second, "talk: stop"))
|
||||
mHeadAnimationTime->setTalkStop(it->first);
|
||||
if (Misc::StringUtils::ciEqual(it->second, "blink: start"))
|
||||
mHeadAnimationTime->setBlinkStart(it->first);
|
||||
if (Misc::StringUtils::ciEqual(it->second, "blink: stop"))
|
||||
mHeadAnimationTime->setBlinkStop(it->first);
|
||||
}
|
||||
src = mHeadAnimationTime;
|
||||
|
||||
break;
|
||||
if (node->getUserDataContainer())
|
||||
{
|
||||
for (unsigned int i=0; i<node->getUserDataContainer()->getNumUserObjects(); ++i)
|
||||
{
|
||||
osg::Object* obj = node->getUserDataContainer()->getUserObject(i);
|
||||
if (NifOsg::TextKeyMapHolder* keys = dynamic_cast<NifOsg::TextKeyMapHolder*>(obj))
|
||||
{
|
||||
for (NifOsg::TextKeyMap::const_iterator it = keys->mTextKeys.begin(); it != keys->mTextKeys.end(); ++it)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(it->second, "talk: start"))
|
||||
mHeadAnimationTime->setTalkStart(it->first);
|
||||
if (Misc::StringUtils::ciEqual(it->second, "talk: stop"))
|
||||
mHeadAnimationTime->setTalkStop(it->first);
|
||||
if (Misc::StringUtils::ciEqual(it->second, "blink: start"))
|
||||
mHeadAnimationTime->setBlinkStart(it->first);
|
||||
if (Misc::StringUtils::ciEqual(it->second, "blink: stop"))
|
||||
mHeadAnimationTime->setBlinkStop(it->first);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type == ESM::PRT_Weapon)
|
||||
src = mWeaponAnimationTime;
|
||||
else
|
||||
src.reset(new NullAnimationTime);
|
||||
else if (type == ESM::PRT_Weapon)
|
||||
src = mWeaponAnimationTime;
|
||||
else
|
||||
src.reset(new NullAnimationTime);
|
||||
|
||||
SceneUtil::AssignControllerSourcesVisitor assignVisitor(src);
|
||||
mObjectParts[type]->getNode()->accept(assignVisitor);
|
||||
SceneUtil::AssignControllerSourcesVisitor assignVisitor(src);
|
||||
node->accept(assignVisitor);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -81,7 +81,8 @@ namespace SceneUtil
|
||||
callback = callback->getNestedCallback();
|
||||
}
|
||||
|
||||
traverse(node);
|
||||
if (node.getNumChildrenRequiringUpdateTraversal() > 0)
|
||||
traverse(node);
|
||||
}
|
||||
|
||||
AssignControllerSourcesVisitor::AssignControllerSourcesVisitor()
|
||||
|
Loading…
x
Reference in New Issue
Block a user