mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 00:36:46 +00:00
Combine animation handling into the base class
This commit is contained in:
parent
fcaa8aae06
commit
81ce8dbe12
4 changed files with 33 additions and 48 deletions
|
@ -42,4 +42,33 @@ void Animation::skipAnim()
|
||||||
mAnimate = 0;
|
mAnimate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Animation::runAnimation(float timepassed)
|
||||||
|
{
|
||||||
|
if(mAnimate != 0)
|
||||||
|
{
|
||||||
|
mTime += timepassed;
|
||||||
|
|
||||||
|
if(mEntityList.mSkelBase)
|
||||||
|
{
|
||||||
|
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
||||||
|
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
||||||
|
while(as.hasMoreElements())
|
||||||
|
{
|
||||||
|
Ogre::AnimationState *state = as.getNext();
|
||||||
|
state->setTimePosition(mTime);
|
||||||
|
if(mTime >= state->getLength())
|
||||||
|
{
|
||||||
|
if(mAnimate != -1)
|
||||||
|
mAnimate--;
|
||||||
|
//std::cout << "Stopping the animation\n";
|
||||||
|
if(mAnimate == 0)
|
||||||
|
mTime = state->getLength();
|
||||||
|
else
|
||||||
|
mTime = mTime - state->getLength();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
|
|
||||||
void playGroup(std::string groupname, int mode, int loops);
|
void playGroup(std::string groupname, int mode, int loops);
|
||||||
void skipAnim();
|
void skipAnim();
|
||||||
virtual void runAnimation(float timepassed) = 0;
|
virtual void runAnimation(float timepassed);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,30 +69,9 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::O
|
||||||
|
|
||||||
void CreatureAnimation::runAnimation(float timepassed)
|
void CreatureAnimation::runAnimation(float timepassed)
|
||||||
{
|
{
|
||||||
if(mAnimate > 0)
|
// Placeholder
|
||||||
{
|
|
||||||
mTime += timepassed;
|
|
||||||
|
|
||||||
if(mEntityList.mSkelBase)
|
Animation::runAnimation(timepassed);
|
||||||
{
|
|
||||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
|
||||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
|
||||||
while(as.hasMoreElements())
|
|
||||||
{
|
|
||||||
Ogre::AnimationState *state = as.getNext();
|
|
||||||
state->setTimePosition(mTime);
|
|
||||||
if(state->getTimePosition() >= state->getLength())
|
|
||||||
{
|
|
||||||
mAnimate--;
|
|
||||||
//std::cout << "Stopping the animation\n";
|
|
||||||
if(mAnimate == 0)
|
|
||||||
mTime = state->getLength();
|
|
||||||
else
|
|
||||||
mTime = mTime - state->getLength();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,30 +373,7 @@ void NpcAnimation::runAnimation(float timepassed)
|
||||||
}
|
}
|
||||||
timeToChange += timepassed;
|
timeToChange += timepassed;
|
||||||
|
|
||||||
if(mAnimate > 0)
|
Animation::runAnimation(timepassed);
|
||||||
{
|
|
||||||
mTime += timepassed;
|
|
||||||
|
|
||||||
if(mEntityList.mSkelBase)
|
|
||||||
{
|
|
||||||
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
|
|
||||||
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
|
|
||||||
while(as.hasMoreElements())
|
|
||||||
{
|
|
||||||
Ogre::AnimationState *state = as.getNext();
|
|
||||||
state->setTimePosition(mTime);
|
|
||||||
if(state->getTimePosition() >= state->getLength())
|
|
||||||
{
|
|
||||||
mAnimate--;
|
|
||||||
//std::cout << "Stopping the animation\n";
|
|
||||||
if(mAnimate == 0)
|
|
||||||
mTime = state->getLength();
|
|
||||||
else
|
|
||||||
mTime = mTime - state->getLength();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
|
void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
|
||||||
|
|
Loading…
Reference in a new issue