Specify the loop count to Animation::play

actorid
Chris Robinson 12 years ago
parent 7241267d5c
commit c58dfbe921

@ -123,7 +123,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
mAnimation->setAccumulation(Ogre::Vector3(0.0f));
}
if(mAnimation->hasAnimation(mCurrentGroup))
mAnimation->play(mCurrentGroup, "start", "stop", loop);
mAnimation->play(mCurrentGroup, "start", "stop", loop ? (~(size_t)0) : 0);
}
CharacterController::CharacterController(const CharacterController &rhs)
@ -155,7 +155,7 @@ void CharacterController::markerEvent(float time, const std::string &evt)
if(mAnimQueue.size() >= 2 && mAnimQueue[0] == mAnimQueue[1])
{
mAnimQueue.pop_front();
mAnimation->play(mCurrentGroup, "loop start", "stop", false);
mAnimation->play(mCurrentGroup, "loop start", "stop", 0);
}
return;
}
@ -164,7 +164,7 @@ void CharacterController::markerEvent(float time, const std::string &evt)
if(mAnimQueue.size() >= 2 && mAnimQueue[0] == mAnimQueue[1])
{
mAnimQueue.pop_front();
mAnimation->play(mCurrentGroup, "loop start", "stop", false);
mAnimation->play(mCurrentGroup, "loop start", "stop", 0);
}
else if(mAnimQueue.size() > 0)
{
@ -172,7 +172,7 @@ void CharacterController::markerEvent(float time, const std::string &evt)
if(mAnimQueue.size() > 0)
{
mCurrentGroup = mAnimQueue.front();
mAnimation->play(mCurrentGroup, "start", "stop", false);
mAnimation->play(mCurrentGroup, "start", "stop", 0);
}
}
return;
@ -284,7 +284,7 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int
mAnimQueue.push_back(groupname);
mCurrentGroup = groupname;
mState = CharState_SpecialIdle;
mAnimation->play(mCurrentGroup, ((mode==2) ? "loop start" : "start"), "stop", false);
mAnimation->play(mCurrentGroup, ((mode==2) ? "loop start" : "start"), "stop", 0);
}
else if(mode == 0)
{
@ -316,7 +316,7 @@ void CharacterController::setState(CharacterState state, bool loop)
if(mAnimation->hasAnimation(anim))
{
mCurrentGroup = anim;
mAnimation->play(mCurrentGroup, "start", "stop", loop);
mAnimation->play(mCurrentGroup, "start", "stop", loop ? (~(size_t)0) : 0);
}
}

@ -23,7 +23,7 @@ Animation::AnimLayer::AnimLayer()
, mTextKeys(NULL)
, mTime(0.0f)
, mPlaying(false)
, mLooping(false)
, mLoopCount(0)
{
}
@ -449,14 +449,20 @@ bool Animation::reset(size_t layeridx, const NifOgre::TextKeyMap &keys, NifOgre:
return true;
}
void Animation::doLoop(size_t layeridx)
bool Animation::doLoop(size_t layeridx)
{
if(mLayer[layeridx].mLoopCount == 0)
return false;
mLayer[layeridx].mLoopCount--;
mLayer[layeridx].mTime = mLayer[layeridx].mLoopStartKey->first;
mLayer[layeridx].mNextKey = mLayer[layeridx].mLoopStartKey;
mLayer[layeridx].mNextKey++;
mLayer[layeridx].mPlaying = true;
if(layeridx == 0 && mNonAccumCtrl)
mLastPosition = mNonAccumCtrl->getTranslation(mLayer[layeridx].mTime) * mAccumulate;
return true;
}
@ -495,9 +501,8 @@ bool Animation::handleTextKey(size_t layeridx, const NifOgre::TextKeyMap::const_
if(evt.compare(off, len, "loop stop") == 0 || evt.compare(off, len, "stop") == 0)
{
if(mLayer[layeridx].mLooping)
if(doLoop(layeridx))
{
doLoop(layeridx);
if(mLayer[layeridx].mTime >= time)
return false;
return true;
@ -510,7 +515,7 @@ bool Animation::handleTextKey(size_t layeridx, const NifOgre::TextKeyMap::const_
}
void Animation::play(const std::string &groupname, const std::string &start, const std::string &stop, bool loop)
void Animation::play(const std::string &groupname, const std::string &start, const std::string &stop, size_t loops)
{
// TODO: parameterize this
size_t layeridx = 0;
@ -527,7 +532,7 @@ void Animation::play(const std::string &groupname, const std::string &start, con
mLayer[layeridx].mGroupName.clear();
mLayer[layeridx].mTextKeys = NULL;
mLayer[layeridx].mControllers = NULL;
mLayer[layeridx].mLooping = false;
mLayer[layeridx].mLoopCount = 0;
mLayer[layeridx].mPlaying = false;
foundanim = true;
@ -562,7 +567,7 @@ void Animation::play(const std::string &groupname, const std::string &start, con
mLayer[layeridx].mGroupName = groupname;
mLayer[layeridx].mTextKeys = &keys;
mLayer[layeridx].mControllers = &objlist.mControllers;
mLayer[layeridx].mLooping = loop;
mLayer[layeridx].mLoopCount = loops;
mLayer[layeridx].mPlaying = true;
if(layeridx == 0)

@ -55,7 +55,7 @@ protected:
float mTime;
bool mPlaying;
bool mLooping;
size_t mLoopCount;
AnimLayer();
};
@ -101,7 +101,7 @@ protected:
*/
bool reset(size_t layeridx, const NifOgre::TextKeyMap &keys, NifOgre::NodeTargetValue<Ogre::Real> *nonaccumctrl, const std::string &groupname, const std::string &start, const std::string &stop);
void doLoop(size_t layeridx);
bool doLoop(size_t layeridx);
bool handleTextKey(size_t layeridx, const NifOgre::TextKeyMap::const_iterator &key);
@ -129,7 +129,7 @@ public:
void setSpeed(float speed);
void play(const std::string &groupname, const std::string &start, const std::string &stop, bool loop);
void play(const std::string &groupname, const std::string &start, const std::string &stop, size_t loops);
virtual Ogre::Vector3 runAnimation(float timepassed);
Ogre::Node *getNode(const std::string &name);

@ -155,7 +155,7 @@ namespace MWRender
if (!mSelectionBuffer)
mSelectionBuffer = new OEngine::Render::SelectionBuffer(mCamera, 512, 1024, 0);
mAnimation->play("inventoryhandtohand", "start", "stop", false);
mAnimation->play("inventoryhandtohand", "start", "stop", 0);
}
// --------------------------------------------------------------------------------------------------
@ -189,7 +189,7 @@ namespace MWRender
void RaceSelectionPreview::onSetup ()
{
mAnimation->play("idle", "start", "stop", false);
mAnimation->play("idle", "start", "stop", 0);
updateCamera();
}

Loading…
Cancel
Save