From 1cdd64cd9b0c90cc8b0c78e4e21a3cd90c525df3 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 18 Jan 2013 17:05:58 -0800 Subject: [PATCH] Return the animation movement from the character controller. Consequently, dead actors don't move anymore. The doPhysics call apparently isn't moving them. --- apps/openmw/mwmechanics/character.cpp | 19 +++++++++++++++++-- apps/openmw/mwrender/animation.cpp | 10 ---------- apps/openmw/mwrender/animation.hpp | 7 +++---- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index ff400b9d10..226f000692 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -120,10 +120,25 @@ void CharacterController::markerEvent(float time, const std::string &evt) Ogre::Vector3 CharacterController::update(float duration) { + Ogre::Vector3 movement = Ogre::Vector3::ZERO; if(mAnimation && !mSkipAnim) - mAnimation->runAnimation(duration); + movement += mAnimation->runAnimation(duration); mSkipAnim = false; - return mDirection; + + if(getState() == CharState_SpecialIdle || getState() == CharState_Idle || + getState() == CharState_Dead) + { + // FIXME: mDirection shouldn't influence the movement here. + movement += mDirection; + } + else + { + // FIXME: mDirection should be normalized after setting the speed of + // the animation in setDirection, rather than here. + movement = mDirection.normalisedCopy() * movement.length(); + } + + return movement; } diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index f9fa6e14cd..4d8f9586fb 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -140,16 +140,6 @@ Ogre::Vector3 Animation::updatePosition(float time) /* Translate the accumulation root back to compensate for the move. */ mAccumRoot->translate(-posdiff); mLastPosition += posdiff; - - if(mPtr.isInCell()) - { - /* Finally, move the object based on how much the non-accumulation root moved. */ - Ogre::Vector3 newpos(mPtr.getRefData().getPosition().pos); - newpos += mInsert->getOrientation() * posdiff; - - MWBase::World *world = MWBase::Environment::get().getWorld(); - world->moveObject(mPtr, newpos.x, newpos.y, newpos.z); - } } return posdiff; } diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index dfa2950f35..349871f0a6 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -32,11 +32,10 @@ protected: NifOgre::TextKeyMap::const_iterator mNextKey; Ogre::AnimationState *mAnimState; - /* Updates the animation to the specified time, and moves the mPtr object - * based on the change since the last update or reset. */ + /* Updates the animation to the specified time, and returns the movement + * vector since the last update or reset. */ Ogre::Vector3 updatePosition(float time); - /* Updates the animation to the specified time, without moving the mPtr - * object. */ + /* Updates the animation to the specified time, without moving anything. */ void resetPosition(float time); float findStart(const std::string &groupname, const std::string &start);