From 8b5b74f9ee3ec4b291e87d92fb01bfd78b177638 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 19 Jul 2012 22:34:26 -0700 Subject: [PATCH] Add a quick hack to let "playgroup all" work on creatures and NPCs --- apps/openmw/mwrender/creatureanimation.cpp | 42 +++++++++++++++------- apps/openmw/mwrender/npcanimation.cpp | 42 +++++++++++++++------- 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index fd2855154..492749553 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -52,6 +52,18 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O } ent->setRenderQueueGroup(transparent ? RQG_Alpha : RQG_Main); } + + if(mEntityList.mSkelBase) + { + Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates(); + Ogre::AnimationStateIterator as = aset->getAnimationStateIterator(); + while(as.hasMoreElements()) + { + Ogre::AnimationState *state = as.getNext(); + state->setEnabled(true); + state->setLoop(false); + } + } } } @@ -59,20 +71,26 @@ void CreatureAnimation::runAnimation(float timepassed) { if(mAnimate > 0) { - //Add the amount of time passed to time - - //Handle the animation transforms dependent on time - - //Handle the shapes dependent on animation transforms mTime += timepassed; - if(mTime >= mStopTime) + + if(mEntityList.mSkelBase) { - mAnimate--; - //std::cout << "Stopping the animation\n"; - if(mAnimate == 0) - mTime = mStopTime; - else - mTime = mStartTime + (mTime - mStopTime); + Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates(); + Ogre::AnimationStateIterator as = aset->getAnimationStateIterator(); + while(as.hasMoreElements()) + { + Ogre::AnimationState *state = as.getNext(); + state->setTimePosition(mTime); + if(state->getTimePosition() >= state->getLength()) + { + mAnimate--; + //std::cout << "Stopping the animation\n"; + if(mAnimate == 0) + mTime = state->getLength(); + else + mTime = mTime - state->getLength(); + } + } } handleAnimationTransforms(); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index a693a6b46..8c34acba2 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -117,6 +117,18 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRendere //stay in the same place when we skipanim, or open a gui window } + if(mEntityList.mSkelBase) + { + Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates(); + Ogre::AnimationStateIterator as = aset->getAnimationStateIterator(); + while(as.hasMoreElements()) + { + Ogre::AnimationState *state = as.getNext(); + state->setEnabled(true); + state->setLoop(false); + } + } + if(isFemale) mInsert->scale(race->data.height.female, race->data.height.female, race->data.height.female); else @@ -361,24 +373,30 @@ void NpcAnimation::runAnimation(float timepassed) timeToChange = 0; updateParts(); } - timeToChange += timepassed; - //1. Add the amount of time passed to time - - //2. Handle the animation transforms dependent on time - - //3. Handle the shapes dependent on animation transforms if(mAnimate > 0) { mTime += timepassed; - if(mTime > mStopTime) + + if(mEntityList.mSkelBase) { - mAnimate--; - if(mAnimate == 0) - mTime = mStopTime; - else - mTime = mStartTime + (mTime - mStopTime); + Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates(); + Ogre::AnimationStateIterator as = aset->getAnimationStateIterator(); + while(as.hasMoreElements()) + { + Ogre::AnimationState *state = as.getNext(); + state->setTimePosition(mTime); + if(state->getTimePosition() >= state->getLength()) + { + mAnimate--; + //std::cout << "Stopping the animation\n"; + if(mAnimate == 0) + mTime = state->getLength(); + else + mTime = mTime - state->getLength(); + } + } } handleAnimationTransforms();