From 86bd287b5346063edb0f62ceb96ee08c6ee80c18 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 20 Mar 2012 20:39:33 +0000
Subject: refactor: precalculate the fixed movement factor for avatar tilting
(sqrt(2)) rather than doing it multiple times on every move.
---
OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Region/Physics/OdePlugin/ODECharacter.cs')
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 6d1f41d..8397eb4 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -115,6 +115,11 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes.
///
+ /// Base movement for calculating tilt.
+ ///
+ private float m_tiltBaseMovement = (float)Math.Sqrt(2);
+
+ ///
/// Used to introduce a fixed tilt because a straight-up capsule falls through terrain, probably a bug in terrain collider
///
private float m_tiltMagnitudeWhenProjectedOnXYPlane = 0.1131371f;
@@ -524,14 +529,14 @@ namespace OpenSim.Region.Physics.OdePlugin
if (movementVector.Y > 0)
{
// northeast
- movementVector.X = (float)Math.Sqrt(2.0);
- movementVector.Y = (float)Math.Sqrt(2.0);
+ movementVector.X = m_tiltBaseMovement;
+ movementVector.Y = m_tiltBaseMovement;
}
else
{
// southeast
- movementVector.X = (float)Math.Sqrt(2.0);
- movementVector.Y = -(float)Math.Sqrt(2.0);
+ movementVector.X = m_tiltBaseMovement;
+ movementVector.Y = -m_tiltBaseMovement;
}
}
else
@@ -540,14 +545,14 @@ namespace OpenSim.Region.Physics.OdePlugin
if (movementVector.Y > 0)
{
// northwest
- movementVector.X = -(float)Math.Sqrt(2.0);
- movementVector.Y = (float)Math.Sqrt(2.0);
+ movementVector.X = -m_tiltBaseMovement;
+ movementVector.Y = m_tiltBaseMovement;
}
else
{
// southwest
- movementVector.X = -(float)Math.Sqrt(2.0);
- movementVector.Y = -(float)Math.Sqrt(2.0);
+ movementVector.X = -m_tiltBaseMovement;
+ movementVector.Y = -m_tiltBaseMovement;
}
}
--
cgit v1.1