refactor: precalculate the fixed movement factor for avatar tilting (sqrt(2)) rather than doing it multiple times on every move.

0.7.4.1
Justin Clark-Casey (justincc) 2012-03-20 20:39:33 +00:00
parent 5f2a65c976
commit 86bd287b53
2 changed files with 16 additions and 8 deletions

View File

@ -114,6 +114,11 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes. private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes.
/// <summary>
/// Base movement for calculating tilt.
/// </summary>
private float m_tiltBaseMovement = (float)Math.Sqrt(2);
/// <summary> /// <summary>
/// Used to introduce a fixed tilt because a straight-up capsule falls through terrain, probably a bug in terrain collider /// Used to introduce a fixed tilt because a straight-up capsule falls through terrain, probably a bug in terrain collider
/// </summary> /// </summary>
@ -524,14 +529,14 @@ namespace OpenSim.Region.Physics.OdePlugin
if (movementVector.Y > 0) if (movementVector.Y > 0)
{ {
// northeast // northeast
movementVector.X = (float)Math.Sqrt(2.0); movementVector.X = m_tiltBaseMovement;
movementVector.Y = (float)Math.Sqrt(2.0); movementVector.Y = m_tiltBaseMovement;
} }
else else
{ {
// southeast // southeast
movementVector.X = (float)Math.Sqrt(2.0); movementVector.X = m_tiltBaseMovement;
movementVector.Y = -(float)Math.Sqrt(2.0); movementVector.Y = -m_tiltBaseMovement;
} }
} }
else else
@ -540,14 +545,14 @@ namespace OpenSim.Region.Physics.OdePlugin
if (movementVector.Y > 0) if (movementVector.Y > 0)
{ {
// northwest // northwest
movementVector.X = -(float)Math.Sqrt(2.0); movementVector.X = -m_tiltBaseMovement;
movementVector.Y = (float)Math.Sqrt(2.0); movementVector.Y = m_tiltBaseMovement;
} }
else else
{ {
// southwest // southwest
movementVector.X = -(float)Math.Sqrt(2.0); movementVector.X = -m_tiltBaseMovement;
movementVector.Y = -(float)Math.Sqrt(2.0); movementVector.Y = -m_tiltBaseMovement;
} }
} }

View File

@ -185,6 +185,9 @@ namespace OpenSim.Region.Physics.OdePlugin
/// <summary> /// <summary>
/// true = old compatibility mode with leaning capsule; false = new corrected mode /// true = old compatibility mode with leaning capsule; false = new corrected mode
/// </summary> /// </summary>
/// <remarks>
/// Even when set to false, the capsule still tilts but this is done in a different way.
/// </remarks>
public bool IsAvCapsuleTilted { get; private set; } public bool IsAvCapsuleTilted { get; private set; }
private float avDensity = 80f; private float avDensity = 80f;