aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs113
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs27
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs318
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs67
-rw-r--r--OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs4
5 files changed, 262 insertions, 267 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 71ace16..c86bc62 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -68,15 +68,15 @@ namespace OpenSim.Region.Physics.OdePlugin
68 { 68 {
69 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 69 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
70 70
71 private PhysicsVector _position; 71 private Vector3 _position;
72 private d.Vector3 _zeroPosition; 72 private d.Vector3 _zeroPosition;
73 // private d.Matrix3 m_StandUpRotation; 73 // private d.Matrix3 m_StandUpRotation;
74 private bool _zeroFlag = false; 74 private bool _zeroFlag = false;
75 private bool m_lastUpdateSent = false; 75 private bool m_lastUpdateSent = false;
76 private PhysicsVector _velocity; 76 private Vector3 _velocity;
77 private PhysicsVector _target_velocity; 77 private Vector3 _target_velocity;
78 private PhysicsVector _acceleration; 78 private Vector3 _acceleration;
79 private PhysicsVector m_rotationalVelocity; 79 private Vector3 m_rotationalVelocity;
80 private float m_mass = 80f; 80 private float m_mass = 80f;
81 public float m_density = 60f; 81 public float m_density = 60f;
82 private bool m_pidControllerActive = true; 82 private bool m_pidControllerActive = true;
@@ -99,7 +99,7 @@ namespace OpenSim.Region.Physics.OdePlugin
99 private bool m_hackSentFall = false; 99 private bool m_hackSentFall = false;
100 private bool m_hackSentFly = false; 100 private bool m_hackSentFly = false;
101 private int m_requestedUpdateFrequency = 0; 101 private int m_requestedUpdateFrequency = 0;
102 private PhysicsVector m_taintPosition = new PhysicsVector(0, 0, 0); 102 private Vector3 m_taintPosition = Vector3.Zero;
103 public uint m_localID = 0; 103 public uint m_localID = 0;
104 public bool m_returnCollisions = false; 104 public bool m_returnCollisions = false;
105 // taints and their non-tainted counterparts 105 // taints and their non-tainted counterparts
@@ -143,22 +143,17 @@ namespace OpenSim.Region.Physics.OdePlugin
143 public UUID m_uuid; 143 public UUID m_uuid;
144 public bool bad = false; 144 public bool bad = false;
145 145
146 public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos, CollisionLocker dode, PhysicsVector size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) 146 public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, CollisionLocker dode, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor)
147 { 147 {
148 m_uuid = UUID.Random(); 148 m_uuid = UUID.Random();
149 149
150 // ode = dode; 150 if (pos.IsFinite())
151 _velocity = new PhysicsVector();
152 _target_velocity = new PhysicsVector();
153
154
155 if (PhysicsVector.isFinite(pos))
156 { 151 {
157 if (pos.Z > 9999999) 152 if (pos.Z > 9999999f)
158 { 153 {
159 pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 154 pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
160 } 155 }
161 if (pos.Z < -90000) 156 if (pos.Z < -90000f)
162 { 157 {
163 pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 158 pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
164 } 159 }
@@ -169,15 +164,13 @@ namespace OpenSim.Region.Physics.OdePlugin
169 } 164 }
170 else 165 else
171 { 166 {
172 _position = new PhysicsVector(((int)_parent_scene.WorldExtents.X * 0.5f), ((int)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128, 128) + 10); 167 _position = new Vector3(((float)_parent_scene.WorldExtents.X * 0.5f), ((float)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f);
173 m_taintPosition.X = _position.X; 168 m_taintPosition.X = _position.X;
174 m_taintPosition.Y = _position.Y; 169 m_taintPosition.Y = _position.Y;
175 m_taintPosition.Z = _position.Z; 170 m_taintPosition.Z = _position.Z;
176 m_log.Warn("[PHYSICS]: Got NaN Position on Character Create"); 171 m_log.Warn("[PHYSICS]: Got NaN Position on Character Create");
177 } 172 }
178 173
179
180 _acceleration = new PhysicsVector();
181 _parent_scene = parent_scene; 174 _parent_scene = parent_scene;
182 175
183 PID_D = pid_d; 176 PID_D = pid_d;
@@ -189,7 +182,6 @@ namespace OpenSim.Region.Physics.OdePlugin
189 walkDivisor = walk_divisor; 182 walkDivisor = walk_divisor;
190 runDivisor = rundivisor; 183 runDivisor = rundivisor;
191 184
192
193 // m_StandUpRotation = 185 // m_StandUpRotation =
194 // new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f, 186 // new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f,
195 // 0.5f); 187 // 0.5f);
@@ -205,7 +197,6 @@ namespace OpenSim.Region.Physics.OdePlugin
205 m_isPhysical = false; // current status: no ODE information exists 197 m_isPhysical = false; // current status: no ODE information exists
206 m_tainted_isPhysical = true; // new tainted status: need to create ODE information 198 m_tainted_isPhysical = true; // new tainted status: need to create ODE information
207 199
208
209 _parent_scene.AddPhysicsActorTaint(this); 200 _parent_scene.AddPhysicsActorTaint(this);
210 201
211 m_name = avName; 202 m_name = avName;
@@ -412,20 +403,20 @@ namespace OpenSim.Region.Physics.OdePlugin
412 /// Not really a good choice unless you 'know' it's a good 403 /// Not really a good choice unless you 'know' it's a good
413 /// spot otherwise you're likely to orbit the avatar. 404 /// spot otherwise you're likely to orbit the avatar.
414 /// </summary> 405 /// </summary>
415 public override PhysicsVector Position 406 public override Vector3 Position
416 { 407 {
417 get { return _position; } 408 get { return _position; }
418 set 409 set
419 { 410 {
420 if (Body == IntPtr.Zero || Shell == IntPtr.Zero) 411 if (Body == IntPtr.Zero || Shell == IntPtr.Zero)
421 { 412 {
422 if (PhysicsVector.isFinite(value)) 413 if (value.IsFinite())
423 { 414 {
424 if (value.Z > 9999999) 415 if (value.Z > 9999999f)
425 { 416 {
426 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 417 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
427 } 418 }
428 if (value.Z < -90000) 419 if (value.Z < -90000f)
429 { 420 {
430 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 421 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
431 } 422 }
@@ -447,7 +438,7 @@ namespace OpenSim.Region.Physics.OdePlugin
447 } 438 }
448 } 439 }
449 440
450 public override PhysicsVector RotationalVelocity 441 public override Vector3 RotationalVelocity
451 { 442 {
452 get { return m_rotationalVelocity; } 443 get { return m_rotationalVelocity; }
453 set { m_rotationalVelocity = value; } 444 set { m_rotationalVelocity = value; }
@@ -457,20 +448,20 @@ namespace OpenSim.Region.Physics.OdePlugin
457 /// This property sets the height of the avatar only. We use the height to make sure the avatar stands up straight 448 /// This property sets the height of the avatar only. We use the height to make sure the avatar stands up straight
458 /// and use it to offset landings properly 449 /// and use it to offset landings properly
459 /// </summary> 450 /// </summary>
460 public override PhysicsVector Size 451 public override Vector3 Size
461 { 452 {
462 get { return new PhysicsVector(CAPSULE_RADIUS*2, CAPSULE_RADIUS*2, CAPSULE_LENGTH); } 453 get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); }
463 set 454 set
464 { 455 {
465 if (PhysicsVector.isFinite(value)) 456 if (value.IsFinite())
466 { 457 {
467 m_pidControllerActive = true; 458 m_pidControllerActive = true;
468 459
469 PhysicsVector SetSize = value; 460 Vector3 SetSize = value;
470 m_tainted_CAPSULE_LENGTH = (SetSize.Z*1.15f) - CAPSULE_RADIUS*2.0f; 461 m_tainted_CAPSULE_LENGTH = (SetSize.Z*1.15f) - CAPSULE_RADIUS*2.0f;
471 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); 462 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
472 463
473 Velocity = new PhysicsVector(0f, 0f, 0f); 464 Velocity = Vector3.Zero;
474 465
475 _parent_scene.AddPhysicsActorTaint(this); 466 _parent_scene.AddPhysicsActorTaint(this);
476 } 467 }
@@ -481,7 +472,7 @@ namespace OpenSim.Region.Physics.OdePlugin
481 } 472 }
482 } 473 }
483 474
484 private void AlignAvatarTiltWithCurrentDirectionOfMovement(PhysicsVector movementVector) 475 private void AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3 movementVector)
485 { 476 {
486 movementVector.Z = 0f; 477 movementVector.Z = 0f;
487 float magnitude = (float)Math.Sqrt((double)(movementVector.X * movementVector.X + movementVector.Y * movementVector.Y)); 478 float magnitude = (float)Math.Sqrt((double)(movementVector.X * movementVector.X + movementVector.Y * movementVector.Y));
@@ -643,7 +634,7 @@ namespace OpenSim.Region.Physics.OdePlugin
643 // (with -0..0 motor stops) falls into the terrain for reasons yet 634 // (with -0..0 motor stops) falls into the terrain for reasons yet
644 // to be comprehended in their entirety. 635 // to be comprehended in their entirety.
645 #endregion 636 #endregion
646 AlignAvatarTiltWithCurrentDirectionOfMovement(new PhysicsVector(0,0,0)); 637 AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero);
647 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f); 638 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f);
648 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f); 639 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f);
649 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f); 640 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f);
@@ -688,7 +679,7 @@ namespace OpenSim.Region.Physics.OdePlugin
688 679
689 } 680 }
690 681
691 public override void LockAngularMotion(PhysicsVector axis) 682 public override void LockAngularMotion(Vector3 axis)
692 { 683 {
693 684
694 } 685 }
@@ -716,9 +707,9 @@ namespace OpenSim.Region.Physics.OdePlugin
716// //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); 707// //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
717// } 708// }
718 709
719 public override PhysicsVector Force 710 public override Vector3 Force
720 { 711 {
721 get { return new PhysicsVector(_target_velocity.X, _target_velocity.Y, _target_velocity.Z); } 712 get { return _target_velocity; }
722 set { return; } 713 set { return; }
723 } 714 }
724 715
@@ -733,7 +724,7 @@ namespace OpenSim.Region.Physics.OdePlugin
733 724
734 } 725 }
735 726
736 public override void VehicleVectorParam(int param, PhysicsVector value) 727 public override void VehicleVectorParam(int param, Vector3 value)
737 { 728 {
738 729
739 } 730 }
@@ -748,14 +739,14 @@ namespace OpenSim.Region.Physics.OdePlugin
748 739
749 } 740 }
750 741
751 public override PhysicsVector CenterOfMass 742 public override Vector3 CenterOfMass
752 { 743 {
753 get { return PhysicsVector.Zero; } 744 get { return Vector3.Zero; }
754 } 745 }
755 746
756 public override PhysicsVector GeometricCenter 747 public override Vector3 GeometricCenter
757 { 748 {
758 get { return PhysicsVector.Zero; } 749 get { return Vector3.Zero; }
759 } 750 }
760 751
761 public override PrimitiveBaseShape Shape 752 public override PrimitiveBaseShape Shape
@@ -763,18 +754,18 @@ namespace OpenSim.Region.Physics.OdePlugin
763 set { return; } 754 set { return; }
764 } 755 }
765 756
766 public override PhysicsVector Velocity 757 public override Vector3 Velocity
767 { 758 {
768 get { 759 get {
769 // There's a problem with PhysicsVector.Zero! Don't Use it Here! 760 // There's a problem with Vector3.Zero! Don't Use it Here!
770 if (_zeroFlag) 761 if (_zeroFlag)
771 return new PhysicsVector(0f, 0f, 0f); 762 return Vector3.Zero;
772 m_lastUpdateSent = false; 763 m_lastUpdateSent = false;
773 return _velocity; 764 return _velocity;
774 } 765 }
775 set 766 set
776 { 767 {
777 if (PhysicsVector.isFinite(value)) 768 if (value.IsFinite())
778 { 769 {
779 m_pidControllerActive = true; 770 m_pidControllerActive = true;
780 _target_velocity = value; 771 _target_velocity = value;
@@ -786,9 +777,9 @@ namespace OpenSim.Region.Physics.OdePlugin
786 } 777 }
787 } 778 }
788 779
789 public override PhysicsVector Torque 780 public override Vector3 Torque
790 { 781 {
791 get { return PhysicsVector.Zero; } 782 get { return Vector3.Zero; }
792 set { return; } 783 set { return; }
793 } 784 }
794 785
@@ -814,12 +805,12 @@ namespace OpenSim.Region.Physics.OdePlugin
814 } 805 }
815 } 806 }
816 807
817 public override PhysicsVector Acceleration 808 public override Vector3 Acceleration
818 { 809 {
819 get { return _acceleration; } 810 get { return _acceleration; }
820 } 811 }
821 812
822 public void SetAcceleration(PhysicsVector accel) 813 public void SetAcceleration(Vector3 accel)
823 { 814 {
824 m_pidControllerActive = true; 815 m_pidControllerActive = true;
825 _acceleration = accel; 816 _acceleration = accel;
@@ -830,9 +821,9 @@ namespace OpenSim.Region.Physics.OdePlugin
830 /// The PID controller takes this target velocity and tries to make it a reality 821 /// The PID controller takes this target velocity and tries to make it a reality
831 /// </summary> 822 /// </summary>
832 /// <param name="force"></param> 823 /// <param name="force"></param>
833 public override void AddForce(PhysicsVector force, bool pushforce) 824 public override void AddForce(Vector3 force, bool pushforce)
834 { 825 {
835 if (PhysicsVector.isFinite(force)) 826 if (force.IsFinite())
836 { 827 {
837 if (pushforce) 828 if (pushforce)
838 { 829 {
@@ -861,7 +852,7 @@ namespace OpenSim.Region.Physics.OdePlugin
861 //m_lastUpdateSent = false; 852 //m_lastUpdateSent = false;
862 } 853 }
863 854
864 public override void AddAngularForce(PhysicsVector force, bool pushforce) 855 public override void AddAngularForce(Vector3 force, bool pushforce)
865 { 856 {
866 857
867 } 858 }
@@ -870,7 +861,7 @@ namespace OpenSim.Region.Physics.OdePlugin
870 /// After all of the forces add up with 'add force' we apply them with doForce 861 /// After all of the forces add up with 'add force' we apply them with doForce
871 /// </summary> 862 /// </summary>
872 /// <param name="force"></param> 863 /// <param name="force"></param>
873 public void doForce(PhysicsVector force) 864 public void doForce(Vector3 force)
874 { 865 {
875 if (!collidelock) 866 if (!collidelock)
876 { 867 {
@@ -881,7 +872,7 @@ namespace OpenSim.Region.Physics.OdePlugin
881 } 872 }
882 } 873 }
883 874
884 public override void SetMomentum(PhysicsVector momentum) 875 public override void SetMomentum(Vector3 momentum)
885 { 876 {
886 } 877 }
887 878
@@ -908,9 +899,9 @@ namespace OpenSim.Region.Physics.OdePlugin
908 //PidStatus = true; 899 //PidStatus = true;
909 900
910 d.Vector3 localpos = d.BodyGetPosition(Body); 901 d.Vector3 localpos = d.BodyGetPosition(Body);
911 PhysicsVector localPos = new PhysicsVector(localpos.X, localpos.Y, localpos.Z); 902 Vector3 localPos = new Vector3(localpos.X, localpos.Y, localpos.Z);
912 903
913 if (!PhysicsVector.isFinite(localPos)) 904 if (!localPos.IsFinite())
914 { 905 {
915 906
916 m_log.Warn("[PHYSICS]: Avatar Position is non-finite!"); 907 m_log.Warn("[PHYSICS]: Avatar Position is non-finite!");
@@ -946,7 +937,7 @@ namespace OpenSim.Region.Physics.OdePlugin
946 return; 937 return;
947 } 938 }
948 939
949 PhysicsVector vec = new PhysicsVector(); 940 Vector3 vec = Vector3.Zero;
950 d.Vector3 vel = d.BodyGetLinearVel(Body); 941 d.Vector3 vel = d.BodyGetLinearVel(Body);
951 942
952 float movementdivisor = 1f; 943 float movementdivisor = 1f;
@@ -1059,12 +1050,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1059 } 1050 }
1060 // end add Kitto Flora 1051 // end add Kitto Flora
1061 } 1052 }
1062 if (PhysicsVector.isFinite(vec)) 1053 if (vec.IsFinite())
1063 { 1054 {
1064 doForce(vec); 1055 doForce(vec);
1065 if (!_zeroFlag) 1056 if (!_zeroFlag)
1066 { 1057 {
1067 AlignAvatarTiltWithCurrentDirectionOfMovement(new PhysicsVector(vec.X, vec.Y, vec.Z)); 1058 AlignAvatarTiltWithCurrentDirectionOfMovement(vec);
1068 } 1059 }
1069 } 1060 }
1070 else 1061 else
@@ -1197,7 +1188,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1197 { 1188 {
1198 } 1189 }
1199 1190
1200 public override PhysicsVector PIDTarget { set { return; } } 1191 public override Vector3 PIDTarget { set { return; } }
1201 public override bool PIDActive { set { return; } } 1192 public override bool PIDActive { set { return; } }
1202 public override float PIDTau { set { return; } } 1193 public override float PIDTau { set { return; } }
1203 1194
@@ -1311,7 +1302,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1311 d.GeomDestroy(Shell); 1302 d.GeomDestroy(Shell);
1312 AvatarGeomAndBodyCreation(_position.X, _position.Y, 1303 AvatarGeomAndBodyCreation(_position.X, _position.Y,
1313 _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); 1304 _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor);
1314 Velocity = new PhysicsVector(0f, 0f, 0f); 1305 Velocity = Vector3.Zero;
1315 1306
1316 _parent_scene.geom_name_map[Shell] = m_name; 1307 _parent_scene.geom_name_map[Shell] = m_name;
1317 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 1308 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
@@ -1325,7 +1316,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1325 } 1316 }
1326 } 1317 }
1327 1318
1328 if (!m_taintPosition.IsIdentical(_position, 0.05f)) 1319 if (!m_taintPosition.ApproxEquals(_position, 0.05f))
1329 { 1320 {
1330 if (Body != IntPtr.Zero) 1321 if (Body != IntPtr.Zero)
1331 { 1322 {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
index 467eba0..4a802cd 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
@@ -1,16 +1,4 @@
1/* 1/*
2 * Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
3 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
4 * ODEPrim.cs contains methods dealing with Prim editing, Prim
5 * characteristics and Kinetic motion.
6 * ODEDynamics.cs contains methods dealing with Prim Physical motion
7 * (dynamics) and the associated settings. Old Linear and angular
8 * motors for dynamic motion have been replace with MoveLinear()
9 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
10 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
11 * switch between 'VEHICLE' parameter use and general dynamics
12 * settings use.
13 *
14 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
15 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
16 * 4 *
@@ -37,6 +25,19 @@
37 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 */ 26 */
39 27
28/* Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
29 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
30 * ODEPrim.cs contains methods dealing with Prim editing, Prim
31 * characteristics and Kinetic motion.
32 * ODEDynamics.cs contains methods dealing with Prim Physical motion
33 * (dynamics) and the associated settings. Old Linear and angular
34 * motors for dynamic motion have been replace with MoveLinear()
35 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
36 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
37 * switch between 'VEHICLE' parameter use and general dynamics
38 * settings use.
39 */
40
40using System; 41using System;
41using System.Collections.Generic; 42using System.Collections.Generic;
42using System.Reflection; 43using System.Reflection;
@@ -231,7 +232,7 @@ namespace OpenSim.Region.Physics.OdePlugin
231 232
232 }//end ProcessFloatVehicleParam 233 }//end ProcessFloatVehicleParam
233 234
234 internal void ProcessVectorVehicleParam(Vehicle pParam, PhysicsVector pValue) 235 internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue)
235 { 236 {
236 switch (pParam) 237 switch (pParam)
237 { 238 {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index f59f0ae..5ff9d32 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -1,18 +1,5 @@
1/* 1/* Copyright (c) Contributors, http://opensimulator.org/
2 * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
3 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
4 * ODEPrim.cs contains methods dealing with Prim editing, Prim
5 * characteristics and Kinetic motion.
6 * ODEDynamics.cs contains methods dealing with Prim Physical motion
7 * (dynamics) and the associated settings. Old Linear and angular
8 * motors for dynamic motion have been replace with MoveLinear()
9 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
10 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
11 * switch between 'VEHICLE' parameter use and general dynamics
12 * settings use.
13 * Copyright (c) Contributors, http://opensimulator.org/
14 * See CONTRIBUTORS.TXT for a full list of copyright holders. 2 * See CONTRIBUTORS.TXT for a full list of copyright holders.
15 *
16 * Redistribution and use in source and binary forms, with or without 3 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions are met: 4 * modification, are permitted provided that the following conditions are met:
18 * * Redistributions of source code must retain the above copyright 5 * * Redistributions of source code must retain the above copyright
@@ -35,6 +22,20 @@
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */ 24 */
25
26/*
27 * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
28 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
29 * ODEPrim.cs contains methods dealing with Prim editing, Prim
30 * characteristics and Kinetic motion.
31 * ODEDynamics.cs contains methods dealing with Prim Physical motion
32 * (dynamics) and the associated settings. Old Linear and angular
33 * motors for dynamic motion have been replace with MoveLinear()
34 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
35 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
36 * switch between 'VEHICLE' parameter use and general dynamics
37 * settings use.
38 */
38using System; 39using System;
39using System.Collections.Generic; 40using System.Collections.Generic;
40using System.Reflection; 41using System.Reflection;
@@ -56,44 +57,43 @@ namespace OpenSim.Region.Physics.OdePlugin
56 { 57 {
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 58 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 59
59 private PhysicsVector _position; 60 private Vector3 _position;
60 private PhysicsVector _velocity; 61 private Vector3 _velocity;
61 private PhysicsVector _torque = new PhysicsVector(0,0,0); 62 private Vector3 _torque;
62 private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); 63 private Vector3 m_lastVelocity;
63 private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f); 64 private Vector3 m_lastposition;
64 private Quaternion m_lastorientation = new Quaternion(); 65 private Quaternion m_lastorientation = new Quaternion();
65 private PhysicsVector m_rotationalVelocity; 66 private Vector3 m_rotationalVelocity;
66 private PhysicsVector _size; 67 private Vector3 _size;
67 private PhysicsVector _acceleration; 68 private Vector3 _acceleration;
68 // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f); 69 // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f);
69 private Quaternion _orientation; 70 private Quaternion _orientation;
70 private PhysicsVector m_taintposition; 71 private Vector3 m_taintposition;
71 private PhysicsVector m_taintsize; 72 private Vector3 m_taintsize;
72 private PhysicsVector m_taintVelocity = new PhysicsVector(0, 0, 0); 73 private Vector3 m_taintVelocity;
73 private PhysicsVector m_taintTorque = new PhysicsVector(0, 0, 0); 74 private Vector3 m_taintTorque;
74 private Quaternion m_taintrot; 75 private Quaternion m_taintrot;
75 private PhysicsVector m_angularlock = new PhysicsVector(1f, 1f, 1f); 76 private Vector3 m_angularlock = Vector3.One;
76 private PhysicsVector m_taintAngularLock = new PhysicsVector(1f, 1f, 1f); 77 private Vector3 m_taintAngularLock = Vector3.One;
77 private IntPtr Amotor = IntPtr.Zero; 78 private IntPtr Amotor = IntPtr.Zero;
78 79
79 private PhysicsVector m_PIDTarget = new PhysicsVector(0, 0, 0); 80 private Vector3 m_PIDTarget;
80 // private PhysicsVector m_taintPIDTarget = new PhysicsVector(0, 0, 0); 81 private float m_PIDTau;
81 private float m_PIDTau = 0f;
82 private float PID_D = 35f; 82 private float PID_D = 35f;
83 private float PID_G = 25f; 83 private float PID_G = 25f;
84 private bool m_usePID = false; 84 private bool m_usePID;
85 85
86 // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau), 86 // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau),
87 // and are for non-VEHICLES only. 87 // and are for non-VEHICLES only.
88 88
89 private float m_PIDHoverHeight = 0f; 89 private float m_PIDHoverHeight;
90 private float m_PIDHoverTau = 0f; 90 private float m_PIDHoverTau;
91 private bool m_useHoverPID = false; 91 private bool m_useHoverPID;
92 private PIDHoverType m_PIDHoverType = PIDHoverType.Ground; 92 private PIDHoverType m_PIDHoverType = PIDHoverType.Ground;
93 private float m_targetHoverHeight = 0f; 93 private float m_targetHoverHeight;
94 private float m_groundHeight = 0f; 94 private float m_groundHeight;
95 private float m_waterHeight = 0f; 95 private float m_waterHeight;
96 private float m_buoyancy = 0f; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. 96 private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
97 97
98 // private float m_tensor = 5f; 98 // private float m_tensor = 5f;
99 private int body_autodisable_frames = 20; 99 private int body_autodisable_frames = 20;
@@ -104,11 +104,11 @@ namespace OpenSim.Region.Physics.OdePlugin
104 | CollisionCategories.Body 104 | CollisionCategories.Body
105 | CollisionCategories.Character 105 | CollisionCategories.Character
106 ); 106 );
107 private bool m_taintshape = false; 107 private bool m_taintshape;
108 private bool m_taintPhysics = false; 108 private bool m_taintPhysics;
109 private bool m_collidesLand = true; 109 private bool m_collidesLand = true;
110 private bool m_collidesWater = false; 110 private bool m_collidesWater;
111 public bool m_returnCollisions = false; 111 public bool m_returnCollisions;
112 112
113 // Default we're a Geometry 113 // Default we're a Geometry
114 private CollisionCategories m_collisionCategories = (CollisionCategories.Geom); 114 private CollisionCategories m_collisionCategories = (CollisionCategories.Geom);
@@ -116,85 +116,83 @@ namespace OpenSim.Region.Physics.OdePlugin
116 // Default, Collide with Other Geometries, spaces and Bodies 116 // Default, Collide with Other Geometries, spaces and Bodies
117 private CollisionCategories m_collisionFlags = m_default_collisionFlags; 117 private CollisionCategories m_collisionFlags = m_default_collisionFlags;
118 118
119 public bool m_taintremove = false; 119 public bool m_taintremove;
120 public bool m_taintdisable = false; 120 public bool m_taintdisable;
121 public bool m_disabled = false; 121 public bool m_disabled;
122 public bool m_taintadd = false; 122 public bool m_taintadd;
123 public bool m_taintselected = false; 123 public bool m_taintselected;
124 public bool m_taintCollidesWater = false; 124 public bool m_taintCollidesWater;
125 125
126 public uint m_localID = 0; 126 public uint m_localID;
127 127
128 //public GCHandle gc; 128 //public GCHandle gc;
129 private CollisionLocker ode; 129 private CollisionLocker ode;
130 130
131 private bool m_taintforce = false; 131 private bool m_taintforce = false;
132 private bool m_taintaddangularforce = false; 132 private bool m_taintaddangularforce = false;
133 private PhysicsVector m_force = new PhysicsVector(0.0f, 0.0f, 0.0f); 133 private Vector3 m_force;
134 private List<PhysicsVector> m_forcelist = new List<PhysicsVector>(); 134 private List<Vector3> m_forcelist = new List<Vector3>();
135 private List<PhysicsVector> m_angularforcelist = new List<PhysicsVector>(); 135 private List<Vector3> m_angularforcelist = new List<Vector3>();
136 136
137 private IMesh _mesh; 137 private IMesh _mesh;
138 private PrimitiveBaseShape _pbs; 138 private PrimitiveBaseShape _pbs;
139 private OdeScene _parent_scene; 139 private OdeScene _parent_scene;
140 public IntPtr m_targetSpace = (IntPtr) 0; 140 public IntPtr m_targetSpace = IntPtr.Zero;
141 public IntPtr prim_geom; 141 public IntPtr prim_geom;
142 public IntPtr prev_geom; 142 public IntPtr prev_geom;
143 public IntPtr _triMeshData; 143 public IntPtr _triMeshData;
144 144
145 private IntPtr _linkJointGroup = (IntPtr)0; 145 private IntPtr _linkJointGroup = IntPtr.Zero;
146 private PhysicsActor _parent = null; 146 private PhysicsActor _parent;
147 private PhysicsActor m_taintparent = null; 147 private PhysicsActor m_taintparent;
148 148
149 private List<OdePrim> childrenPrim = new List<OdePrim>(); 149 private List<OdePrim> childrenPrim = new List<OdePrim>();
150 150
151 private bool iscolliding = false; 151 private bool iscolliding;
152 private bool m_isphysical = false; 152 private bool m_isphysical;
153 private bool m_isSelected = false; 153 private bool m_isSelected;
154 154
155 internal bool m_isVolumeDetect = false; // If true, this prim only detects collisions but doesn't collide actively 155 internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
156 156
157 private bool m_throttleUpdates = false; 157 private bool m_throttleUpdates;
158 private int throttleCounter = 0; 158 private int throttleCounter;
159 public int m_interpenetrationcount = 0; 159 public int m_interpenetrationcount;
160 public float m_collisionscore = 0; 160 public float m_collisionscore;
161 public int m_roundsUnderMotionThreshold = 0; 161 public int m_roundsUnderMotionThreshold;
162 private int m_crossingfailures = 0; 162 private int m_crossingfailures;
163 163
164 public bool outofBounds = false; 164 public bool outofBounds;
165 private float m_density = 10.000006836f; // Aluminum g/cm3; 165 private float m_density = 10.000006836f; // Aluminum g/cm3;
166 166
167 public bool _zeroFlag = false; 167 public bool _zeroFlag;
168 private bool m_lastUpdateSent = false; 168 private bool m_lastUpdateSent;
169 169
170 public IntPtr Body = (IntPtr) 0; 170 public IntPtr Body = IntPtr.Zero;
171 public String m_primName; 171 public String m_primName;
172// private String m_primName; 172 private Vector3 _target_velocity;
173 private PhysicsVector _target_velocity;
174 public d.Mass pMass; 173 public d.Mass pMass;
175 174
176 public int m_eventsubscription = 0; 175 public int m_eventsubscription;
177 private CollisionEventUpdate CollisionEventsThisFrame = null; 176 private CollisionEventUpdate CollisionEventsThisFrame;
178 177
179 private IntPtr m_linkJoint = (IntPtr)0; 178 private IntPtr m_linkJoint = IntPtr.Zero;
180 179
181 public volatile bool childPrim = false; 180 public volatile bool childPrim;
182 181
183 private ODEDynamics m_vehicle; 182 private ODEDynamics m_vehicle;
184 183
185 internal int m_material = (int)Material.Wood; 184 internal int m_material = (int)Material.Wood;
186 185
187 public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, 186 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
188 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) 187 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
189 { 188 {
190 _target_velocity = new PhysicsVector(0, 0, 0);
191 m_vehicle = new ODEDynamics(); 189 m_vehicle = new ODEDynamics();
192 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); 190 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
193 ode = dode; 191 ode = dode;
194 _velocity = new PhysicsVector(); 192 if (!pos.IsFinite())
195 if (!PhysicsVector.isFinite(pos))
196 { 193 {
197 pos = new PhysicsVector(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), parent_scene.GetTerrainHeightAtXY(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f)) + 0.5f); 194 pos = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f),
195 parent_scene.GetTerrainHeightAtXY(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f)) + 0.5f);
198 m_log.Warn("[PHYSICS]: Got nonFinite Object create Position"); 196 m_log.Warn("[PHYSICS]: Got nonFinite Object create Position");
199 } 197 }
200 _position = pos; 198 _position = pos;
@@ -209,9 +207,9 @@ namespace OpenSim.Region.Physics.OdePlugin
209 prim_geom = IntPtr.Zero; 207 prim_geom = IntPtr.Zero;
210 prev_geom = IntPtr.Zero; 208 prev_geom = IntPtr.Zero;
211 209
212 if (!PhysicsVector.isFinite(pos)) 210 if (!pos.IsFinite())
213 { 211 {
214 size = new PhysicsVector(0.5f, 0.5f, 0.5f); 212 size = new Vector3(0.5f, 0.5f, 0.5f);
215 m_log.Warn("[PHYSICS]: Got nonFinite Object create Size"); 213 m_log.Warn("[PHYSICS]: Got nonFinite Object create Size");
216 } 214 }
217 215
@@ -221,8 +219,6 @@ namespace OpenSim.Region.Physics.OdePlugin
221 219
222 _size = size; 220 _size = size;
223 m_taintsize = _size; 221 m_taintsize = _size;
224 _acceleration = new PhysicsVector();
225 m_rotationalVelocity = PhysicsVector.Zero;
226 222
227 if (!QuaternionIsFinite(rotation)) 223 if (!QuaternionIsFinite(rotation))
228 { 224 {
@@ -387,7 +383,7 @@ namespace OpenSim.Region.Physics.OdePlugin
387 m_disabled = false; 383 m_disabled = false;
388 384
389 // The body doesn't already have a finite rotation mode set here 385 // The body doesn't already have a finite rotation mode set here
390 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 386 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0.0f)) && _parent == null)
391 { 387 {
392 createAMotor(m_angularlock); 388 createAMotor(m_angularlock);
393 } 389 }
@@ -800,6 +796,8 @@ namespace OpenSim.Region.Physics.OdePlugin
800 m_collisionscore = 0; 796 m_collisionscore = 0;
801 } 797 }
802 798
799 private static Dictionary<IMesh, IntPtr> m_MeshToTriMeshMap = new Dictionary<IMesh, IntPtr>();
800
803 public void setMesh(OdeScene parent_scene, IMesh mesh) 801 public void setMesh(OdeScene parent_scene, IMesh mesh)
804 { 802 {
805 // This sleeper is there to moderate how long it takes between 803 // This sleeper is there to moderate how long it takes between
@@ -831,19 +829,24 @@ namespace OpenSim.Region.Physics.OdePlugin
831 mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage 829 mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage
832 830
833 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory 831 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
832 if (m_MeshToTriMeshMap.ContainsKey(mesh))
833 {
834 _triMeshData = m_MeshToTriMeshMap[mesh];
835 }
836 else
837 {
838 _triMeshData = d.GeomTriMeshDataCreate();
834 839
835 _triMeshData = d.GeomTriMeshDataCreate(); 840 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
836 841 d.GeomTriMeshDataPreprocess(_triMeshData);
837 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); 842 m_MeshToTriMeshMap[mesh] = _triMeshData;
838 d.GeomTriMeshDataPreprocess(_triMeshData); 843 }
839 844
840 _parent_scene.waitForSpaceUnlock(m_targetSpace); 845 _parent_scene.waitForSpaceUnlock(m_targetSpace);
841
842 try 846 try
843 { 847 {
844 if (prim_geom == IntPtr.Zero) 848 if (prim_geom == IntPtr.Zero)
845 { 849 {
846//Console.WriteLine(" setMesh 1");
847 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null)); 850 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
848 } 851 }
849 } 852 }
@@ -853,6 +856,7 @@ namespace OpenSim.Region.Physics.OdePlugin
853 return; 856 return;
854 } 857 }
855 858
859
856 // if (IsPhysical && Body == (IntPtr) 0) 860 // if (IsPhysical && Body == (IntPtr) 0)
857 // { 861 // {
858 // Recreate the body 862 // Recreate the body
@@ -873,7 +877,7 @@ namespace OpenSim.Region.Physics.OdePlugin
873 877
874 if (prim_geom != IntPtr.Zero) 878 if (prim_geom != IntPtr.Zero)
875 { 879 {
876 if (!_position.IsIdentical(m_taintposition,0f)) 880 if (!_position.ApproxEquals(m_taintposition, 0f))
877 changemove(timestep); 881 changemove(timestep);
878 882
879 if (m_taintrot != _orientation) 883 if (m_taintrot != _orientation)
@@ -898,7 +902,7 @@ namespace OpenSim.Region.Physics.OdePlugin
898 changePhysicsStatus(timestep); 902 changePhysicsStatus(timestep);
899 // 903 //
900 904
901 if (!_size.IsIdentical(m_taintsize,0)) 905 if (!_size.ApproxEquals(m_taintsize,0f))
902 changesize(timestep); 906 changesize(timestep);
903 // 907 //
904 908
@@ -912,7 +916,7 @@ namespace OpenSim.Region.Physics.OdePlugin
912 if (m_taintaddangularforce) 916 if (m_taintaddangularforce)
913 changeAddAngularForce(timestep); 917 changeAddAngularForce(timestep);
914 918
915 if (!m_taintTorque.IsIdentical(PhysicsVector.Zero, 0.001f)) 919 if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f))
916 changeSetTorque(timestep); 920 changeSetTorque(timestep);
917 921
918 if (m_taintdisable) 922 if (m_taintdisable)
@@ -921,7 +925,7 @@ namespace OpenSim.Region.Physics.OdePlugin
921 if (m_taintselected != m_isSelected) 925 if (m_taintselected != m_isSelected)
922 changeSelectedStatus(timestep); 926 changeSelectedStatus(timestep);
923 927
924 if (!m_taintVelocity.IsIdentical(PhysicsVector.Zero, 0.001f)) 928 if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f))
925 changevelocity(timestep); 929 changevelocity(timestep);
926 930
927 if (m_taintparent != _parent) 931 if (m_taintparent != _parent)
@@ -930,7 +934,7 @@ namespace OpenSim.Region.Physics.OdePlugin
930 if (m_taintCollidesWater != m_collidesWater) 934 if (m_taintCollidesWater != m_collidesWater)
931 changefloatonwater(timestep); 935 changefloatonwater(timestep);
932 936
933 if (!m_angularlock.IsIdentical(m_taintAngularLock,0)) 937 if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f))
934 changeAngularLock(timestep); 938 changeAngularLock(timestep);
935 939
936 } 940 }
@@ -950,7 +954,7 @@ namespace OpenSim.Region.Physics.OdePlugin
950 //If we have a parent then we're not authorative here 954 //If we have a parent then we're not authorative here
951 if (_parent == null) 955 if (_parent == null)
952 { 956 {
953 if (!m_taintAngularLock.IsIdentical(new PhysicsVector(1f,1f,1f), 0)) 957 if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f))
954 { 958 {
955 //d.BodySetFiniteRotationMode(Body, 0); 959 //d.BodySetFiniteRotationMode(Body, 0);
956 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z); 960 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z);
@@ -967,7 +971,7 @@ namespace OpenSim.Region.Physics.OdePlugin
967 } 971 }
968 } 972 }
969 // Store this for later in case we get turned into a separate body 973 // Store this for later in case we get turned into a separate body
970 m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z); 974 m_angularlock = m_taintAngularLock;
971 975
972 } 976 }
973 977
@@ -1111,7 +1115,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1111 prm.m_disabled = false; 1115 prm.m_disabled = false;
1112 1116
1113 // The body doesn't already have a finite rotation mode set here 1117 // The body doesn't already have a finite rotation mode set here
1114 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 1118 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
1115 { 1119 {
1116 prm.createAMotor(m_angularlock); 1120 prm.createAMotor(m_angularlock);
1117 } 1121 }
@@ -1154,7 +1158,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1154 m_disabled = false; 1158 m_disabled = false;
1155 1159
1156 // The body doesn't already have a finite rotation mode set here 1160 // The body doesn't already have a finite rotation mode set here
1157 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 1161 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
1158 { 1162 {
1159 createAMotor(m_angularlock); 1163 createAMotor(m_angularlock);
1160 } 1164 }
@@ -1338,7 +1342,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1338 m_taintshape = false; 1342 m_taintshape = false;
1339 m_taintforce = false; 1343 m_taintforce = false;
1340 m_taintdisable = false; 1344 m_taintdisable = false;
1341 m_taintVelocity = PhysicsVector.Zero; 1345 m_taintVelocity = Vector3.Zero;
1342 } 1346 }
1343 1347
1344 public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) 1348 public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh)
@@ -1567,7 +1571,7 @@ Console.WriteLine(" JointCreateFixed");
1567//Console.WriteLine("Move " + m_primName); 1571//Console.WriteLine("Move " + m_primName);
1568 if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009 1572 if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009
1569 // NON-'VEHICLES' are dealt with here 1573 // NON-'VEHICLES' are dealt with here
1570 if (d.BodyIsEnabled(Body) && !m_angularlock.IsIdentical(PhysicsVector.Zero, 0.003f)) 1574 if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f))
1571 { 1575 {
1572 d.Vector3 avel2 = d.BodyGetAngularVel(Body); 1576 d.Vector3 avel2 = d.BodyGetAngularVel(Body);
1573 if (m_angularlock.X == 1) 1577 if (m_angularlock.X == 1)
@@ -1624,7 +1628,7 @@ Console.WriteLine(" JointCreateFixed");
1624 1628
1625 d.Vector3 pos = d.BodyGetPosition(Body); 1629 d.Vector3 pos = d.BodyGetPosition(Body);
1626 _target_velocity = 1630 _target_velocity =
1627 new PhysicsVector( 1631 new Vector3(
1628 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), 1632 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1629 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep), 1633 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
1630 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep) 1634 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
@@ -1632,7 +1636,7 @@ Console.WriteLine(" JointCreateFixed");
1632 1636
1633 // if velocity is zero, use position control; otherwise, velocity control 1637 // if velocity is zero, use position control; otherwise, velocity control
1634 1638
1635 if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f)) 1639 if (_target_velocity.ApproxEquals(Vector3.Zero,0.1f))
1636 { 1640 {
1637 // keep track of where we stopped. No more slippin' & slidin' 1641 // keep track of where we stopped. No more slippin' & slidin'
1638 1642
@@ -1717,13 +1721,13 @@ Console.WriteLine(" JointCreateFixed");
1717 1721
1718 1722
1719 _target_velocity = 1723 _target_velocity =
1720 new PhysicsVector(0.0f, 0.0f, 1724 new Vector3(0.0f, 0.0f,
1721 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep) 1725 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
1722 ); 1726 );
1723 1727
1724 // if velocity is zero, use position control; otherwise, velocity control 1728 // if velocity is zero, use position control; otherwise, velocity control
1725 1729
1726 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) 1730 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
1727 { 1731 {
1728 // keep track of where we stopped. No more slippin' & slidin' 1732 // keep track of where we stopped. No more slippin' & slidin'
1729 1733
@@ -1812,7 +1816,7 @@ Console.WriteLine(" JointCreateFixed");
1812 d.BodySetQuaternion(Body, ref myrot); 1816 d.BodySetQuaternion(Body, ref myrot);
1813 if (m_isphysical) 1817 if (m_isphysical)
1814 { 1818 {
1815 if (!m_angularlock.IsIdentical(new PhysicsVector(1, 1, 1), 0)) 1819 if (!m_angularlock.ApproxEquals(Vector3.One, 0f))
1816 createAMotor(m_angularlock); 1820 createAMotor(m_angularlock);
1817 } 1821 }
1818 } 1822 }
@@ -2121,7 +2125,7 @@ Console.WriteLine(" JointCreateFixed");
2121 //m_log.Info("[PHYSICS]: dequeing forcelist"); 2125 //m_log.Info("[PHYSICS]: dequeing forcelist");
2122 if (IsPhysical) 2126 if (IsPhysical)
2123 { 2127 {
2124 PhysicsVector iforce = new PhysicsVector(); 2128 Vector3 iforce = Vector3.Zero;
2125 for (int i = 0; i < m_forcelist.Count; i++) 2129 for (int i = 0; i < m_forcelist.Count; i++)
2126 { 2130 {
2127 iforce = iforce + (m_forcelist[i] * 100); 2131 iforce = iforce + (m_forcelist[i] * 100);
@@ -2151,8 +2155,8 @@ Console.WriteLine(" JointCreateFixed");
2151 d.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z); 2155 d.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z);
2152 } 2156 }
2153 } 2157 }
2154 2158
2155 m_taintTorque = new PhysicsVector(0, 0, 0); 2159 m_taintTorque = Vector3.Zero;
2156 } 2160 }
2157 2161
2158 public void changeAddAngularForce(float timestamp) 2162 public void changeAddAngularForce(float timestamp)
@@ -2164,7 +2168,7 @@ Console.WriteLine(" JointCreateFixed");
2164 //m_log.Info("[PHYSICS]: dequeing forcelist"); 2168 //m_log.Info("[PHYSICS]: dequeing forcelist");
2165 if (IsPhysical) 2169 if (IsPhysical)
2166 { 2170 {
2167 PhysicsVector iforce = new PhysicsVector(); 2171 Vector3 iforce = Vector3.Zero;
2168 for (int i = 0; i < m_angularforcelist.Count; i++) 2172 for (int i = 0; i < m_angularforcelist.Count; i++)
2169 { 2173 {
2170 iforce = iforce + (m_angularforcelist[i] * 100); 2174 iforce = iforce + (m_angularforcelist[i] * 100);
@@ -2198,7 +2202,7 @@ Console.WriteLine(" JointCreateFixed");
2198 2202
2199 //resetCollisionAccounting(); 2203 //resetCollisionAccounting();
2200 } 2204 }
2201 m_taintVelocity = PhysicsVector.Zero; 2205 m_taintVelocity = Vector3.Zero;
2202 } 2206 }
2203 2207
2204 public override bool IsPhysical 2208 public override bool IsPhysical
@@ -2207,7 +2211,7 @@ Console.WriteLine(" JointCreateFixed");
2207 set { 2211 set {
2208 m_isphysical = value; 2212 m_isphysical = value;
2209 if (!m_isphysical) // Zero the remembered last velocity 2213 if (!m_isphysical) // Zero the remembered last velocity
2210 m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); 2214 m_lastVelocity = Vector3.Zero;
2211 } 2215 }
2212 } 2216 }
2213 2217
@@ -2252,7 +2256,7 @@ Console.WriteLine(" JointCreateFixed");
2252 get { return _zeroFlag; } 2256 get { return _zeroFlag; }
2253 } 2257 }
2254 2258
2255 public override PhysicsVector Position 2259 public override Vector3 Position
2256 { 2260 {
2257 get { return _position; } 2261 get { return _position; }
2258 2262
@@ -2261,12 +2265,12 @@ Console.WriteLine(" JointCreateFixed");
2261 } 2265 }
2262 } 2266 }
2263 2267
2264 public override PhysicsVector Size 2268 public override Vector3 Size
2265 { 2269 {
2266 get { return _size; } 2270 get { return _size; }
2267 set 2271 set
2268 { 2272 {
2269 if (PhysicsVector.isFinite(value)) 2273 if (value.IsFinite())
2270 { 2274 {
2271 _size = value; 2275 _size = value;
2272 } 2276 }
@@ -2282,13 +2286,13 @@ Console.WriteLine(" JointCreateFixed");
2282 get { return CalculateMass(); } 2286 get { return CalculateMass(); }
2283 } 2287 }
2284 2288
2285 public override PhysicsVector Force 2289 public override Vector3 Force
2286 { 2290 {
2287 //get { return PhysicsVector.Zero; } 2291 //get { return Vector3.Zero; }
2288 get { return m_force; } 2292 get { return m_force; }
2289 set 2293 set
2290 { 2294 {
2291 if (PhysicsVector.isFinite(value)) 2295 if (value.IsFinite())
2292 { 2296 {
2293 m_force = value; 2297 m_force = value;
2294 } 2298 }
@@ -2310,7 +2314,7 @@ Console.WriteLine(" JointCreateFixed");
2310 m_vehicle.ProcessFloatVehicleParam((Vehicle) param, value); 2314 m_vehicle.ProcessFloatVehicleParam((Vehicle) param, value);
2311 } 2315 }
2312 2316
2313 public override void VehicleVectorParam(int param, PhysicsVector value) 2317 public override void VehicleVectorParam(int param, Vector3 value)
2314 { 2318 {
2315 m_vehicle.ProcessVectorVehicleParam((Vehicle) param, value); 2319 m_vehicle.ProcessVectorVehicleParam((Vehicle) param, value);
2316 } 2320 }
@@ -2328,14 +2332,14 @@ Console.WriteLine(" JointCreateFixed");
2328 } 2332 }
2329 } 2333 }
2330 2334
2331 public override PhysicsVector CenterOfMass 2335 public override Vector3 CenterOfMass
2332 { 2336 {
2333 get { return PhysicsVector.Zero; } 2337 get { return Vector3.Zero; }
2334 } 2338 }
2335 2339
2336 public override PhysicsVector GeometricCenter 2340 public override Vector3 GeometricCenter
2337 { 2341 {
2338 get { return PhysicsVector.Zero; } 2342 get { return Vector3.Zero; }
2339 } 2343 }
2340 2344
2341 public override PrimitiveBaseShape Shape 2345 public override PrimitiveBaseShape Shape
@@ -2347,13 +2351,13 @@ Console.WriteLine(" JointCreateFixed");
2347 } 2351 }
2348 } 2352 }
2349 2353
2350 public override PhysicsVector Velocity 2354 public override Vector3 Velocity
2351 { 2355 {
2352 get 2356 get
2353 { 2357 {
2354 // Averate previous velocity with the new one so 2358 // Averate previous velocity with the new one so
2355 // client object interpolation works a 'little' better 2359 // client object interpolation works a 'little' better
2356 PhysicsVector returnVelocity = new PhysicsVector(); 2360 Vector3 returnVelocity = Vector3.Zero;
2357 returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2; 2361 returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2;
2358 returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y)/2; 2362 returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y)/2;
2359 returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2; 2363 returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2;
@@ -2361,7 +2365,7 @@ Console.WriteLine(" JointCreateFixed");
2361 } 2365 }
2362 set 2366 set
2363 { 2367 {
2364 if (PhysicsVector.isFinite(value)) 2368 if (value.IsFinite())
2365 { 2369 {
2366 _velocity = value; 2370 _velocity = value;
2367 2371
@@ -2376,19 +2380,19 @@ Console.WriteLine(" JointCreateFixed");
2376 } 2380 }
2377 } 2381 }
2378 2382
2379 public override PhysicsVector Torque 2383 public override Vector3 Torque
2380 { 2384 {
2381 get 2385 get
2382 { 2386 {
2383 if (!m_isphysical || Body == IntPtr.Zero) 2387 if (!m_isphysical || Body == IntPtr.Zero)
2384 return new PhysicsVector(0,0,0); 2388 return Vector3.Zero;
2385 2389
2386 return _torque; 2390 return _torque;
2387 } 2391 }
2388 2392
2389 set 2393 set
2390 { 2394 {
2391 if (PhysicsVector.isFinite(value)) 2395 if (value.IsFinite())
2392 { 2396 {
2393 m_taintTorque = value; 2397 m_taintTorque = value;
2394 _parent_scene.AddPhysicsActorTaint(this); 2398 _parent_scene.AddPhysicsActorTaint(this);
@@ -2440,20 +2444,20 @@ Console.WriteLine(" JointCreateFixed");
2440 return true; 2444 return true;
2441 } 2445 }
2442 2446
2443 public override PhysicsVector Acceleration 2447 public override Vector3 Acceleration
2444 { 2448 {
2445 get { return _acceleration; } 2449 get { return _acceleration; }
2446 } 2450 }
2447 2451
2448 2452
2449 public void SetAcceleration(PhysicsVector accel) 2453 public void SetAcceleration(Vector3 accel)
2450 { 2454 {
2451 _acceleration = accel; 2455 _acceleration = accel;
2452 } 2456 }
2453 2457
2454 public override void AddForce(PhysicsVector force, bool pushforce) 2458 public override void AddForce(Vector3 force, bool pushforce)
2455 { 2459 {
2456 if (PhysicsVector.isFinite(force)) 2460 if (force.IsFinite())
2457 { 2461 {
2458 m_forcelist.Add(force); 2462 m_forcelist.Add(force);
2459 m_taintforce = true; 2463 m_taintforce = true;
@@ -2465,9 +2469,9 @@ Console.WriteLine(" JointCreateFixed");
2465 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); 2469 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString());
2466 } 2470 }
2467 2471
2468 public override void AddAngularForce(PhysicsVector force, bool pushforce) 2472 public override void AddAngularForce(Vector3 force, bool pushforce)
2469 { 2473 {
2470 if (PhysicsVector.isFinite(force)) 2474 if (force.IsFinite())
2471 { 2475 {
2472 m_angularforcelist.Add(force); 2476 m_angularforcelist.Add(force);
2473 m_taintaddangularforce = true; 2477 m_taintaddangularforce = true;
@@ -2478,23 +2482,23 @@ Console.WriteLine(" JointCreateFixed");
2478 } 2482 }
2479 } 2483 }
2480 2484
2481 public override PhysicsVector RotationalVelocity 2485 public override Vector3 RotationalVelocity
2482 { 2486 {
2483 get 2487 get
2484 { 2488 {
2485 PhysicsVector pv = new PhysicsVector(0, 0, 0); 2489 Vector3 pv = Vector3.Zero;
2486 if (_zeroFlag) 2490 if (_zeroFlag)
2487 return pv; 2491 return pv;
2488 m_lastUpdateSent = false; 2492 m_lastUpdateSent = false;
2489 2493
2490 if (m_rotationalVelocity.IsIdentical(pv, 0.2f)) 2494 if (m_rotationalVelocity.ApproxEquals(pv, 0.2f))
2491 return pv; 2495 return pv;
2492 2496
2493 return m_rotationalVelocity; 2497 return m_rotationalVelocity;
2494 } 2498 }
2495 set 2499 set
2496 { 2500 {
2497 if (PhysicsVector.isFinite(value)) 2501 if (value.IsFinite())
2498 { 2502 {
2499 m_rotationalVelocity = value; 2503 m_rotationalVelocity = value;
2500 } 2504 }
@@ -2535,16 +2539,16 @@ Console.WriteLine(" JointCreateFixed");
2535 m_taintparent = null; 2539 m_taintparent = null;
2536 } 2540 }
2537 2541
2538 public override void LockAngularMotion(PhysicsVector axis) 2542 public override void LockAngularMotion(Vector3 axis)
2539 { 2543 {
2540 // reverse the zero/non zero values for ODE. 2544 // reverse the zero/non zero values for ODE.
2541 if (PhysicsVector.isFinite(axis)) 2545 if (axis.IsFinite())
2542 { 2546 {
2543 axis.X = (axis.X > 0) ? 1f : 0f; 2547 axis.X = (axis.X > 0) ? 1f : 0f;
2544 axis.Y = (axis.Y > 0) ? 1f : 0f; 2548 axis.Y = (axis.Y > 0) ? 1f : 0f;
2545 axis.Z = (axis.Z > 0) ? 1f : 0f; 2549 axis.Z = (axis.Z > 0) ? 1f : 0f;
2546 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); 2550 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z);
2547 m_taintAngularLock = new PhysicsVector(axis.X, axis.Y, axis.Z); 2551 m_taintAngularLock = axis;
2548 } 2552 }
2549 else 2553 else
2550 { 2554 {
@@ -2557,7 +2561,7 @@ Console.WriteLine(" JointCreateFixed");
2557 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 2561 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
2558 if (_parent == null) 2562 if (_parent == null)
2559 { 2563 {
2560 PhysicsVector pv = new PhysicsVector(0, 0, 0); 2564 Vector3 pv = Vector3.Zero;
2561 bool lastZeroFlag = _zeroFlag; 2565 bool lastZeroFlag = _zeroFlag;
2562 if (Body != (IntPtr)0) // FIXME -> or if it is a joint 2566 if (Body != (IntPtr)0) // FIXME -> or if it is a joint
2563 { 2567 {
@@ -2566,9 +2570,9 @@ Console.WriteLine(" JointCreateFixed");
2566 d.Vector3 vel = d.BodyGetLinearVel(Body); 2570 d.Vector3 vel = d.BodyGetLinearVel(Body);
2567 d.Vector3 rotvel = d.BodyGetAngularVel(Body); 2571 d.Vector3 rotvel = d.BodyGetAngularVel(Body);
2568 d.Vector3 torque = d.BodyGetTorque(Body); 2572 d.Vector3 torque = d.BodyGetTorque(Body);
2569 _torque.setValues(torque.X, torque.Y, torque.Z); 2573 _torque = new Vector3(torque.X, torque.Y, torque.Z);
2570 PhysicsVector l_position = new PhysicsVector(); 2574 Vector3 l_position = Vector3.Zero;
2571 Quaternion l_orientation = new Quaternion(); 2575 Quaternion l_orientation = Quaternion.Identity;
2572 2576
2573 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 2577 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
2574 //if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } 2578 //if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
@@ -2703,16 +2707,16 @@ Console.WriteLine(" JointCreateFixed");
2703 _velocity.Z = vel.Z; 2707 _velocity.Z = vel.Z;
2704 2708
2705 _acceleration = ((_velocity - m_lastVelocity) / 0.1f); 2709 _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
2706 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f); 2710 _acceleration = new Vector3(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f);
2707 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); 2711 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
2708 2712
2709 if (_velocity.IsIdentical(pv, 0.5f)) 2713 if (_velocity.ApproxEquals(pv, 0.5f))
2710 { 2714 {
2711 m_rotationalVelocity = pv; 2715 m_rotationalVelocity = pv;
2712 } 2716 }
2713 else 2717 else
2714 { 2718 {
2715 m_rotationalVelocity.setValues(rotvel.X, rotvel.Y, rotvel.Z); 2719 m_rotationalVelocity = new Vector3(rotvel.X, rotvel.Y, rotvel.Z);
2716 } 2720 }
2717 2721
2718 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString()); 2722 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString());
@@ -2760,15 +2764,15 @@ Console.WriteLine(" JointCreateFixed");
2760 } 2764 }
2761 } 2765 }
2762 2766
2763 public override void SetMomentum(PhysicsVector momentum) 2767 public override void SetMomentum(Vector3 momentum)
2764 { 2768 {
2765 } 2769 }
2766 2770
2767 public override PhysicsVector PIDTarget 2771 public override Vector3 PIDTarget
2768 { 2772 {
2769 set 2773 set
2770 { 2774 {
2771 if (PhysicsVector.isFinite(value)) 2775 if (value.IsFinite())
2772 { 2776 {
2773 m_PIDTarget = value; 2777 m_PIDTarget = value;
2774 } 2778 }
@@ -2784,7 +2788,7 @@ Console.WriteLine(" JointCreateFixed");
2784 public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } } 2788 public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } }
2785 public override float PIDHoverTau { set { m_PIDHoverTau = value; } } 2789 public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
2786 2790
2787 private void createAMotor(PhysicsVector axis) 2791 private void createAMotor(Vector3 axis)
2788 { 2792 {
2789 if (Body == IntPtr.Zero) 2793 if (Body == IntPtr.Zero)
2790 return; 2794 return;
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 0a065be..2f42646 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -239,6 +239,7 @@ namespace OpenSim.Region.Physics.OdePlugin
239 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); 239 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>();
240 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); 240 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
241 private readonly HashSet<OdePrim> _taintedPrimH = new HashSet<OdePrim>(); 241 private readonly HashSet<OdePrim> _taintedPrimH = new HashSet<OdePrim>();
242 private readonly Object _taintedPrimLock = new Object();
242 private readonly List<OdePrim> _taintedPrimL = new List<OdePrim>(); 243 private readonly List<OdePrim> _taintedPrimL = new List<OdePrim>();
243 private readonly HashSet<OdeCharacter> _taintedActors = new HashSet<OdeCharacter>(); 244 private readonly HashSet<OdeCharacter> _taintedActors = new HashSet<OdeCharacter>();
244 private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>(); 245 private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>();
@@ -683,7 +684,7 @@ namespace OpenSim.Region.Physics.OdePlugin
683 /// </summary> 684 /// </summary>
684 /// <param name="pos"></param> 685 /// <param name="pos"></param>
685 /// <returns>Returns which split up space the given position is in.</returns> 686 /// <returns>Returns which split up space the given position is in.</returns>
686 public string whichspaceamIin(PhysicsVector pos) 687 public string whichspaceamIin(Vector3 pos)
687 { 688 {
688 return calculateSpaceForGeom(pos).ToString(); 689 return calculateSpaceForGeom(pos).ToString();
689 } 690 }
@@ -962,7 +963,7 @@ namespace OpenSim.Region.Physics.OdePlugin
962 963
963 //p2.CollidingObj = true; 964 //p2.CollidingObj = true;
964 contacts[i].depth = 0.00000003f; 965 contacts[i].depth = 0.00000003f;
965 p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 0.5f); 966 p2.Velocity = p2.Velocity + new Vector3(0f, 0f, 0.5f);
966 contacts[i].pos = 967 contacts[i].pos =
967 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), 968 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2),
968 contacts[i].pos.Y + (p1.Size.Y/2), 969 contacts[i].pos.Y + (p1.Size.Y/2),
@@ -980,7 +981,7 @@ namespace OpenSim.Region.Physics.OdePlugin
980 981
981 //p2.CollidingObj = true; 982 //p2.CollidingObj = true;
982 contacts[i].depth = 0.00000003f; 983 contacts[i].depth = 0.00000003f;
983 p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 0.5f); 984 p1.Velocity = p1.Velocity + new Vector3(0f, 0f, 0.5f);
984 contacts[i].pos = 985 contacts[i].pos =
985 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), 986 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2),
986 contacts[i].pos.Y + (p1.Size.Y/2), 987 contacts[i].pos.Y + (p1.Size.Y/2),
@@ -1645,9 +1646,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1645 1646
1646 #region Add/Remove Entities 1647 #region Add/Remove Entities
1647 1648
1648 public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) 1649 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
1649 { 1650 {
1650 PhysicsVector pos = new PhysicsVector(); 1651 Vector3 pos;
1651 pos.X = position.X; 1652 pos.X = position.X;
1652 pos.Y = position.Y; 1653 pos.Y = position.Y;
1653 pos.Z = position.Z; 1654 pos.Z = position.Z;
@@ -1697,18 +1698,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1697 1698
1698 } 1699 }
1699 1700
1700 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, 1701 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
1701 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) 1702 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
1702 { 1703 {
1703 1704
1704 PhysicsVector pos = new PhysicsVector(position.X, position.Y, position.Z); 1705 Vector3 pos = position;
1705 //pos.X = position.X; 1706 Vector3 siz = size;
1706 //pos.Y = position.Y;
1707 //pos.Z = position.Z;
1708 PhysicsVector siz = new PhysicsVector();
1709 siz.X = size.X;
1710 siz.Y = size.Y;
1711 siz.Z = size.Z;
1712 Quaternion rot = rotation; 1707 Quaternion rot = rotation;
1713 1708
1714 OdePrim newPrim; 1709 OdePrim newPrim;
@@ -1735,14 +1730,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1735 } 1730 }
1736 } 1731 }
1737 1732
1738 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 1733 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1739 PhysicsVector size, Quaternion rotation) //To be removed 1734 Vector3 size, Quaternion rotation) //To be removed
1740 { 1735 {
1741 return AddPrimShape(primName, pbs, position, size, rotation, false); 1736 return AddPrimShape(primName, pbs, position, size, rotation, false);
1742 } 1737 }
1743 1738
1744 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 1739 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1745 PhysicsVector size, Quaternion rotation, bool isPhysical) 1740 Vector3 size, Quaternion rotation, bool isPhysical)
1746 { 1741 {
1747 PhysicsActor result; 1742 PhysicsActor result;
1748 IMesh mesh = null; 1743 IMesh mesh = null;
@@ -1975,7 +1970,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1975 // this joint will just be added to a waiting list that is NOT processed during the main 1970 // this joint will just be added to a waiting list that is NOT processed during the main
1976 // Simulate() loop (to avoid deadlocks). After Simulate() is finished, we handle unprocessed joint requests. 1971 // Simulate() loop (to avoid deadlocks). After Simulate() is finished, we handle unprocessed joint requests.
1977 1972
1978 public override PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, PhysicsVector position, 1973 public override PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, Vector3 position,
1979 Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation) 1974 Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation)
1980 1975
1981 { 1976 {
@@ -1983,7 +1978,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1983 OdePhysicsJoint joint = new OdePhysicsJoint(); 1978 OdePhysicsJoint joint = new OdePhysicsJoint();
1984 joint.ObjectNameInScene = objectNameInScene; 1979 joint.ObjectNameInScene = objectNameInScene;
1985 joint.Type = jointType; 1980 joint.Type = jointType;
1986 joint.Position = new PhysicsVector(position.X, position.Y, position.Z); 1981 joint.Position = position;
1987 joint.Rotation = rotation; 1982 joint.Rotation = rotation;
1988 joint.RawParams = parms; 1983 joint.RawParams = parms;
1989 joint.BodyNames = new List<string>(bodyNames); 1984 joint.BodyNames = new List<string>(bodyNames);
@@ -2035,7 +2030,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2035 } 2030 }
2036 2031
2037 // normally called from within OnJointMoved, which is called from within a lock (OdeLock) 2032 // normally called from within OnJointMoved, which is called from within a lock (OdeLock)
2038 public override PhysicsVector GetJointAnchor(PhysicsJoint joint) 2033 public override Vector3 GetJointAnchor(PhysicsJoint joint)
2039 { 2034 {
2040 Debug.Assert(joint.IsInPhysicsEngine); 2035 Debug.Assert(joint.IsInPhysicsEngine);
2041 d.Vector3 pos = new d.Vector3(); 2036 d.Vector3 pos = new d.Vector3();
@@ -2057,14 +2052,14 @@ namespace OpenSim.Region.Physics.OdePlugin
2057 break; 2052 break;
2058 } 2053 }
2059 } 2054 }
2060 return new PhysicsVector(pos.X, pos.Y, pos.Z); 2055 return new Vector3(pos.X, pos.Y, pos.Z);
2061 } 2056 }
2062 2057
2063 // normally called from within OnJointMoved, which is called from within a lock (OdeLock) 2058 // normally called from within OnJointMoved, which is called from within a lock (OdeLock)
2064 // WARNING: ODE sometimes returns <0,0,0> as the joint axis! Therefore this function 2059 // WARNING: ODE sometimes returns <0,0,0> as the joint axis! Therefore this function
2065 // appears to be unreliable. Fortunately we can compute the joint axis ourselves by 2060 // appears to be unreliable. Fortunately we can compute the joint axis ourselves by
2066 // keeping track of the joint's original orientation relative to one of the involved bodies. 2061 // keeping track of the joint's original orientation relative to one of the involved bodies.
2067 public override PhysicsVector GetJointAxis(PhysicsJoint joint) 2062 public override Vector3 GetJointAxis(PhysicsJoint joint)
2068 { 2063 {
2069 Debug.Assert(joint.IsInPhysicsEngine); 2064 Debug.Assert(joint.IsInPhysicsEngine);
2070 d.Vector3 axis = new d.Vector3(); 2065 d.Vector3 axis = new d.Vector3();
@@ -2086,7 +2081,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2086 break; 2081 break;
2087 } 2082 }
2088 } 2083 }
2089 return new PhysicsVector(axis.X, axis.Y, axis.Z); 2084 return new Vector3(axis.X, axis.Y, axis.Z);
2090 } 2085 }
2091 2086
2092 2087
@@ -2254,7 +2249,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2254 /// <param name="pos">the position that the geom moved to</param> 2249 /// <param name="pos">the position that the geom moved to</param>
2255 /// <param name="currentspace">a pointer to the space it was in before it was moved.</param> 2250 /// <param name="currentspace">a pointer to the space it was in before it was moved.</param>
2256 /// <returns>a pointer to the new space it's in</returns> 2251 /// <returns>a pointer to the new space it's in</returns>
2257 public IntPtr recalculateSpaceForGeom(IntPtr geom, PhysicsVector pos, IntPtr currentspace) 2252 public IntPtr recalculateSpaceForGeom(IntPtr geom, Vector3 pos, IntPtr currentspace)
2258 { 2253 {
2259 // Called from setting the Position and Size of an ODEPrim so 2254 // Called from setting the Position and Size of an ODEPrim so
2260 // it's already in locked space. 2255 // it's already in locked space.
@@ -2401,7 +2396,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2401 /// </summary> 2396 /// </summary>
2402 /// <param name="pos"></param> 2397 /// <param name="pos"></param>
2403 /// <returns>a pointer to the space. This could be a new space or reused space.</returns> 2398 /// <returns>a pointer to the space. This could be a new space or reused space.</returns>
2404 public IntPtr calculateSpaceForGeom(PhysicsVector pos) 2399 public IntPtr calculateSpaceForGeom(Vector3 pos)
2405 { 2400 {
2406 int[] xyspace = calculateSpaceArrayItemFromPos(pos); 2401 int[] xyspace = calculateSpaceArrayItemFromPos(pos);
2407 //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); 2402 //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString());
@@ -2413,7 +2408,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2413 /// </summary> 2408 /// </summary>
2414 /// <param name="pos"></param> 2409 /// <param name="pos"></param>
2415 /// <returns>an array item based on the position</returns> 2410 /// <returns>an array item based on the position</returns>
2416 public int[] calculateSpaceArrayItemFromPos(PhysicsVector pos) 2411 public int[] calculateSpaceArrayItemFromPos(Vector3 pos)
2417 { 2412 {
2418 int[] returnint = new int[2]; 2413 int[] returnint = new int[2];
2419 2414
@@ -2572,7 +2567,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2572 if (prim is OdePrim) 2567 if (prim is OdePrim)
2573 { 2568 {
2574 OdePrim taintedprim = ((OdePrim) prim); 2569 OdePrim taintedprim = ((OdePrim) prim);
2575 lock (_taintedPrimH) 2570 lock (_taintedPrimLock)
2576 { 2571 {
2577 if (!(_taintedPrimH.Contains(taintedprim))) 2572 if (!(_taintedPrimH.Contains(taintedprim)))
2578 { 2573 {
@@ -2700,24 +2695,28 @@ namespace OpenSim.Region.Physics.OdePlugin
2700 // Modify other objects in the scene. 2695 // Modify other objects in the scene.
2701 processedtaints = false; 2696 processedtaints = false;
2702 2697
2703 lock (_taintedPrimL) 2698 lock (_taintedPrimLock)
2704 { 2699 {
2705 foreach (OdePrim prim in _taintedPrimL) 2700 foreach (OdePrim prim in _taintedPrimL)
2706 { 2701 {
2707
2708
2709 if (prim.m_taintremove) 2702 if (prim.m_taintremove)
2710 { 2703 {
2711//Console.WriteLine("Simulate calls RemovePrimThreadLocked"); 2704 //Console.WriteLine("Simulate calls RemovePrimThreadLocked");
2712 RemovePrimThreadLocked(prim); 2705 RemovePrimThreadLocked(prim);
2713 } 2706 }
2714 else 2707 else
2715 { 2708 {
2716//Console.WriteLine("Simulate calls ProcessTaints"); 2709 //Console.WriteLine("Simulate calls ProcessTaints");
2717 prim.ProcessTaints(timeStep); 2710 prim.ProcessTaints(timeStep);
2718 } 2711 }
2719 processedtaints = true; 2712 processedtaints = true;
2720 prim.m_collisionscore = 0; 2713 prim.m_collisionscore = 0;
2714
2715 // This loop can block up the Heartbeat for a very long time on large regions.
2716 // We need to let the Watchdog know that the Heartbeat is not dead
2717 // NOTE: This is currently commented out, but if things like OAR loading are
2718 // timing the heartbeat out we will need to uncomment it
2719 //Watchdog.UpdateThread();
2721 } 2720 }
2722 2721
2723 if (SupportsNINJAJoints) 2722 if (SupportsNINJAJoints)
diff --git a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
index cdd38c4..69e2d03 100644
--- a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
+++ b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
@@ -76,8 +76,8 @@ namespace OpenSim.Region.Physics.OdePlugin
76 public void CreateAndDropPhysicalCube() 76 public void CreateAndDropPhysicalCube()
77 { 77 {
78 PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox(); 78 PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox();
79 PhysicsVector position = new PhysicsVector(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); 79 Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f);
80 PhysicsVector size = new PhysicsVector(0.5f, 0.5f, 0.5f); 80 Vector3 size = new Vector3(0.5f, 0.5f, 0.5f);
81 Quaternion rot = Quaternion.Identity; 81 Quaternion rot = Quaternion.Identity;
82 PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true); 82 PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true);
83 OdePrim oprim = (OdePrim)prim; 83 OdePrim oprim = (OdePrim)prim;