mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Store the AnimSource in the animation state
This commit is contained in:
parent
58efce5008
commit
8a9b0eb5f7
@ -55,7 +55,6 @@ Animation::Animation(const MWWorld::Ptr &ptr)
|
||||
, mAnimVelocity(0.0f)
|
||||
, mAnimSpeedMult(1.0f)
|
||||
{
|
||||
mSource = NULL;
|
||||
mAnimationValuePtr.bind(OGRE_NEW AnimationValue(this));
|
||||
}
|
||||
|
||||
@ -196,7 +195,6 @@ void Animation::clearAnimSources()
|
||||
{
|
||||
mStates.clear();
|
||||
|
||||
mSource = NULL;
|
||||
mAnimationName.empty();
|
||||
|
||||
mNonAccumCtrl = NULL;
|
||||
@ -506,12 +504,12 @@ bool Animation::play(const std::string &groupname, const std::string &start, con
|
||||
continue;
|
||||
foundanim = true;
|
||||
|
||||
state.mSource = &*iter;
|
||||
state.mLoopCount = loops;
|
||||
state.mPlaying = true;
|
||||
mStates[groupname] = state;
|
||||
|
||||
// FIXME
|
||||
mSource = &*iter;
|
||||
mAnimationName = groupname;
|
||||
|
||||
mNonAccumCtrl = nonaccumctrl;
|
||||
@ -592,10 +590,11 @@ Ogre::Vector3 Animation::runAnimation(float duration)
|
||||
|
||||
for(size_t i = 0;i < mObjectRoot.mControllers.size();i++)
|
||||
mObjectRoot.mControllers[i].update();
|
||||
if(mSource)
|
||||
if(!mAnimationName.empty() && (stateiter=mStates.find(mAnimationName)) != mStates.end())
|
||||
{
|
||||
for(size_t i = 0;i < mSource->mControllers.size();i++)
|
||||
mSource->mControllers[i].update();
|
||||
AnimSource *src = stateiter->second.mSource;
|
||||
for(size_t i = 0;i < src->mControllers.size();i++)
|
||||
src->mControllers[i].update();
|
||||
}
|
||||
|
||||
if(mSkelBase)
|
||||
|
@ -36,6 +36,7 @@ protected:
|
||||
typedef std::vector<AnimSource> AnimSourceList;
|
||||
|
||||
struct AnimState {
|
||||
AnimSource *mSource;
|
||||
NifOgre::TextKeyMap::const_iterator mStartKey;
|
||||
NifOgre::TextKeyMap::const_iterator mLoopStartKey;
|
||||
NifOgre::TextKeyMap::const_iterator mStopKey;
|
||||
@ -46,7 +47,7 @@ protected:
|
||||
bool mPlaying;
|
||||
size_t mLoopCount;
|
||||
|
||||
AnimState() : mTime(0.0f), mPlaying(false), mLoopCount(0)
|
||||
AnimState() : mSource(NULL), mTime(0.0f), mPlaying(false), mLoopCount(0)
|
||||
{ }
|
||||
};
|
||||
typedef std::map<std::string,AnimState> AnimStateMap;
|
||||
@ -69,7 +70,6 @@ protected:
|
||||
AnimStateMap mStates;
|
||||
|
||||
// Note: One per animation group (lower body, upper body, left arm, etc).
|
||||
AnimSource *mSource;
|
||||
std::string mAnimationName;
|
||||
Ogre::SharedPtr<AnimationValue> mAnimationValuePtr;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user