1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-21 15:41:33 +00:00

Fixed the rotation animation glitch.

This commit is contained in:
cc9cii 2014-04-20 14:27:18 +10:00
parent 000afa48b7
commit 2b544d550b
3 changed files with 9 additions and 12 deletions

View file

@ -209,7 +209,10 @@ namespace MWMechanics
if (mRotate) if (mRotate)
{ {
if (zTurn(actor, Ogre::Degree(mTargetAngle))) // Reduce the turning animation glitch by using a *HUGE* value of
// epsilon... TODO: a proper fix might be in either the physics or the
// animation subsystem
if (zTurn(actor, Ogre::Degree(mTargetAngle), Ogre::Degree(12)))
mRotate = false; mRotate = false;
} }
@ -220,7 +223,7 @@ namespace MWMechanics
return false; return false;
} }
// NOTE: everything below get updated every mReaction // NOTE: everything below get updated every 0.25 seconds
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
if(mDuration) if(mDuration)
@ -404,7 +407,6 @@ namespace MWMechanics
float faceAngle = Ogre::Radian(Ogre::Math::ACos(dir.y / length) * float faceAngle = Ogre::Radian(Ogre::Math::ACos(dir.y / length) *
((Ogre::Math::ASin(dir.x / length).valueRadians()>0)?1.0:-1.0)).valueDegrees(); ((Ogre::Math::ASin(dir.x / length).valueRadians()>0)?1.0:-1.0)).valueDegrees();
// an attempt at reducing the turning animation glitch // an attempt at reducing the turning animation glitch
// TODO: doesn't seem to work very well
if(abs(faceAngle) > 10) if(abs(faceAngle) > 10)
{ {
mTargetAngle = faceAngle; mTargetAngle = faceAngle;
@ -412,11 +414,6 @@ namespace MWMechanics
} }
} }
} }
else if(!mDistance) // FIXME: stationary actors go back to their normal position
{
//mTargetAngle = mOriginalAngle;
//mRotate = true;
}
if (!mSaidGreeting) if (!mSaidGreeting)
{ {
@ -436,7 +433,7 @@ namespace MWMechanics
} }
// Check if idle animation finished // Check if idle animation finished
if(!checkIdle(actor, mPlayedIdle)) if(!checkIdle(actor, mPlayedIdle) && !mRotate)
{ {
mPlayedIdle = 0; mPlayedIdle = 0;
mIdleNow = false; mIdleNow = false;

View file

@ -10,7 +10,7 @@
namespace MWMechanics namespace MWMechanics
{ {
bool zTurn(const MWWorld::Ptr& actor, Ogre::Radian targetAngle) bool zTurn(const MWWorld::Ptr& actor, Ogre::Radian targetAngle, Ogre::Degree epsilon)
{ {
Ogre::Radian currentAngle (actor.getRefData().getPosition().rot[2]); Ogre::Radian currentAngle (actor.getRefData().getPosition().rot[2]);
Ogre::Radian diff (targetAngle - currentAngle); Ogre::Radian diff (targetAngle - currentAngle);
@ -27,7 +27,6 @@ bool zTurn(const MWWorld::Ptr& actor, Ogre::Radian targetAngle)
// The turning animation actually moves you slightly, so the angle will be wrong again. // The turning animation actually moves you slightly, so the angle will be wrong again.
// Use epsilon to prevent jerkiness. // Use epsilon to prevent jerkiness.
const Ogre::Degree epsilon (0.5);
if (absDiff < epsilon) if (absDiff < epsilon)
return true; return true;

View file

@ -12,7 +12,8 @@ namespace MWMechanics
/// configure rotation settings for an actor to reach this target angle (eventually) /// configure rotation settings for an actor to reach this target angle (eventually)
/// @return have we reached the target angle? /// @return have we reached the target angle?
bool zTurn(const MWWorld::Ptr& actor, Ogre::Radian targetAngle); bool zTurn(const MWWorld::Ptr& actor, Ogre::Radian targetAngle,
Ogre::Degree epsilon = Ogre::Degree(0.5));
} }