mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 21:49:41 +00:00
Implement SwimTurnLeft/Right animations
This commit is contained in:
parent
1c6cfad3cc
commit
bcad431cc5
2 changed files with 20 additions and 7 deletions
|
@ -186,6 +186,8 @@ static const StateInfo sMovementList[] = {
|
||||||
|
|
||||||
{ CharState_TurnLeft, "turnleft" },
|
{ CharState_TurnLeft, "turnleft" },
|
||||||
{ CharState_TurnRight, "turnright" },
|
{ CharState_TurnRight, "turnright" },
|
||||||
|
{ CharState_SwimTurnLeft, "swimturnleft" },
|
||||||
|
{ CharState_SwimTurnRight, "swimturnright" },
|
||||||
};
|
};
|
||||||
static const StateInfo *sMovementListEnd = &sMovementList[sizeof(sMovementList)/sizeof(sMovementList[0])];
|
static const StateInfo *sMovementListEnd = &sMovementList[sizeof(sMovementList)/sizeof(sMovementList[0])];
|
||||||
|
|
||||||
|
@ -564,7 +566,7 @@ void CharacterController::refreshCurrentAnims(CharacterState idle, CharacterStat
|
||||||
// FIXME: if one of the below states is close to their last animation frame (i.e. will be disabled in the coming update),
|
// FIXME: if one of the below states is close to their last animation frame (i.e. will be disabled in the coming update),
|
||||||
// the idle animation should be displayed
|
// the idle animation should be displayed
|
||||||
if ((mUpperBodyState != UpperCharState_Nothing
|
if ((mUpperBodyState != UpperCharState_Nothing
|
||||||
|| (mMovementState != CharState_None && mMovementState != CharState_TurnLeft && mMovementState != CharState_TurnRight)
|
|| (mMovementState != CharState_None && !isTurning())
|
||||||
|| mHitState != CharState_None)
|
|| mHitState != CharState_None)
|
||||||
&& !mPtr.getClass().isBipedal(mPtr))
|
&& !mPtr.getClass().isBipedal(mPtr))
|
||||||
idle = CharState_None;
|
idle = CharState_None;
|
||||||
|
@ -1875,22 +1877,22 @@ void CharacterController::update(float duration)
|
||||||
else if(rot.z() != 0.0f && !inwater && !sneak && !(mPtr == getPlayer() && MWBase::Environment::get().getWorld()->isFirstPerson()))
|
else if(rot.z() != 0.0f && !inwater && !sneak && !(mPtr == getPlayer() && MWBase::Environment::get().getWorld()->isFirstPerson()))
|
||||||
{
|
{
|
||||||
if(rot.z() > 0.0f)
|
if(rot.z() > 0.0f)
|
||||||
movestate = CharState_TurnRight;
|
movestate = inwater ? CharState_SwimTurnRight : CharState_TurnRight;
|
||||||
else if(rot.z() < 0.0f)
|
else if(rot.z() < 0.0f)
|
||||||
movestate = CharState_TurnLeft;
|
movestate = inwater ? CharState_SwimTurnLeft : CharState_TurnLeft;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mTurnAnimationThreshold -= duration;
|
mTurnAnimationThreshold -= duration;
|
||||||
if (movestate == CharState_TurnRight || movestate == CharState_TurnLeft)
|
if (isTurning())
|
||||||
mTurnAnimationThreshold = 0.05f;
|
mTurnAnimationThreshold = 0.05f;
|
||||||
else if (movestate == CharState_None && (mMovementState == CharState_TurnRight || mMovementState == CharState_TurnLeft)
|
else if (movestate == CharState_None && isTurning()
|
||||||
&& mTurnAnimationThreshold > 0)
|
&& mTurnAnimationThreshold > 0)
|
||||||
{
|
{
|
||||||
movestate = mMovementState;
|
movestate = mMovementState;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(movestate != CharState_None && movestate != CharState_TurnLeft && movestate != CharState_TurnRight)
|
if(!isTurning())
|
||||||
clearAnimQueue();
|
clearAnimQueue();
|
||||||
|
|
||||||
if(mAnimQueue.empty() || inwater || sneak)
|
if(mAnimQueue.empty() || inwater || sneak)
|
||||||
|
@ -1915,7 +1917,7 @@ void CharacterController::update(float duration)
|
||||||
if (inJump)
|
if (inJump)
|
||||||
mMovementAnimationControlled = false;
|
mMovementAnimationControlled = false;
|
||||||
|
|
||||||
if (mMovementState == CharState_TurnLeft || mMovementState == CharState_TurnRight)
|
if (isTurning())
|
||||||
{
|
{
|
||||||
if (duration > 0)
|
if (duration > 0)
|
||||||
mAnimation->adjustSpeedMult(mCurrentMovement, std::min(1.5f, std::abs(rot.z()) / duration / static_cast<float>(osg::PI)));
|
mAnimation->adjustSpeedMult(mCurrentMovement, std::min(1.5f, std::abs(rot.z()) / duration / static_cast<float>(osg::PI)));
|
||||||
|
@ -2277,6 +2279,14 @@ bool CharacterController::isKnockedOut() const
|
||||||
mHitState == CharState_SwimKnockOut;
|
mHitState == CharState_SwimKnockOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CharacterController::isTurning() const
|
||||||
|
{
|
||||||
|
return mMovementState == CharState_TurnLeft ||
|
||||||
|
mMovementState == CharState_TurnRight ||
|
||||||
|
mMovementState == CharState_SwimTurnLeft ||
|
||||||
|
mMovementState == CharState_SwimTurnRight;
|
||||||
|
}
|
||||||
|
|
||||||
bool CharacterController::isRecovery() const
|
bool CharacterController::isRecovery() const
|
||||||
{
|
{
|
||||||
return mHitState == CharState_Hit ||
|
return mHitState == CharState_Hit ||
|
||||||
|
|
|
@ -88,6 +88,8 @@ enum CharacterState {
|
||||||
|
|
||||||
CharState_TurnLeft,
|
CharState_TurnLeft,
|
||||||
CharState_TurnRight,
|
CharState_TurnRight,
|
||||||
|
CharState_SwimTurnLeft,
|
||||||
|
CharState_SwimTurnRight,
|
||||||
|
|
||||||
CharState_Jump,
|
CharState_Jump,
|
||||||
|
|
||||||
|
@ -275,6 +277,7 @@ public:
|
||||||
bool isRecovery() const;
|
bool isRecovery() const;
|
||||||
bool isSneaking() const;
|
bool isSneaking() const;
|
||||||
bool isRunning() const;
|
bool isRunning() const;
|
||||||
|
bool isTurning() const;
|
||||||
bool isAttackingOrSpell() const;
|
bool isAttackingOrSpell() const;
|
||||||
|
|
||||||
void setAttackingOrSpell(bool attackingOrSpell);
|
void setAttackingOrSpell(bool attackingOrSpell);
|
||||||
|
|
Loading…
Reference in a new issue