Speed up ControllerVisitor by skipping sub graphs that have no ChildrenRequiringUpdateTraversal()

pull/140/head
scrawl 8 years ago
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)
src = mHeadAnimationTime;
if (node->getUserDataContainer())
{
osg::Object* obj = node->getUserDataContainer()->getUserObject(i);
if (NifOsg::TextKeyMapHolder* keys = dynamic_cast<NifOsg::TextKeyMapHolder*>(obj))
for (unsigned int i=0; i<node->getUserDataContainer()->getNumUserObjects(); ++i)
{
for (NifOsg::TextKeyMap::const_iterator it = keys->mTextKeys.begin(); it != keys->mTextKeys.end(); ++it)
osg::Object* obj = node->getUserDataContainer()->getUserObject(i);
if (NifOsg::TextKeyMapHolder* keys = dynamic_cast<NifOsg::TextKeyMapHolder*>(obj))
{
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);
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;
}
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…
Cancel
Save