mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 10:53:54 +00:00
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)
|
, mLastPosition(0.0f)
|
||||||
, mCurrentKeys(NULL)
|
, mCurrentKeys(NULL)
|
||||||
, mAnimState(NULL)
|
, mAnimState(NULL)
|
||||||
, mTime(0.0f)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,10 +120,7 @@ void Animation::setController(MWMechanics::CharacterController *controller)
|
||||||
|
|
||||||
void Animation::updatePosition(float time)
|
void Animation::updatePosition(float time)
|
||||||
{
|
{
|
||||||
if(time == mTime)
|
|
||||||
return;
|
|
||||||
mAnimState->setTimePosition(time);
|
mAnimState->setTimePosition(time);
|
||||||
mTime = time;
|
|
||||||
|
|
||||||
if(mNonAccumRoot)
|
if(mNonAccumRoot)
|
||||||
{
|
{
|
||||||
|
@ -152,7 +148,6 @@ void Animation::updatePosition(float time)
|
||||||
void Animation::resetPosition(float time)
|
void Animation::resetPosition(float time)
|
||||||
{
|
{
|
||||||
mAnimState->setTimePosition(time);
|
mAnimState->setTimePosition(time);
|
||||||
mTime = time;
|
|
||||||
|
|
||||||
mNextKey = mCurrentKeys->begin();
|
mNextKey = mCurrentKeys->begin();
|
||||||
while(mNextKey != mCurrentKeys->end() && mNextKey->first < time)
|
while(mNextKey != mCurrentKeys->end() && mNextKey->first < time)
|
||||||
|
@ -216,21 +211,20 @@ void Animation::runAnimation(float timepassed)
|
||||||
{
|
{
|
||||||
while(mAnimState && timepassed > 0.0f)
|
while(mAnimState && timepassed > 0.0f)
|
||||||
{
|
{
|
||||||
float targetTime = mTime + timepassed;
|
float targetTime = mAnimState->getTimePosition() + timepassed;
|
||||||
if(mNextKey != mCurrentKeys->end() && mNextKey->first <= targetTime)
|
if(mNextKey == mCurrentKeys->end() || mNextKey->first > targetTime)
|
||||||
{
|
{
|
||||||
const std::string &evt = mNextKey->second;
|
updatePosition(targetTime);
|
||||||
updatePosition(mNextKey->first);
|
break;
|
||||||
mNextKey++;
|
|
||||||
timepassed = targetTime - mTime;
|
|
||||||
|
|
||||||
if(mController)
|
|
||||||
mController->markerEvent(evt);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePosition(targetTime);
|
const std::string &evt = mNextKey->second;
|
||||||
timepassed = targetTime - mTime;
|
updatePosition(mNextKey->first);
|
||||||
|
timepassed = targetTime - mNextKey->first;
|
||||||
|
mNextKey++;
|
||||||
|
|
||||||
|
if(mController)
|
||||||
|
mController->markerEvent(evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ protected:
|
||||||
NifOgre::TextKeyMap *mCurrentKeys;
|
NifOgre::TextKeyMap *mCurrentKeys;
|
||||||
NifOgre::TextKeyMap::const_iterator mNextKey;
|
NifOgre::TextKeyMap::const_iterator mNextKey;
|
||||||
Ogre::AnimationState *mAnimState;
|
Ogre::AnimationState *mAnimState;
|
||||||
float mTime;
|
|
||||||
|
|
||||||
/* Updates the animation to the specified time, and moves the mPtr object
|
/* Updates the animation to the specified time, and moves the mPtr object
|
||||||
* based on the change since the last update or reset. */
|
* based on the change since the last update or reset. */
|
||||||
|
|
Loading…
Reference in a new issue