Fixed the rotation animation glitch.

actorid
cc9cii 11 years ago
parent 000afa48b7
commit 2b544d550b

@ -209,7 +209,10 @@ namespace MWMechanics
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;
}
@ -220,7 +223,7 @@ namespace MWMechanics
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();
if(mDuration)
@ -404,7 +407,6 @@ namespace MWMechanics
float faceAngle = Ogre::Radian(Ogre::Math::ACos(dir.y / length) *
((Ogre::Math::ASin(dir.x / length).valueRadians()>0)?1.0:-1.0)).valueDegrees();
// an attempt at reducing the turning animation glitch
// TODO: doesn't seem to work very well
if(abs(faceAngle) > 10)
{
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)
{
@ -436,7 +433,7 @@ namespace MWMechanics
}
// Check if idle animation finished
if(!checkIdle(actor, mPlayedIdle))
if(!checkIdle(actor, mPlayedIdle) && !mRotate)
{
mPlayedIdle = 0;
mIdleNow = false;

@ -10,7 +10,7 @@
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 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.
// Use epsilon to prevent jerkiness.
const Ogre::Degree epsilon (0.5);
if (absDiff < epsilon)
return true;

@ -12,7 +12,8 @@ namespace MWMechanics
/// configure rotation settings for an actor to reach this target angle (eventually)
/// @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));
}

Loading…
Cancel
Save