mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 10:53:54 +00:00
Handle animation skipping in the character controller
This commit is contained in:
parent
852aa214cc
commit
7ee389f3b2
4 changed files with 6 additions and 18 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<std::string> getAnimationNames();
|
||||
|
||||
void playGroup(std::string groupname, int mode, int loops);
|
||||
void skipAnim();
|
||||
virtual void runAnimation(float timepassed);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue