forked from teamnwah/openmw-tes3coop
The animation state tracks the animation time for us
This commit is contained in:
parent
7cce44290e
commit
fc0f9e2159
2 changed files with 11 additions and 18 deletions
|
@ -25,7 +25,6 @@ Animation::Animation(const MWWorld::Ptr &ptr)
|
|||
, mLastPosition(0.0f)
|
||||
, mCurrentKeys(NULL)
|
||||
, mAnimState(NULL)
|
||||
, mTime(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -121,10 +120,7 @@ void Animation::setController(MWMechanics::CharacterController *controller)
|
|||
|
||||
void Animation::updatePosition(float time)
|
||||
{
|
||||
if(time == mTime)
|
||||
return;
|
||||
mAnimState->setTimePosition(time);
|
||||
mTime = time;
|
||||
|
||||
if(mNonAccumRoot)
|
||||
{
|
||||
|
@ -152,7 +148,6 @@ void Animation::updatePosition(float time)
|
|||
void Animation::resetPosition(float time)
|
||||
{
|
||||
mAnimState->setTimePosition(time);
|
||||
mTime = time;
|
||||
|
||||
mNextKey = mCurrentKeys->begin();
|
||||
while(mNextKey != mCurrentKeys->end() && mNextKey->first < time)
|
||||
|
@ -216,21 +211,20 @@ void Animation::runAnimation(float timepassed)
|
|||
{
|
||||
while(mAnimState && timepassed > 0.0f)
|
||||
{
|
||||
float targetTime = mTime + timepassed;
|
||||
if(mNextKey != mCurrentKeys->end() && mNextKey->first <= targetTime)
|
||||
float targetTime = mAnimState->getTimePosition() + timepassed;
|
||||
if(mNextKey == mCurrentKeys->end() || mNextKey->first > targetTime)
|
||||
{
|
||||
const std::string &evt = mNextKey->second;
|
||||
updatePosition(mNextKey->first);
|
||||
mNextKey++;
|
||||
timepassed = targetTime - mTime;
|
||||
|
||||
if(mController)
|
||||
mController->markerEvent(evt);
|
||||
continue;
|
||||
updatePosition(targetTime);
|
||||
break;
|
||||
}
|
||||
|
||||
updatePosition(targetTime);
|
||||
timepassed = targetTime - mTime;
|
||||
const std::string &evt = mNextKey->second;
|
||||
updatePosition(mNextKey->first);
|
||||
timepassed = targetTime - mNextKey->first;
|
||||
mNextKey++;
|
||||
|
||||
if(mController)
|
||||
mController->markerEvent(evt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ protected:
|
|||
NifOgre::TextKeyMap *mCurrentKeys;
|
||||
NifOgre::TextKeyMap::const_iterator mNextKey;
|
||||
Ogre::AnimationState *mAnimState;
|
||||
float mTime;
|
||||
|
||||
/* Updates the animation to the specified time, and moves the mPtr object
|
||||
* based on the change since the last update or reset. */
|
||||
|
|
Loading…
Reference in a new issue