aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs')
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs33
1 files changed, 29 insertions, 4 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
index 55d6945..b3b09e6 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
@@ -116,6 +116,8 @@ namespace OpenSim.Region.Physics.OdePlugin
116 private Vector3 m_angularMotorDVel = Vector3.Zero; // decayed angular motor 116 private Vector3 m_angularMotorDVel = Vector3.Zero; // decayed angular motor
117// private Vector3 m_angObjectVel = Vector3.Zero; // current body angular velocity 117// private Vector3 m_angObjectVel = Vector3.Zero; // current body angular velocity
118 private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body 118 private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body
119
120 private Vector3 m_angularLock = Vector3.One;
119 121
120 //Deflection properties 122 //Deflection properties
121 // private float m_angularDeflectionEfficiency = 0; 123 // private float m_angularDeflectionEfficiency = 0;
@@ -296,6 +298,11 @@ namespace OpenSim.Region.Physics.OdePlugin
296 298
297 }//end ProcessRotationVehicleParam 299 }//end ProcessRotationVehicleParam
298 300
301 internal void SetAngularLock(Vector3 pValue)
302 {
303 m_angularLock = pValue;
304 }
305
299 internal void ProcessFlagsVehicleSet(int flags) 306 internal void ProcessFlagsVehicleSet(int flags)
300 { 307 {
301 m_flags |= (VehicleFlag)flags; 308 m_flags |= (VehicleFlag)flags;
@@ -649,8 +656,13 @@ namespace OpenSim.Region.Physics.OdePlugin
649//if(frcount == 0) Console.WriteLine("MoveAngular "); 656//if(frcount == 0) Console.WriteLine("MoveAngular ");
650 657
651 // Get what the body is doing, this includes 'external' influences 658 // Get what the body is doing, this includes 'external' influences
659 d.Quaternion rot = d.BodyGetQuaternion(Body);
660 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
661 Quaternion irotq = Quaternion.Inverse(rotq);
652 d.Vector3 angularObjectVel = d.BodyGetAngularVel(Body); 662 d.Vector3 angularObjectVel = d.BodyGetAngularVel(Body);
653 Vector3 angObjectVel = new Vector3(angularObjectVel.X, angularObjectVel.Y, angularObjectVel.Z); 663 Vector3 angObjectVel = new Vector3(angularObjectVel.X, angularObjectVel.Y, angularObjectVel.Z);
664 angObjectVel = angObjectVel * irotq; // ============ Converts to LOCAL rotation
665
654//if(frcount == 0) Console.WriteLine("V0 = {0}", angObjectVel); 666//if(frcount == 0) Console.WriteLine("V0 = {0}", angObjectVel);
655// Vector3 FrAaccel = m_lastAngularVelocity - angObjectVel; 667// Vector3 FrAaccel = m_lastAngularVelocity - angObjectVel;
656// Vector3 initavel = angObjectVel; 668// Vector3 initavel = angObjectVel;
@@ -694,8 +706,8 @@ namespace OpenSim.Region.Physics.OdePlugin
694 { 706 {
695 float VAservo = 1.0f / (m_verticalAttractionTimescale * pTimestep); 707 float VAservo = 1.0f / (m_verticalAttractionTimescale * pTimestep);
696 // get present body rotation 708 // get present body rotation
697 d.Quaternion rot = d.BodyGetQuaternion(Body); 709// d.Quaternion rot = d.BodyGetQuaternion(Body);
698 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); 710// Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
699 // make a vector pointing up 711 // make a vector pointing up
700 Vector3 verterr = Vector3.Zero; 712 Vector3 verterr = Vector3.Zero;
701 verterr.Z = 1.0f; 713 verterr.Z = 1.0f;
@@ -706,7 +718,7 @@ namespace OpenSim.Region.Physics.OdePlugin
706 // negative. Similar for tilt and |.Y|. .X and .Y must be modulated to prevent a stable inverted body. 718 // negative. Similar for tilt and |.Y|. .X and .Y must be modulated to prevent a stable inverted body.
707 719
708 if (verterr.Z < 0.0f) 720 if (verterr.Z < 0.0f)
709 { // Defelction from vertical exceeds 90-degrees. This method will ensure stable return to 721 { // Deflection from vertical exceeds 90-degrees. This method will ensure stable return to
710 // vertical, BUT for some reason a z-rotation is imparted to the object. TBI. 722 // vertical, BUT for some reason a z-rotation is imparted to the object. TBI.
711//Console.WriteLine("InvertFlip"); 723//Console.WriteLine("InvertFlip");
712 verterr.X = 2.0f - verterr.X; 724 verterr.X = 2.0f - verterr.X;
@@ -781,9 +793,22 @@ namespace OpenSim.Region.Physics.OdePlugin
781 m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero. 793 m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero.
782 } 794 }
783 */ 795 */
796//if(frcount == 0) Console.WriteLine("angularLock {0}", m_angularLock);
797
798 if (!m_angularLock.ApproxEquals(Vector3.One, 0.003f))
799 {
800 if (m_angularLock.X == 0)
801 m_lastAngularVelocity.X = 0f;
802 if (m_angularLock.Y == 0)
803 m_lastAngularVelocity.Y = 0f;
804 if (m_angularLock.Z == 0)
805 m_lastAngularVelocity.Z = 0f;
806 }
784 // Apply to the body 807 // Apply to the body
785// Vector3 aInc = m_lastAngularVelocity - initavel; 808// Vector3 aInc = m_lastAngularVelocity - initavel;
786//if(frcount == 0) Console.WriteLine("Inc {0}", aInc); 809//if(frcount == 0) Console.WriteLine("Inc {0}", aInc);
810 m_lastAngularVelocity = m_lastAngularVelocity * rotq; // ================ Converts to WORLD rotation
811
787 d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z); 812 d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z);
788//if(frcount == 0) Console.WriteLine("V4 = {0}", m_lastAngularVelocity); 813//if(frcount == 0) Console.WriteLine("V4 = {0}", m_lastAngularVelocity);
789 814