From 7ee389f3b2006bb05aee871e5774c32d64a65b6f Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 16 Jan 2013 21:25:50 -0800 Subject: [PATCH] Handle animation skipping in the character controller --- apps/openmw/mwmechanics/character.cpp | 10 +++++----- apps/openmw/mwmechanics/character.hpp | 1 + apps/openmw/mwrender/animation.cpp | 10 ---------- apps/openmw/mwrender/animation.hpp | 3 --- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index c347312c24..547d9e0a50 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -30,7 +30,7 @@ namespace MWMechanics { CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state) - : mPtr(ptr), mAnimation(anim), mState(state) + : mPtr(ptr), mAnimation(anim), mState(state), mSkipAnim(false) { if(mAnimation) mAnimNames = mAnimation->getAnimationNames(); @@ -56,7 +56,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim CharacterController::CharacterController(const CharacterController &rhs) : mPtr(rhs.mPtr), mAnimation(rhs.mAnimation), mAnimNames(rhs.mAnimNames) - , mState(rhs.mState) + , mState(rhs.mState), mSkipAnim(rhs.mSkipAnim) { if(mAnimNames.size() == 0) return; @@ -77,8 +77,9 @@ void CharacterController::markerEvent(const std::string &evt) Ogre::Vector3 CharacterController::update(float duration) { - if(mAnimation) + if(mAnimation && !mSkipAnim) mAnimation->runAnimation(duration); + mSkipAnim = false; return MWWorld::Class::get(mPtr).getMovementVector(mPtr); } @@ -92,8 +93,7 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int void CharacterController::skipAnim() { - if(mAnimation) - mAnimation->skipAnim(); + mSkipAnim = true; } diff --git a/apps/openmw/mwmechanics/character.hpp b/apps/openmw/mwmechanics/character.hpp index c29c39acdf..202e105784 100644 --- a/apps/openmw/mwmechanics/character.hpp +++ b/apps/openmw/mwmechanics/character.hpp @@ -25,6 +25,7 @@ class CharacterController std::string mCurrentGroup; CharacterState mState; + bool mSkipAnim; protected: /* Called by the animation whenever a new text key is reached. */ diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 1d628aefaa..c0b6a6e1cc 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -24,7 +24,6 @@ Animation::Animation(const MWWorld::Ptr &ptr) , mStartPosition(0.0f) , mLastPosition(0.0f) , mTime(0.0f) - , mSkipFrame(false) { } @@ -246,17 +245,8 @@ void Animation::playGroup(std::string groupname, int mode, int loops) } } -void Animation::skipAnim() -{ - mSkipFrame = true; -} - void Animation::runAnimation(float timepassed) { - if(mSkipFrame) - timepassed = 0.0f; - mSkipFrame = false; - while(mCurGroup.mAnimState && timepassed > 0.0f) { float targetTime = mTime + timepassed; diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 3afe32a4b2..5dbe7b510a 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -48,8 +48,6 @@ protected: GroupTimes mCurGroup; GroupTimes mNextGroup; - bool mSkipFrame; - /* Updates the animation to the specified time, and moves the mPtr object * based on the change since the last update or reset. */ void updatePosition(float time); @@ -69,7 +67,6 @@ public: std::vector getAnimationNames(); void playGroup(std::string groupname, int mode, int loops); - void skipAnim(); virtual void runAnimation(float timepassed); };