mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 11:23:51 +00:00
Specify the loop count to Animation::play
This commit is contained in:
parent
7241267d5c
commit
c58dfbe921
4 changed files with 23 additions and 18 deletions
|
@ -123,7 +123,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
||||||
mAnimation->setAccumulation(Ogre::Vector3(0.0f));
|
mAnimation->setAccumulation(Ogre::Vector3(0.0f));
|
||||||
}
|
}
|
||||||
if(mAnimation->hasAnimation(mCurrentGroup))
|
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)
|
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])
|
if(mAnimQueue.size() >= 2 && mAnimQueue[0] == mAnimQueue[1])
|
||||||
{
|
{
|
||||||
mAnimQueue.pop_front();
|
mAnimQueue.pop_front();
|
||||||
mAnimation->play(mCurrentGroup, "loop start", "stop", false);
|
mAnimation->play(mCurrentGroup, "loop start", "stop", 0);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ void CharacterController::markerEvent(float time, const std::string &evt)
|
||||||
if(mAnimQueue.size() >= 2 && mAnimQueue[0] == mAnimQueue[1])
|
if(mAnimQueue.size() >= 2 && mAnimQueue[0] == mAnimQueue[1])
|
||||||
{
|
{
|
||||||
mAnimQueue.pop_front();
|
mAnimQueue.pop_front();
|
||||||
mAnimation->play(mCurrentGroup, "loop start", "stop", false);
|
mAnimation->play(mCurrentGroup, "loop start", "stop", 0);
|
||||||
}
|
}
|
||||||
else if(mAnimQueue.size() > 0)
|
else if(mAnimQueue.size() > 0)
|
||||||
{
|
{
|
||||||
|
@ -172,7 +172,7 @@ void CharacterController::markerEvent(float time, const std::string &evt)
|
||||||
if(mAnimQueue.size() > 0)
|
if(mAnimQueue.size() > 0)
|
||||||
{
|
{
|
||||||
mCurrentGroup = mAnimQueue.front();
|
mCurrentGroup = mAnimQueue.front();
|
||||||
mAnimation->play(mCurrentGroup, "start", "stop", false);
|
mAnimation->play(mCurrentGroup, "start", "stop", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -284,7 +284,7 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int
|
||||||
mAnimQueue.push_back(groupname);
|
mAnimQueue.push_back(groupname);
|
||||||
mCurrentGroup = groupname;
|
mCurrentGroup = groupname;
|
||||||
mState = CharState_SpecialIdle;
|
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)
|
else if(mode == 0)
|
||||||
{
|
{
|
||||||
|
@ -316,7 +316,7 @@ void CharacterController::setState(CharacterState state, bool loop)
|
||||||
if(mAnimation->hasAnimation(anim))
|
if(mAnimation->hasAnimation(anim))
|
||||||
{
|
{
|
||||||
mCurrentGroup = 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)
|
, mTextKeys(NULL)
|
||||||
, mTime(0.0f)
|
, mTime(0.0f)
|
||||||
, mPlaying(false)
|
, mPlaying(false)
|
||||||
, mLooping(false)
|
, mLoopCount(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,14 +449,20 @@ bool Animation::reset(size_t layeridx, const NifOgre::TextKeyMap &keys, NifOgre:
|
||||||
return true;
|
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].mTime = mLayer[layeridx].mLoopStartKey->first;
|
||||||
mLayer[layeridx].mNextKey = mLayer[layeridx].mLoopStartKey;
|
mLayer[layeridx].mNextKey = mLayer[layeridx].mLoopStartKey;
|
||||||
mLayer[layeridx].mNextKey++;
|
mLayer[layeridx].mNextKey++;
|
||||||
mLayer[layeridx].mPlaying = true;
|
mLayer[layeridx].mPlaying = true;
|
||||||
if(layeridx == 0 && mNonAccumCtrl)
|
if(layeridx == 0 && mNonAccumCtrl)
|
||||||
mLastPosition = mNonAccumCtrl->getTranslation(mLayer[layeridx].mTime) * mAccumulate;
|
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(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)
|
if(mLayer[layeridx].mTime >= time)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
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
|
// TODO: parameterize this
|
||||||
size_t layeridx = 0;
|
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].mGroupName.clear();
|
||||||
mLayer[layeridx].mTextKeys = NULL;
|
mLayer[layeridx].mTextKeys = NULL;
|
||||||
mLayer[layeridx].mControllers = NULL;
|
mLayer[layeridx].mControllers = NULL;
|
||||||
mLayer[layeridx].mLooping = false;
|
mLayer[layeridx].mLoopCount = 0;
|
||||||
mLayer[layeridx].mPlaying = false;
|
mLayer[layeridx].mPlaying = false;
|
||||||
|
|
||||||
foundanim = true;
|
foundanim = true;
|
||||||
|
@ -562,7 +567,7 @@ void Animation::play(const std::string &groupname, const std::string &start, con
|
||||||
mLayer[layeridx].mGroupName = groupname;
|
mLayer[layeridx].mGroupName = groupname;
|
||||||
mLayer[layeridx].mTextKeys = &keys;
|
mLayer[layeridx].mTextKeys = &keys;
|
||||||
mLayer[layeridx].mControllers = &objlist.mControllers;
|
mLayer[layeridx].mControllers = &objlist.mControllers;
|
||||||
mLayer[layeridx].mLooping = loop;
|
mLayer[layeridx].mLoopCount = loops;
|
||||||
mLayer[layeridx].mPlaying = true;
|
mLayer[layeridx].mPlaying = true;
|
||||||
|
|
||||||
if(layeridx == 0)
|
if(layeridx == 0)
|
||||||
|
|
|
@ -55,7 +55,7 @@ protected:
|
||||||
float mTime;
|
float mTime;
|
||||||
|
|
||||||
bool mPlaying;
|
bool mPlaying;
|
||||||
bool mLooping;
|
size_t mLoopCount;
|
||||||
|
|
||||||
AnimLayer();
|
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);
|
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);
|
bool handleTextKey(size_t layeridx, const NifOgre::TextKeyMap::const_iterator &key);
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ public:
|
||||||
|
|
||||||
void setSpeed(float speed);
|
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);
|
virtual Ogre::Vector3 runAnimation(float timepassed);
|
||||||
|
|
||||||
Ogre::Node *getNode(const std::string &name);
|
Ogre::Node *getNode(const std::string &name);
|
||||||
|
|
|
@ -155,7 +155,7 @@ namespace MWRender
|
||||||
if (!mSelectionBuffer)
|
if (!mSelectionBuffer)
|
||||||
mSelectionBuffer = new OEngine::Render::SelectionBuffer(mCamera, 512, 1024, 0);
|
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 ()
|
void RaceSelectionPreview::onSetup ()
|
||||||
{
|
{
|
||||||
mAnimation->play("idle", "start", "stop", false);
|
mAnimation->play("idle", "start", "stop", 0);
|
||||||
|
|
||||||
updateCamera();
|
updateCamera();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue