aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs')
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs52
1 files changed, 26 insertions, 26 deletions
diff --git a/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs b/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs
index 7e95d7f..39aea59 100644
--- a/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/ODEDynamics.cs
@@ -93,7 +93,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
93 private float m_linearMotorDecayTimescale = 0; 93 private float m_linearMotorDecayTimescale = 0;
94 private float m_linearMotorTimescale = 0; 94 private float m_linearMotorTimescale = 0;
95 private Vector3 m_lastLinearVelocityVector = Vector3.Zero; 95 private Vector3 m_lastLinearVelocityVector = Vector3.Zero;
96 private d.Vector3 m_lastPositionVector = new d.Vector3(); 96 private SafeNativeMethods.Vector3 m_lastPositionVector = new SafeNativeMethods.Vector3();
97 // private bool m_LinearMotorSetLastFrame = false; 97 // private bool m_LinearMotorSetLastFrame = false;
98 // private Vector3 m_linearMotorOffset = Vector3.Zero; 98 // private Vector3 m_linearMotorOffset = Vector3.Zero;
99 99
@@ -611,7 +611,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
611 { 611 {
612 m_lastLinearVelocityVector = Vector3.Zero; 612 m_lastLinearVelocityVector = Vector3.Zero;
613 m_lastAngularVelocity = Vector3.Zero; 613 m_lastAngularVelocity = Vector3.Zero;
614 m_lastPositionVector = d.BodyGetPosition(Body); 614 m_lastPositionVector = SafeNativeMethods.BodyGetPosition(Body);
615 } 615 }
616 616
617 internal void Step(float pTimestep, OdeScene pParentScene) 617 internal void Step(float pTimestep, OdeScene pParentScene)
@@ -631,8 +631,8 @@ namespace OpenSim.Region.PhysicsModule.ODE
631 { 631 {
632 if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f)) // requested m_linearMotorDirection is significant 632 if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f)) // requested m_linearMotorDirection is significant
633 { 633 {
634 if (!d.BodyIsEnabled(Body)) 634 if (!SafeNativeMethods.BodyIsEnabled(Body))
635 d.BodyEnable(Body); 635 SafeNativeMethods.BodyEnable(Body);
636 636
637 // add drive to body 637 // add drive to body
638 Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep); 638 Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep);
@@ -662,7 +662,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
662 662
663 // convert requested object velocity to world-referenced vector 663 // convert requested object velocity to world-referenced vector
664 m_dir = m_lastLinearVelocityVector; 664 m_dir = m_lastLinearVelocityVector;
665 d.Quaternion rot = d.BodyGetQuaternion(Body); 665 SafeNativeMethods.Quaternion rot = SafeNativeMethods.BodyGetQuaternion(Body);
666 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object 666 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
667 m_dir *= rotq; // apply obj rotation to velocity vector 667 m_dir *= rotq; // apply obj rotation to velocity vector
668 668
@@ -673,15 +673,15 @@ namespace OpenSim.Region.PhysicsModule.ODE
673 Vector3 grav = Vector3.Zero; 673 Vector3 grav = Vector3.Zero;
674 // There is some gravity, make a gravity force vector 674 // There is some gravity, make a gravity force vector
675 // that is applied after object velocity. 675 // that is applied after object velocity.
676 d.Mass objMass; 676 SafeNativeMethods.Mass objMass;
677 d.BodyGetMass(Body, out objMass); 677 SafeNativeMethods.BodyGetMass(Body, out objMass);
678 // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; 678 // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g;
679 grav.Z = _pParentScene.gravityz * objMass.mass * (1f - m_VehicleBuoyancy); 679 grav.Z = _pParentScene.gravityz * objMass.mass * (1f - m_VehicleBuoyancy);
680 // Preserve the current Z velocity 680 // Preserve the current Z velocity
681 d.Vector3 vel_now = d.BodyGetLinearVel(Body); 681 SafeNativeMethods.Vector3 vel_now = SafeNativeMethods.BodyGetLinearVel(Body);
682 m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity 682 m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity
683 683
684 d.Vector3 pos = d.BodyGetPosition(Body); 684 SafeNativeMethods.Vector3 pos = SafeNativeMethods.BodyGetPosition(Body);
685// Vector3 accel = new Vector3(-(m_dir.X - m_lastLinearVelocityVector.X / 0.1f), -(m_dir.Y - m_lastLinearVelocityVector.Y / 0.1f), m_dir.Z - m_lastLinearVelocityVector.Z / 0.1f); 685// Vector3 accel = new Vector3(-(m_dir.X - m_lastLinearVelocityVector.X / 0.1f), -(m_dir.Y - m_lastLinearVelocityVector.Y / 0.1f), m_dir.Z - m_lastLinearVelocityVector.Z / 0.1f);
686 Vector3 posChange = new Vector3(); 686 Vector3 posChange = new Vector3();
687 posChange.X = pos.X - m_lastPositionVector.X; 687 posChange.X = pos.X - m_lastPositionVector.X;
@@ -693,33 +693,33 @@ namespace OpenSim.Region.PhysicsModule.ODE
693 if (pos.X >= (m_BlockingEndPoint.X - (float)1)) 693 if (pos.X >= (m_BlockingEndPoint.X - (float)1))
694 { 694 {
695 pos.X -= posChange.X + 1; 695 pos.X -= posChange.X + 1;
696 d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); 696 SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
697 } 697 }
698 if (pos.Y >= (m_BlockingEndPoint.Y - (float)1)) 698 if (pos.Y >= (m_BlockingEndPoint.Y - (float)1))
699 { 699 {
700 pos.Y -= posChange.Y + 1; 700 pos.Y -= posChange.Y + 1;
701 d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); 701 SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
702 } 702 }
703 if (pos.Z >= (m_BlockingEndPoint.Z - (float)1)) 703 if (pos.Z >= (m_BlockingEndPoint.Z - (float)1))
704 { 704 {
705 pos.Z -= posChange.Z + 1; 705 pos.Z -= posChange.Z + 1;
706 d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); 706 SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
707 } 707 }
708 if (pos.X <= 0) 708 if (pos.X <= 0)
709 { 709 {
710 pos.X += posChange.X + 1; 710 pos.X += posChange.X + 1;
711 d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); 711 SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
712 } 712 }
713 if (pos.Y <= 0) 713 if (pos.Y <= 0)
714 { 714 {
715 pos.Y += posChange.Y + 1; 715 pos.Y += posChange.Y + 1;
716 d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); 716 SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
717 } 717 }
718 } 718 }
719 if (pos.Z < _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y)) 719 if (pos.Z < _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y))
720 { 720 {
721 pos.Z = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + 2; 721 pos.Z = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y) + 2;
722 d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); 722 SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, pos.Z);
723 } 723 }
724 724
725 // Check if hovering 725 // Check if hovering
@@ -748,7 +748,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
748 { 748 {
749 if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2) 749 if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2)
750 { 750 {
751 d.BodySetPosition(Body, pos.X, pos.Y, m_VhoverTargetHeight); 751 SafeNativeMethods.BodySetPosition(Body, pos.X, pos.Y, m_VhoverTargetHeight);
752 } 752 }
753 } 753 }
754 else 754 else
@@ -815,12 +815,12 @@ namespace OpenSim.Region.PhysicsModule.ODE
815 m_dir.Z = 0; 815 m_dir.Z = 0;
816 } 816 }
817 817
818 m_lastPositionVector = d.BodyGetPosition(Body); 818 m_lastPositionVector = SafeNativeMethods.BodyGetPosition(Body);
819 819
820 // Apply velocity 820 // Apply velocity
821 d.BodySetLinearVel(Body, m_dir.X, m_dir.Y, m_dir.Z); 821 SafeNativeMethods.BodySetLinearVel(Body, m_dir.X, m_dir.Y, m_dir.Z);
822 // apply gravity force 822 // apply gravity force
823 d.BodyAddForce(Body, grav.X, grav.Y, grav.Z); 823 SafeNativeMethods.BodyAddForce(Body, grav.X, grav.Y, grav.Z);
824 824
825 825
826 // apply friction 826 // apply friction
@@ -841,7 +841,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
841 */ 841 */
842 842
843 // Get what the body is doing, this includes 'external' influences 843 // Get what the body is doing, this includes 'external' influences
844 d.Vector3 angularVelocity = d.BodyGetAngularVel(Body); 844 SafeNativeMethods.Vector3 angularVelocity = SafeNativeMethods.BodyGetAngularVel(Body);
845 // Vector3 angularVelocity = Vector3.Zero; 845 // Vector3 angularVelocity = Vector3.Zero;
846 846
847 if (m_angularMotorApply > 0) 847 if (m_angularMotorApply > 0)
@@ -874,7 +874,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
874 { 874 {
875 float VAservo = 0.2f / (m_verticalAttractionTimescale * pTimestep); 875 float VAservo = 0.2f / (m_verticalAttractionTimescale * pTimestep);
876 // get present body rotation 876 // get present body rotation
877 d.Quaternion rot = d.BodyGetQuaternion(Body); 877 SafeNativeMethods.Quaternion rot = SafeNativeMethods.BodyGetQuaternion(Body);
878 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); 878 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
879 // make a vector pointing up 879 // make a vector pointing up
880 Vector3 verterr = Vector3.Zero; 880 Vector3 verterr = Vector3.Zero;
@@ -923,7 +923,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
923 923
924 if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) 924 if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
925 { 925 {
926 if (!d.BodyIsEnabled (Body)) d.BodyEnable (Body); 926 if (!SafeNativeMethods.BodyIsEnabled (Body)) SafeNativeMethods.BodyEnable (Body);
927 } 927 }
928 else 928 else
929 { 929 {
@@ -935,14 +935,14 @@ namespace OpenSim.Region.PhysicsModule.ODE
935 m_lastAngularVelocity -= m_lastAngularVelocity * decayamount; 935 m_lastAngularVelocity -= m_lastAngularVelocity * decayamount;
936 936
937 // Apply to the body 937 // Apply to the body
938 d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z); 938 SafeNativeMethods.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z);
939 939
940 } //end MoveAngular 940 } //end MoveAngular
941 internal void LimitRotation(float timestep) 941 internal void LimitRotation(float timestep)
942 { 942 {
943 d.Quaternion rot = d.BodyGetQuaternion(Body); 943 SafeNativeMethods.Quaternion rot = SafeNativeMethods.BodyGetQuaternion(Body);
944 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object 944 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
945 d.Quaternion m_rot = new d.Quaternion(); 945 SafeNativeMethods.Quaternion m_rot = new SafeNativeMethods.Quaternion();
946 bool changed = false; 946 bool changed = false;
947 m_rot.X = rotq.X; 947 m_rot.X = rotq.X;
948 m_rot.Y = rotq.Y; 948 m_rot.Y = rotq.Y;
@@ -975,7 +975,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
975 changed = true; 975 changed = true;
976 } 976 }
977 if (changed) 977 if (changed)
978 d.BodySetQuaternion(Body, ref m_rot); 978 SafeNativeMethods.BodySetQuaternion(Body, ref m_rot);
979 } 979 }
980 } 980 }
981} 981}