1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 12:53:51 +00:00

Don't use the character controller to handle text keys

The Animation class has the Ptr and can call to whatever subsystem is needed.
This commit is contained in:
Chris Robinson 2013-04-24 06:48:34 -07:00
parent e8cabc9434
commit b80891099e
3 changed files with 16 additions and 44 deletions

View file

@ -148,27 +148,6 @@ void CharacterController::updatePtr(const MWWorld::Ptr &ptr)
} }
void CharacterController::markerEvent(float time, const std::string &evt)
{
if(evt == "stop")
{
if(mAnimQueue.size() > 0)
{
mAnimQueue.pop_front();
if(mAnimQueue.size() > 0)
{
mCurrentGroup = mAnimQueue.front().first;
size_t count = mAnimQueue.front().second;
mAnimation->play(mCurrentGroup, "start", "stop", count);
}
}
return;
}
std::cerr<< "Unhandled animation event: "<<evt <<std::endl;
}
void CharacterController::update(float duration, Movement &movement) void CharacterController::update(float duration, Movement &movement)
{ {
float speed = 0.0f; float speed = 0.0f;
@ -237,7 +216,17 @@ void CharacterController::update(float duration, Movement &movement)
setState(CharState_TurnLeft, true); setState(CharState_TurnLeft, true);
} }
else if(getState() != CharState_SpecialIdle || !mAnimation->isPlaying(0)) else if(getState() != CharState_SpecialIdle || !mAnimation->isPlaying(0))
setState((inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle)), true); {
if(mAnimQueue.size() > 0)
{
mCurrentGroup = mAnimQueue.front().first;
size_t count = mAnimQueue.front().second;
mAnimQueue.pop_front();
mAnimation->play(mCurrentGroup, "start", "stop", count);
}
else
setState((inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle)), true);
}
movement.mRotation[0] += rot.x * duration; movement.mRotation[0] += rot.x * duration;
movement.mRotation[1] += rot.y * duration; movement.mRotation[1] += rot.y * duration;
@ -263,17 +252,16 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int
else else
{ {
count = std::max(count, 1); count = std::max(count, 1);
if(mode != 0 || mAnimQueue.size() == 0) if(mode != 0 || getState() != CharState_SpecialIdle)
{ {
mAnimQueue.clear(); mAnimQueue.clear();
mAnimQueue.push_back(std::make_pair(groupname, count-1));
mCurrentGroup = groupname; mCurrentGroup = groupname;
mState = CharState_SpecialIdle; mState = CharState_SpecialIdle;
mAnimation->play(mCurrentGroup, ((mode==2) ? "loop start" : "start"), "stop", count-1); mAnimation->play(mCurrentGroup, ((mode==2) ? "loop start" : "start"), "stop", count-1);
} }
else if(mode == 0) else if(mode == 0)
{ {
mAnimQueue.resize(1); mAnimQueue.clear();
mAnimQueue.push_back(std::make_pair(groupname, count-1)); mAnimQueue.push_back(std::make_pair(groupname, count-1));
} }
} }

View file

@ -79,12 +79,6 @@ class CharacterController
CharacterState mState; CharacterState mState;
bool mSkipAnim; bool mSkipAnim;
protected:
/* Called by the animation whenever a new text key is reached. */
void markerEvent(float time, const std::string &evt);
friend class MWRender::Animation;
public: public:
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state, bool loop); CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state, bool loop);
CharacterController(const CharacterController &rhs); CharacterController(const CharacterController &rhs);

View file

@ -499,7 +499,7 @@ bool Animation::handleTextKey(size_t layeridx, const NifOgre::TextKeyMap::const_
return true; return true;
} }
if(evt.compare(off, len, "loop stop") == 0) if(evt.compare(off, len, "loop stop") == 0 || evt.compare(off, len, "stop") == 0)
{ {
if(doLoop(layeridx)) if(doLoop(layeridx))
{ {
@ -508,18 +508,8 @@ bool Animation::handleTextKey(size_t layeridx, const NifOgre::TextKeyMap::const_
} }
return true; return true;
} }
if(evt.compare(off, len, "stop") == 0)
{ std::cerr<< "Unhandled animation textkey: "<<evt <<std::endl;
if(doLoop(layeridx))
{
if(mLayer[layeridx].mTime >= time)
return false;
return true;
}
// fall-through
}
if(mController)
mController->markerEvent(time, evt.substr(off));
return true; return true;
} }