forked from mirror/openmw-tes3mp
Return the movement vector from runAnimation
This commit is contained in:
parent
9235fba770
commit
9123f4f2af
8 changed files with 16 additions and 31 deletions
|
@ -54,11 +54,4 @@ ActivatorAnimation::ActivatorAnimation(const MWWorld::Ptr &ptr)
|
|||
}
|
||||
}
|
||||
|
||||
void ActivatorAnimation::runAnimation(float timepassed)
|
||||
{
|
||||
// Placeholder
|
||||
|
||||
Animation::runAnimation(timepassed);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ namespace MWRender
|
|||
public:
|
||||
ActivatorAnimation(const MWWorld::Ptr& ptr);
|
||||
virtual ~ActivatorAnimation();
|
||||
|
||||
virtual void runAnimation(float timepassed);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -125,16 +125,17 @@ void Animation::setAccumulation(const Ogre::Vector3 &accum)
|
|||
}
|
||||
|
||||
|
||||
void Animation::updatePosition(float time)
|
||||
Ogre::Vector3 Animation::updatePosition(float time)
|
||||
{
|
||||
mAnimState->setTimePosition(time);
|
||||
|
||||
Ogre::Vector3 posdiff = Ogre::Vector3::ZERO;
|
||||
if(mNonAccumRoot)
|
||||
{
|
||||
/* Update the animation and get the non-accumulation root's difference from the
|
||||
* last update. */
|
||||
mEntityList.mSkelBase->getSkeleton()->setAnimationState(*mAnimState->getParent());
|
||||
Ogre::Vector3 posdiff = (mNonAccumRoot->getPosition() - mLastPosition) * mAccumulate;
|
||||
posdiff = (mNonAccumRoot->getPosition() - mLastPosition) * mAccumulate;
|
||||
|
||||
/* Translate the accumulation root back to compensate for the move. */
|
||||
mAccumRoot->translate(-posdiff);
|
||||
|
@ -150,6 +151,7 @@ void Animation::updatePosition(float time)
|
|||
world->moveObject(mPtr, newpos.x, newpos.y, newpos.z);
|
||||
}
|
||||
}
|
||||
return posdiff;
|
||||
}
|
||||
|
||||
void Animation::resetPosition(float time)
|
||||
|
@ -212,14 +214,15 @@ void Animation::play(const std::string &groupname, const std::string &start)
|
|||
}
|
||||
}
|
||||
|
||||
void Animation::runAnimation(float timepassed)
|
||||
Ogre::Vector3 Animation::runAnimation(float timepassed)
|
||||
{
|
||||
Ogre::Vector3 movement = Ogre::Vector3::ZERO;
|
||||
while(mAnimState && timepassed > 0.0f)
|
||||
{
|
||||
float targetTime = mAnimState->getTimePosition() + timepassed;
|
||||
if(mNextKey == mCurrentKeys->end() || mNextKey->first > targetTime)
|
||||
{
|
||||
updatePosition(targetTime);
|
||||
movement += updatePosition(targetTime);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -227,12 +230,13 @@ void Animation::runAnimation(float timepassed)
|
|||
const std::string &evt = mNextKey->second;
|
||||
mNextKey++;
|
||||
|
||||
updatePosition(time);
|
||||
movement += updatePosition(time);
|
||||
timepassed = targetTime - time;
|
||||
|
||||
if(mController)
|
||||
mController->markerEvent(time, evt);
|
||||
}
|
||||
return movement;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ protected:
|
|||
|
||||
/* 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);
|
||||
Ogre::Vector3 updatePosition(float time);
|
||||
/* Updates the animation to the specified time, without moving the mPtr
|
||||
* object. */
|
||||
void resetPosition(float time);
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
void setAccumulation(const Ogre::Vector3 &accum);
|
||||
|
||||
void play(const std::string &groupname, const std::string &start);
|
||||
virtual void runAnimation(float timepassed);
|
||||
virtual Ogre::Vector3 runAnimation(float timepassed);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -8,9 +8,8 @@
|
|||
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
using namespace Ogre;
|
||||
using namespace NifOgre;
|
||||
namespace MWRender{
|
||||
namespace MWRender
|
||||
{
|
||||
|
||||
CreatureAnimation::~CreatureAnimation()
|
||||
{
|
||||
|
@ -55,11 +54,4 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr)
|
|||
}
|
||||
}
|
||||
|
||||
void CreatureAnimation::runAnimation(float timepassed)
|
||||
{
|
||||
// Placeholder
|
||||
|
||||
Animation::runAnimation(timepassed);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ namespace MWRender
|
|||
public:
|
||||
CreatureAnimation(const MWWorld::Ptr& ptr);
|
||||
virtual ~CreatureAnimation();
|
||||
|
||||
virtual void runAnimation(float timepassed);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -308,7 +308,7 @@ NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, int
|
|||
return entities;
|
||||
}
|
||||
|
||||
void NpcAnimation::runAnimation(float timepassed)
|
||||
Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
|
||||
{
|
||||
if(mTimeToChange > .2)
|
||||
{
|
||||
|
@ -317,7 +317,7 @@ void NpcAnimation::runAnimation(float timepassed)
|
|||
}
|
||||
mTimeToChange += timepassed;
|
||||
|
||||
Animation::runAnimation(timepassed);
|
||||
return Animation::runAnimation(timepassed);
|
||||
}
|
||||
|
||||
void NpcAnimation::removeEntities(NifOgre::EntityList &entities)
|
||||
|
|
|
@ -98,7 +98,7 @@ public:
|
|||
MWWorld::InventoryStore& inv, int visibilityFlags);
|
||||
virtual ~NpcAnimation();
|
||||
|
||||
virtual void runAnimation(float timepassed);
|
||||
virtual Ogre::Vector3 runAnimation(float timepassed);
|
||||
|
||||
void forceUpdate();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue