From 4641737fc4b6cc96544cca469efd2b7db920a760 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 7 Aug 2013 17:23:53 -0700 Subject: [PATCH] Update part skeletons immediately when added --- apps/openmw/mwrender/npcanimation.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index e8777b5654..36f5886fd6 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -493,20 +493,25 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g mPartPriorities[type] = priority; mObjectParts[type] = insertBoundedPart(mesh, group, sPartList.at(type)); - if(mObjectParts[type].mSkelBase && mObjectParts[type].mSkelBase->isParentTagPoint()) + if(mObjectParts[type].mSkelBase) { - Ogre::Node *root = mObjectParts[type].mSkelBase->getParentNode(); Ogre::SkeletonInstance *skel = mObjectParts[type].mSkelBase->getSkeleton(); - if(skel->hasBone("BoneOffset")) + if(mObjectParts[type].mSkelBase->isParentTagPoint()) { - Ogre::Bone *offset = skel->getBone("BoneOffset"); - root->translate(offset->getPosition()); - root->rotate(offset->getOrientation()); - // HACK: Why an extra -90 degree rotation? - root->pitch(Ogre::Degree(-90.0f)); - root->scale(offset->getScale()); - root->setInitialState(); + Ogre::Node *root = mObjectParts[type].mSkelBase->getParentNode(); + if(skel->hasBone("BoneOffset")) + { + Ogre::Bone *offset = skel->getBone("BoneOffset"); + root->translate(offset->getPosition()); + root->rotate(offset->getOrientation()); + // HACK: Why an extra -90 degree rotation? + root->pitch(Ogre::Degree(-90.0f)); + root->scale(offset->getScale()); + root->setInitialState(); + } } + + updateSkeletonInstance(mSkelBase->getSkeleton(), skel); } // TODO: @@ -521,7 +526,7 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g ctrl->setSource(mNullAnimationValuePtr); } - return true; + return true; } void NpcAnimation::addPartGroup(int group, int priority, const std::vector &parts)