diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 53eaf0996..e85008679 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -770,43 +770,46 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g } } - boost::shared_ptr 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 src; + if (type == ESM::PRT_Head) { - for (unsigned int i=0; igetUserDataContainer()->getNumUserObjects(); ++i) + src = mHeadAnimationTime; + + if (node->getUserDataContainer()) { - osg::Object* obj = node->getUserDataContainer()->getUserObject(i); - if (NifOsg::TextKeyMapHolder* keys = dynamic_cast(obj)) + for (unsigned int i=0; igetUserDataContainer()->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(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; } diff --git a/components/sceneutil/controller.cpp b/components/sceneutil/controller.cpp index 12c89c87d..15a614880 100644 --- a/components/sceneutil/controller.cpp +++ b/components/sceneutil/controller.cpp @@ -81,7 +81,8 @@ namespace SceneUtil callback = callback->getNestedCallback(); } - traverse(node); + if (node.getNumChildrenRequiringUpdateTraversal() > 0) + traverse(node); } AssignControllerSourcesVisitor::AssignControllerSourcesVisitor()