aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletDotNETPlugin
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletDotNETPlugin')
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs96
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs257
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs12
3 files changed, 178 insertions, 187 deletions
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
index 8da9687..5ed3b14 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
@@ -60,15 +60,15 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
60 private btQuaternion m_bodyOrientation; 60 private btQuaternion m_bodyOrientation;
61 private btDefaultMotionState m_bodyMotionState; 61 private btDefaultMotionState m_bodyMotionState;
62 private btGeneric6DofConstraint m_aMotor; 62 private btGeneric6DofConstraint m_aMotor;
63 // private PhysicsVector m_movementComparision; 63 // private Vector3 m_movementComparision;
64 private PhysicsVector m_position; 64 private Vector3 m_position;
65 private PhysicsVector m_zeroPosition; 65 private Vector3 m_zeroPosition;
66 private bool m_zeroFlag = false; 66 private bool m_zeroFlag = false;
67 private bool m_lastUpdateSent = false; 67 private bool m_lastUpdateSent = false;
68 private PhysicsVector m_velocity; 68 private Vector3 m_velocity;
69 private PhysicsVector m_target_velocity; 69 private Vector3 m_target_velocity;
70 private PhysicsVector m_acceleration; 70 private Vector3 m_acceleration;
71 private PhysicsVector m_rotationalVelocity; 71 private Vector3 m_rotationalVelocity;
72 private bool m_pidControllerActive = true; 72 private bool m_pidControllerActive = true;
73 public float PID_D = 80.0f; 73 public float PID_D = 80.0f;
74 public float PID_P = 90.0f; 74 public float PID_P = 90.0f;
@@ -96,8 +96,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
96 private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes. 96 private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes.
97 private bool m_taintRemove = false; 97 private bool m_taintRemove = false;
98 // private bool m_taintedPosition = false; 98 // private bool m_taintedPosition = false;
99 // private PhysicsVector m_taintedPosition_value; 99 // private Vector3 m_taintedPosition_value;
100 private PhysicsVector m_taintedForce; 100 private Vector3 m_taintedForce;
101 101
102 private float m_buoyancy = 0f; 102 private float m_buoyancy = 0f;
103 103
@@ -115,14 +115,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
115 public int m_eventsubscription = 0; 115 public int m_eventsubscription = 0;
116 // private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); 116 // private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
117 117
118 public BulletDotNETCharacter(string avName, BulletDotNETScene parent_scene, PhysicsVector pos, PhysicsVector size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) 118 public BulletDotNETCharacter(string avName, BulletDotNETScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor)
119 { 119 {
120 m_taintedForce = new PhysicsVector();
121 m_velocity = new PhysicsVector();
122 m_target_velocity = new PhysicsVector();
123 m_position = pos; 120 m_position = pos;
124 m_zeroPosition = new PhysicsVector(pos.X, pos.Y, pos.Z); // this is a class, not a struct. Must make new, or m_zeroPosition will == position regardless 121 m_zeroPosition = pos;
125 m_acceleration = new PhysicsVector();
126 m_parent_scene = parent_scene; 122 m_parent_scene = parent_scene;
127 PID_D = pid_d; 123 PID_D = pid_d;
128 PID_P = pid_p; 124 PID_P = pid_p;
@@ -161,9 +157,6 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
161 tempTrans1 = new btTransform(tempQuat1, tempVector1); 157 tempTrans1 = new btTransform(tempQuat1, tempVector1);
162 // m_movementComparision = new PhysicsVector(0, 0, 0); 158 // m_movementComparision = new PhysicsVector(0, 0, 0);
163 m_CapsuleOrientationAxis = new btVector3(1, 0, 1); 159 m_CapsuleOrientationAxis = new btVector3(1, 0, 1);
164
165
166
167 } 160 }
168 161
169 /// <summary> 162 /// <summary>
@@ -254,18 +247,18 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
254 get { return m_zeroFlag; } 247 get { return m_zeroFlag; }
255 } 248 }
256 249
257 public override PhysicsVector Size 250 public override Vector3 Size
258 { 251 {
259 get { return new PhysicsVector(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } 252 get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); }
260 set 253 set
261 { 254 {
262 m_pidControllerActive = true; 255 m_pidControllerActive = true;
263 256
264 PhysicsVector SetSize = value; 257 Vector3 SetSize = value;
265 m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f; 258 m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
266 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); 259 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
267 260
268 Velocity = new PhysicsVector(0f, 0f, 0f); 261 Velocity = Vector3.Zero;
269 262
270 m_parent_scene.AddPhysicsActorTaint(this); 263 m_parent_scene.AddPhysicsActorTaint(this);
271 } 264 }
@@ -317,12 +310,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
317 310
318 } 311 }
319 312
320 public override void LockAngularMotion(PhysicsVector axis) 313 public override void LockAngularMotion(Vector3 axis)
321 { 314 {
322 315
323 } 316 }
324 317
325 public override PhysicsVector Position 318 public override Vector3 Position
326 { 319 {
327 get { return m_position; } 320 get { return m_position; }
328 set 321 set
@@ -342,9 +335,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
342 } 335 }
343 } 336 }
344 337
345 public override PhysicsVector Force 338 public override Vector3 Force
346 { 339 {
347 get { return new PhysicsVector(m_target_velocity.X, m_target_velocity.Y, m_target_velocity.Z); } 340 get { return m_target_velocity; }
348 set { return; } 341 set { return; }
349 } 342 }
350 343
@@ -359,7 +352,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
359 352
360 } 353 }
361 354
362 public override void VehicleVectorParam(int param, PhysicsVector value) 355 public override void VehicleVectorParam(int param, Vector3 value)
363 { 356 {
364 357
365 } 358 }
@@ -374,23 +367,22 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
374 367
375 } 368 }
376 369
377 public override PhysicsVector GeometricCenter 370 public override Vector3 GeometricCenter
378 { 371 {
379 get { return PhysicsVector.Zero; } 372 get { return Vector3.Zero; }
380 } 373 }
381 374
382 public override PhysicsVector CenterOfMass 375 public override Vector3 CenterOfMass
383 { 376 {
384 get { return PhysicsVector.Zero; } 377 get { return Vector3.Zero; }
385 } 378 }
386 379
387 public override PhysicsVector Velocity 380 public override Vector3 Velocity
388 { 381 {
389 get 382 get
390 { 383 {
391 // There's a problem with PhysicsVector.Zero! Don't Use it Here!
392 if (m_zeroFlag) 384 if (m_zeroFlag)
393 return new PhysicsVector(0f, 0f, 0f); 385 return Vector3.Zero;
394 m_lastUpdateSent = false; 386 m_lastUpdateSent = false;
395 return m_velocity; 387 return m_velocity;
396 } 388 }
@@ -401,9 +393,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
401 } 393 }
402 } 394 }
403 395
404 public override PhysicsVector Torque 396 public override Vector3 Torque
405 { 397 {
406 get { return PhysicsVector.Zero; } 398 get { return Vector3.Zero; }
407 set { return; } 399 set { return; }
408 } 400 }
409 401
@@ -413,7 +405,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
413 set { } 405 set { }
414 } 406 }
415 407
416 public override PhysicsVector Acceleration 408 public override Vector3 Acceleration
417 { 409 {
418 get { return m_acceleration; } 410 get { return m_acceleration; }
419 } 411 }
@@ -586,7 +578,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
586 set { return; } 578 set { return; }
587 } 579 }
588 580
589 public override PhysicsVector RotationalVelocity 581 public override Vector3 RotationalVelocity
590 { 582 {
591 get { return m_rotationalVelocity; } 583 get { return m_rotationalVelocity; }
592 set { m_rotationalVelocity = value; } 584 set { m_rotationalVelocity = value; }
@@ -604,7 +596,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
604 set { m_buoyancy = value; } 596 set { m_buoyancy = value; }
605 } 597 }
606 598
607 public override PhysicsVector PIDTarget { set { return; } } 599 public override Vector3 PIDTarget { set { return; } }
608 public override bool PIDActive { set { return; } } 600 public override bool PIDActive { set { return; } }
609 public override float PIDTau { set { return; } } 601 public override float PIDTau { set { return; } }
610 602
@@ -634,7 +626,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
634 /// </summary> 626 /// </summary>
635 /// <param name="force"></param> 627 /// <param name="force"></param>
636 /// <param name="pushforce">Is this a push by a script?</param> 628 /// <param name="pushforce">Is this a push by a script?</param>
637 public override void AddForce(PhysicsVector force, bool pushforce) 629 public override void AddForce(Vector3 force, bool pushforce)
638 { 630 {
639 if (pushforce) 631 if (pushforce)
640 { 632 {
@@ -656,7 +648,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
656 //m_lastUpdateSent = false; 648 //m_lastUpdateSent = false;
657 } 649 }
658 650
659 public void doForce(PhysicsVector force, bool now) 651 public void doForce(Vector3 force, bool now)
660 { 652 {
661 653
662 tempVector3.setValue(force.X, force.Y, force.Z); 654 tempVector3.setValue(force.X, force.Y, force.Z);
@@ -671,7 +663,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
671 } 663 }
672 } 664 }
673 665
674 public void doImpulse(PhysicsVector force, bool now) 666 public void doImpulse(Vector3 force, bool now)
675 { 667 {
676 668
677 tempVector3.setValue(force.X, force.Y, force.Z); 669 tempVector3.setValue(force.X, force.Y, force.Z);
@@ -686,12 +678,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
686 } 678 }
687 } 679 }
688 680
689 public override void AddAngularForce(PhysicsVector force, bool pushforce) 681 public override void AddAngularForce(Vector3 force, bool pushforce)
690 { 682 {
691 683
692 } 684 }
693 685
694 public override void SetMomentum(PhysicsVector momentum) 686 public override void SetMomentum(Vector3 momentum)
695 { 687 {
696 688
697 } 689 }
@@ -808,7 +800,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
808 800
809 AvatarGeomAndBodyCreation(m_position.X, m_position.Y, 801 AvatarGeomAndBodyCreation(m_position.X, m_position.Y,
810 m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2)); 802 m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2));
811 Velocity = new PhysicsVector(0f, 0f, 0f); 803 Velocity = Vector3.Zero;
812 804
813 } 805 }
814 else 806 else
@@ -852,9 +844,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
852 } 844 }
853 //PidStatus = true; 845 //PidStatus = true;
854 846
855 PhysicsVector vec = new PhysicsVector(); 847 Vector3 vec = Vector3.Zero;
856 848
857 PhysicsVector vel = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); 849 Vector3 vel = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ());
858 850
859 float movementdivisor = 1f; 851 float movementdivisor = 1f;
860 852
@@ -885,7 +877,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
885 // Avatar to Avatar collisions 877 // Avatar to Avatar collisions
886 // Prim to avatar collisions 878 // Prim to avatar collisions
887 879
888 PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); 880 Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
889 vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2); 881 vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2);
890 vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2); 882 vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2);
891 if (m_flying) 883 if (m_flying)
@@ -927,7 +919,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
927 { 919 {
928 // We're colliding with something and we're not flying but we're moving 920 // We're colliding with something and we're not flying but we're moving
929 // This means we're walking or running. 921 // This means we're walking or running.
930 PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); 922 Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
931 vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P; 923 vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P;
932 if (m_target_velocity.X > 0) 924 if (m_target_velocity.X > 0)
933 { 925 {
@@ -1016,7 +1008,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1016 tempVector2 = Body.getInterpolationLinearVelocity(); 1008 tempVector2 = Body.getInterpolationLinearVelocity();
1017 1009
1018 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 1010 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
1019 PhysicsVector vec = new PhysicsVector(tempVector1.getX(),tempVector1.getY(),tempVector1.getZ()); 1011 Vector3 vec = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
1020 1012
1021 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 1013 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
1022 if (vec.X < -10.0f) vec.X = 0.0f; 1014 if (vec.X < -10.0f) vec.X = 0.0f;
@@ -1048,7 +1040,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1048 else 1040 else
1049 { 1041 {
1050 m_lastUpdateSent = false; 1042 m_lastUpdateSent = false;
1051 vec = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); 1043 vec = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ());
1052 m_velocity.X = (vec.X); 1044 m_velocity.X = (vec.X);
1053 m_velocity.Y = (vec.Y); 1045 m_velocity.Y = (vec.Y);
1054 1046
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
index f22ea71..5b542db 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
@@ -43,44 +43,43 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 private PhysicsVector _position; 46 private Vector3 _position;
47 private PhysicsVector m_zeroPosition; 47 private Vector3 m_zeroPosition;
48 private PhysicsVector _velocity; 48 private Vector3 _velocity;
49 private PhysicsVector _torque = new PhysicsVector(0, 0, 0); 49 private Vector3 _torque;
50 private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); 50 private Vector3 m_lastVelocity;
51 private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f); 51 private Vector3 m_lastposition;
52 private Quaternion m_lastorientation = new Quaternion(); 52 private Quaternion m_lastorientation = Quaternion.Identity;
53 private PhysicsVector m_rotationalVelocity; 53 private Vector3 m_rotationalVelocity;
54 private PhysicsVector _size; 54 private Vector3 _size;
55 private PhysicsVector _acceleration; 55 private Vector3 _acceleration;
56 // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f); 56 // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f);
57 private Quaternion _orientation; 57 private Quaternion _orientation;
58 private PhysicsVector m_taintposition; 58 private Vector3 m_taintposition;
59 private PhysicsVector m_taintsize; 59 private Vector3 m_taintsize;
60 private PhysicsVector m_taintVelocity = new PhysicsVector(0, 0, 0); 60 private Vector3 m_taintVelocity;
61 private PhysicsVector m_taintTorque = new PhysicsVector(0, 0, 0); 61 private Vector3 m_taintTorque;
62 private Quaternion m_taintrot; 62 private Quaternion m_taintrot;
63 private PhysicsVector m_angularlock = new PhysicsVector(1f, 1f, 1f); 63 private Vector3 m_angularlock = Vector3.One;
64 private PhysicsVector m_taintAngularLock = new PhysicsVector(1f, 1f, 1f); 64 private Vector3 m_taintAngularLock = Vector3.One;
65 // private btGeneric6DofConstraint Amotor; 65 // private btGeneric6DofConstraint Amotor;
66 66
67 private PhysicsVector m_PIDTarget = new PhysicsVector(0, 0, 0); 67 private Vector3 m_PIDTarget;
68 private float m_PIDTau = 0f; 68 private float m_PIDTau;
69 private float m_PIDHoverHeight = 0f; 69 private float m_PIDHoverHeight;
70 private float m_PIDHoverTau = 0f; 70 private float m_PIDHoverTau;
71 private bool m_useHoverPID = false; 71 private bool m_useHoverPID;
72 private PIDHoverType m_PIDHoverType = PIDHoverType.Ground; 72 private PIDHoverType m_PIDHoverType = PIDHoverType.Ground;
73 private float m_targetHoverHeight = 0f; 73 private float m_targetHoverHeight;
74 private float m_groundHeight = 0f; 74 private float m_groundHeight;
75 private float m_waterHeight = 0f; 75 private float m_waterHeight;
76 private float PID_D = 35f; 76 private float PID_D = 35f;
77 private float PID_G = 25f; 77 private float PID_G = 25f;
78 // private float m_tensor = 5f; 78 // private float m_tensor = 5f;
79 // private int body_autodisable_frames = 20; 79 // private int body_autodisable_frames = 20;
80 private IMesh primMesh = null; 80 private IMesh primMesh;
81
82 private bool m_usePID = false;
83 81
82 private bool m_usePID;
84 83
85 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom 84 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
86 | CollisionCategories.Space 85 | CollisionCategories.Space
@@ -88,11 +87,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
88 | CollisionCategories.Character 87 | CollisionCategories.Character
89 ); 88 );
90 89
91 private bool m_taintshape = false; 90 private bool m_taintshape;
92 private bool m_taintPhysics = false; 91 private bool m_taintPhysics;
93 // private bool m_collidesLand = true; 92 // private bool m_collidesLand = true;
94 private bool m_collidesWater = false; 93 private bool m_collidesWater;
95 public bool m_returnCollisions = false; 94 public bool m_returnCollisions;
96 95
97 // Default we're a Geometry 96 // Default we're a Geometry
98 // private CollisionCategories m_collisionCategories = (CollisionCategories.Geom); 97 // private CollisionCategories m_collisionCategories = (CollisionCategories.Geom);
@@ -100,23 +99,23 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
100 // Default, Collide with Other Geometries, spaces and Bodies 99 // Default, Collide with Other Geometries, spaces and Bodies
101 // private CollisionCategories m_collisionFlags = m_default_collisionFlags; 100 // private CollisionCategories m_collisionFlags = m_default_collisionFlags;
102 101
103 public bool m_taintremove = false; 102 public bool m_taintremove;
104 public bool m_taintdisable = false; 103 public bool m_taintdisable;
105 public bool m_disabled = false; 104 public bool m_disabled;
106 public bool m_taintadd = false; 105 public bool m_taintadd;
107 public bool m_taintselected = false; 106 public bool m_taintselected;
108 public bool m_taintCollidesWater = false; 107 public bool m_taintCollidesWater;
109 108
110 public uint m_localID = 0; 109 public uint m_localID;
111 110
112 //public GCHandle gc; 111 //public GCHandle gc;
113 // private CollisionLocker ode; 112 // private CollisionLocker ode;
114 113
115 private bool m_taintforce = false; 114 private bool m_taintforce;
116 private bool m_taintaddangularforce = false; 115 private bool m_taintaddangularforce;
117 private PhysicsVector m_force = new PhysicsVector(0.0f, 0.0f, 0.0f); 116 private Vector3 m_force;
118 private List<PhysicsVector> m_forcelist = new List<PhysicsVector>(); 117 private List<Vector3> m_forcelist = new List<Vector3>();
119 private List<PhysicsVector> m_angularforcelist = new List<PhysicsVector>(); 118 private List<Vector3> m_angularforcelist = new List<Vector3>();
120 119
121 private IMesh _mesh; 120 private IMesh _mesh;
122 private PrimitiveBaseShape _pbs; 121 private PrimitiveBaseShape _pbs;
@@ -124,40 +123,40 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
124 public btCollisionShape prim_geom; 123 public btCollisionShape prim_geom;
125 public IntPtr _triMeshData; 124 public IntPtr _triMeshData;
126 125
127 private PhysicsActor _parent = null; 126 private PhysicsActor _parent;
128 private PhysicsActor m_taintparent = null; 127 private PhysicsActor m_taintparent;
129 128
130 private List<BulletDotNETPrim> childrenPrim = new List<BulletDotNETPrim>(); 129 private List<BulletDotNETPrim> childrenPrim = new List<BulletDotNETPrim>();
131 130
132 private bool iscolliding = false; 131 private bool iscolliding;
133 private bool m_isphysical = false; 132 private bool m_isphysical;
134 private bool m_isSelected = false; 133 private bool m_isSelected;
135 134
136 internal bool m_isVolumeDetect = false; // If true, this prim only detects collisions but doesn't collide actively 135 internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
137 136
138 private bool m_throttleUpdates = false; 137 private bool m_throttleUpdates;
139 // private int throttleCounter = 0; 138 // private int throttleCounter;
140 public int m_interpenetrationcount = 0; 139 public int m_interpenetrationcount;
141 public float m_collisionscore = 0; 140 public float m_collisionscore;
142 public int m_roundsUnderMotionThreshold = 0; 141 public int m_roundsUnderMotionThreshold;
143 private int m_crossingfailures = 0; 142 private int m_crossingfailures;
144 143
145 public float m_buoyancy = 0f; 144 public float m_buoyancy;
146 145
147 public bool outofBounds = false; 146 public bool outofBounds;
148 private float m_density = 10.000006836f; // Aluminum g/cm3; 147 private float m_density = 10.000006836f; // Aluminum g/cm3;
149 148
150 public bool _zeroFlag = false; 149 public bool _zeroFlag;
151 private bool m_lastUpdateSent = false; 150 private bool m_lastUpdateSent;
152 151
153 152
154 private String m_primName; 153 private String m_primName;
155 private PhysicsVector _target_velocity; 154 private Vector3 _target_velocity;
156 155
157 public int m_eventsubscription = 0; 156 public int m_eventsubscription;
158 // private CollisionEventUpdate CollisionEventsThisFrame = null; 157 // private CollisionEventUpdate CollisionEventsThisFrame = null;
159 158
160 public volatile bool childPrim = false; 159 public volatile bool childPrim;
161 160
162 private btVector3 tempPosition1; 161 private btVector3 tempPosition1;
163 private btVector3 tempPosition2; 162 private btVector3 tempPosition2;
@@ -190,7 +189,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
190 189
191 public btRigidBody Body; 190 public btRigidBody Body;
192 191
193 public BulletDotNETPrim(String primName, BulletDotNETScene parent_scene, PhysicsVector pos, PhysicsVector size, 192 public BulletDotNETPrim(String primName, BulletDotNETScene parent_scene, Vector3 pos, Vector3 size,
194 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical) 193 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical)
195 { 194 {
196 tempPosition1 = new btVector3(0, 0, 0); 195 tempPosition1 = new btVector3(0, 0, 0);
@@ -225,8 +224,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
225 224
226 AxisLockLinearHigh = new btVector3((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionSize); 225 AxisLockLinearHigh = new btVector3((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionSize);
227 226
228 _target_velocity = new PhysicsVector(0, 0, 0); 227 _target_velocity = Vector3.Zero;
229 _velocity = new PhysicsVector(); 228 _velocity = Vector3.Zero;
230 _position = pos; 229 _position = pos;
231 m_taintposition = pos; 230 m_taintposition = pos;
232 PID_D = parent_scene.bodyPIDD; 231 PID_D = parent_scene.bodyPIDD;
@@ -244,8 +243,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
244 243
245 _size = size; 244 _size = size;
246 m_taintsize = _size; 245 m_taintsize = _size;
247 _acceleration = new PhysicsVector(); 246 _acceleration = Vector3.Zero;
248 m_rotationalVelocity = PhysicsVector.Zero; 247 m_rotationalVelocity = Vector3.Zero;
249 _orientation = rotation; 248 _orientation = rotation;
250 m_taintrot = _orientation; 249 m_taintrot = _orientation;
251 _mesh = mesh; 250 _mesh = mesh;
@@ -274,7 +273,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
274 get { return _zeroFlag; } 273 get { return _zeroFlag; }
275 } 274 }
276 275
277 public override PhysicsVector Size 276 public override Vector3 Size
278 { 277 {
279 get { return _size; } 278 get { return _size; }
280 set { _size = value; } 279 set { _size = value; }
@@ -348,13 +347,13 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
348 m_taintparent = null; 347 m_taintparent = null;
349 } 348 }
350 349
351 public override void LockAngularMotion(PhysicsVector axis) 350 public override void LockAngularMotion(Vector3 axis)
352 { 351 {
353 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); 352 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z);
354 m_taintAngularLock = new PhysicsVector(axis.X, axis.Y, axis.Z); 353 m_taintAngularLock = axis;
355 } 354 }
356 355
357 public override PhysicsVector Position 356 public override Vector3 Position
358 { 357 {
359 get { return _position; } 358 get { return _position; }
360 359
@@ -370,9 +369,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
370 get { return CalculateMass(); } 369 get { return CalculateMass(); }
371 } 370 }
372 371
373 public override PhysicsVector Force 372 public override Vector3 Force
374 { 373 {
375 //get { return PhysicsVector.Zero; } 374 //get { return Vector3.Zero; }
376 get { return m_force; } 375 get { return m_force; }
377 set { m_force = value; } 376 set { m_force = value; }
378 } 377 }
@@ -388,7 +387,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
388 //TODO: 387 //TODO:
389 } 388 }
390 389
391 public override void VehicleVectorParam(int param, PhysicsVector value) 390 public override void VehicleVectorParam(int param, Vector3 value)
392 { 391 {
393 //TODO: 392 //TODO:
394 } 393 }
@@ -405,23 +404,23 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
405 404
406 } 405 }
407 406
408 public override PhysicsVector GeometricCenter 407 public override Vector3 GeometricCenter
409 { 408 {
410 get { return PhysicsVector.Zero; } 409 get { return Vector3.Zero; }
411 } 410 }
412 411
413 public override PhysicsVector CenterOfMass 412 public override Vector3 CenterOfMass
414 { 413 {
415 get { return PhysicsVector.Zero; } 414 get { return Vector3.Zero; }
416 } 415 }
417 416
418 public override PhysicsVector Velocity 417 public override Vector3 Velocity
419 { 418 {
420 get 419 get
421 { 420 {
422 // Averate previous velocity with the new one so 421 // Averate previous velocity with the new one so
423 // client object interpolation works a 'little' better 422 // client object interpolation works a 'little' better
424 PhysicsVector returnVelocity = new PhysicsVector(); 423 Vector3 returnVelocity;
425 returnVelocity.X = (m_lastVelocity.X + _velocity.X) / 2; 424 returnVelocity.X = (m_lastVelocity.X + _velocity.X) / 2;
426 returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y) / 2; 425 returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y) / 2;
427 returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z) / 2; 426 returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z) / 2;
@@ -436,12 +435,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
436 } 435 }
437 } 436 }
438 437
439 public override PhysicsVector Torque 438 public override Vector3 Torque
440 { 439 {
441 get 440 get
442 { 441 {
443 if (!m_isphysical || Body.Handle == IntPtr.Zero) 442 if (!m_isphysical || Body.Handle == IntPtr.Zero)
444 return new PhysicsVector(0, 0, 0); 443 return Vector3.Zero;
445 444
446 return _torque; 445 return _torque;
447 } 446 }
@@ -459,7 +458,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
459 set { m_collisionscore = value; } 458 set { m_collisionscore = value; }
460 } 459 }
461 460
462 public override PhysicsVector Acceleration 461 public override Vector3 Acceleration
463 { 462 {
464 get { return _acceleration; } 463 get { return _acceleration; }
465 } 464 }
@@ -528,16 +527,16 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
528 } 527 }
529 } 528 }
530 529
531 public override PhysicsVector RotationalVelocity 530 public override Vector3 RotationalVelocity
532 { 531 {
533 get 532 get
534 { 533 {
535 PhysicsVector pv = new PhysicsVector(0, 0, 0); 534 Vector3 pv = Vector3.Zero;
536 if (_zeroFlag) 535 if (_zeroFlag)
537 return pv; 536 return pv;
538 m_lastUpdateSent = false; 537 m_lastUpdateSent = false;
539 538
540 if (m_rotationalVelocity.IsIdentical(pv, 0.2f)) 539 if (m_rotationalVelocity.ApproxEquals(pv, 0.2f))
541 return pv; 540 return pv;
542 541
543 return m_rotationalVelocity; 542 return m_rotationalVelocity;
@@ -557,7 +556,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
557 set { m_buoyancy = value; } 556 set { m_buoyancy = value; }
558 } 557 }
559 558
560 public override PhysicsVector PIDTarget { set { m_PIDTarget = value; ; } } 559 public override Vector3 PIDTarget { set { m_PIDTarget = value; ; } }
561 public override bool PIDActive { set { m_usePID = value; } } 560 public override bool PIDActive { set { m_usePID = value; } }
562 public override float PIDTau { set { m_PIDTau = value; } } 561 public override float PIDTau { set { m_PIDTau = value; } }
563 562
@@ -567,20 +566,20 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
567 public override float PIDHoverTau { set { m_PIDHoverTau = value; } } 566 public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
568 567
569 568
570 public override void AddForce(PhysicsVector force, bool pushforce) 569 public override void AddForce(Vector3 force, bool pushforce)
571 { 570 {
572 m_forcelist.Add(force); 571 m_forcelist.Add(force);
573 m_taintforce = true; 572 m_taintforce = true;
574 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); 573 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString());
575 } 574 }
576 575
577 public override void AddAngularForce(PhysicsVector force, bool pushforce) 576 public override void AddAngularForce(Vector3 force, bool pushforce)
578 { 577 {
579 m_angularforcelist.Add(force); 578 m_angularforcelist.Add(force);
580 m_taintaddangularforce = true; 579 m_taintaddangularforce = true;
581 } 580 }
582 581
583 public override void SetMomentum(PhysicsVector momentum) 582 public override void SetMomentum(Vector3 momentum)
584 { 583 {
585 } 584 }
586 585
@@ -778,7 +777,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
778 777
779 } 778 }
780 779
781 if (!_position.IsIdentical(m_taintposition, 0f)) 780 if (!_position.ApproxEquals(m_taintposition, 0f))
782 { 781 {
783 m_log.Debug("[PHYSICS]: TaintMove"); 782 m_log.Debug("[PHYSICS]: TaintMove");
784 changemove(timestep); 783 changemove(timestep);
@@ -796,7 +795,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
796 } 795 }
797 // 796 //
798 797
799 if (!_size.IsIdentical(m_taintsize, 0)) 798 if (!_size.ApproxEquals(m_taintsize, 0f))
800 { 799 {
801 m_log.Debug("[PHYSICS]: TaintSize"); 800 m_log.Debug("[PHYSICS]: TaintSize");
802 changesize(timestep); 801 changesize(timestep);
@@ -820,7 +819,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
820 m_log.Debug("[PHYSICS]: TaintAngularForce"); 819 m_log.Debug("[PHYSICS]: TaintAngularForce");
821 changeAddAngularForce(timestep); 820 changeAddAngularForce(timestep);
822 } 821 }
823 if (!m_taintTorque.IsIdentical(PhysicsVector.Zero, 0.001f)) 822 if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f))
824 { 823 {
825 m_log.Debug("[PHYSICS]: TaintTorque"); 824 m_log.Debug("[PHYSICS]: TaintTorque");
826 changeSetTorque(timestep); 825 changeSetTorque(timestep);
@@ -835,7 +834,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
835 m_log.Debug("[PHYSICS]: TaintSelected"); 834 m_log.Debug("[PHYSICS]: TaintSelected");
836 changeSelectedStatus(timestep); 835 changeSelectedStatus(timestep);
837 } 836 }
838 if (!m_taintVelocity.IsIdentical(PhysicsVector.Zero, 0.001f)) 837 if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f))
839 { 838 {
840 m_log.Debug("[PHYSICS]: TaintVelocity"); 839 m_log.Debug("[PHYSICS]: TaintVelocity");
841 changevelocity(timestep); 840 changevelocity(timestep);
@@ -849,7 +848,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
849 { 848 {
850 changefloatonwater(timestep); 849 changefloatonwater(timestep);
851 } 850 }
852 if (!m_angularlock.IsIdentical(m_taintAngularLock, 0)) 851 if (!m_angularlock.ApproxEquals(m_taintAngularLock, 0))
853 { 852 {
854 m_log.Debug("[PHYSICS]: TaintAngularLock"); 853 m_log.Debug("[PHYSICS]: TaintAngularLock");
855 changeAngularLock(timestep); 854 changeAngularLock(timestep);
@@ -1012,7 +1011,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1012 { 1011 {
1013 if (_parent_scene.needsMeshing(_pbs)) 1012 if (_parent_scene.needsMeshing(_pbs))
1014 { 1013 {
1015 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); 1014 ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity);
1016 // createmesh returns null when it doesn't mesh. 1015 // createmesh returns null when it doesn't mesh.
1017 CreateGeom(IntPtr.Zero, _mesh); 1016 CreateGeom(IntPtr.Zero, _mesh);
1018 } 1017 }
@@ -1029,7 +1028,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1029 return _parent_scene.needsMeshing(_pbs); 1028 return _parent_scene.needsMeshing(_pbs);
1030 } 1029 }
1031 1030
1032 internal void ProcessGeomCreationAsTriMesh(PhysicsVector positionOffset, Quaternion orientation) 1031 internal void ProcessGeomCreationAsTriMesh(Vector3 positionOffset, Quaternion orientation)
1033 { 1032 {
1034 // Don't need to re-enable body.. it's done in SetMesh 1033 // Don't need to re-enable body.. it's done in SetMesh
1035 float meshlod = _parent_scene.meshSculptLOD; 1034 float meshlod = _parent_scene.meshSculptLOD;
@@ -1038,7 +1037,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1038 meshlod = _parent_scene.MeshSculptphysicalLOD; 1037 meshlod = _parent_scene.MeshSculptphysicalLOD;
1039 1038
1040 IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical); 1039 IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical);
1041 if (!positionOffset.IsIdentical(PhysicsVector.Zero, 0.001f) || orientation != Quaternion.Identity) 1040 if (!positionOffset.ApproxEquals(Vector3.Zero, 0.001f) || orientation != Quaternion.Identity)
1042 { 1041 {
1043 1042
1044 float[] xyz = new float[3]; 1043 float[] xyz = new float[3];
@@ -1202,7 +1201,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1202 //m_log.Info("[PHYSICS]: dequeing forcelist"); 1201 //m_log.Info("[PHYSICS]: dequeing forcelist");
1203 if (IsPhysical) 1202 if (IsPhysical)
1204 { 1203 {
1205 PhysicsVector iforce = new PhysicsVector(); 1204 Vector3 iforce = Vector3.Zero;
1206 for (int i = 0; i < m_forcelist.Count; i++) 1205 for (int i = 0; i < m_forcelist.Count; i++)
1207 { 1206 {
1208 iforce = iforce + m_forcelist[i]; 1207 iforce = iforce + m_forcelist[i];
@@ -1237,7 +1236,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1237 //m_log.Info("[PHYSICS]: dequeing forcelist"); 1236 //m_log.Info("[PHYSICS]: dequeing forcelist");
1238 if (IsPhysical) 1237 if (IsPhysical)
1239 { 1238 {
1240 PhysicsVector iforce = new PhysicsVector(); 1239 Vector3 iforce = Vector3.Zero;
1241 for (int i = 0; i < m_angularforcelist.Count; i++) 1240 for (int i = 0; i < m_angularforcelist.Count; i++)
1242 { 1241 {
1243 iforce = iforce + m_angularforcelist[i]; 1242 iforce = iforce + m_angularforcelist[i];
@@ -1276,7 +1275,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1276 } 1275 }
1277 } 1276 }
1278 } 1277 }
1279 m_taintTorque = new PhysicsVector(0, 0, 0); 1278 m_taintTorque = Vector3.Zero;
1280 } 1279 }
1281 1280
1282 private void changedisable(float timestep) 1281 private void changedisable(float timestep)
@@ -1317,7 +1316,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1317 1316
1318 //resetCollisionAccounting(); 1317 //resetCollisionAccounting();
1319 } 1318 }
1320 m_taintVelocity = PhysicsVector.Zero; 1319 m_taintVelocity = Vector3.Zero;
1321 } 1320 }
1322 1321
1323 private void changelink(float timestep) 1322 private void changelink(float timestep)
@@ -1361,7 +1360,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1361 1360
1362 if (m_taintparent != null) 1361 if (m_taintparent != null)
1363 { 1362 {
1364 m_taintparent.Position.Z = m_taintparent.Position.Z + 0.02f; 1363 Vector3 taintparentPosition = m_taintparent.Position;
1364 taintparentPosition.Z = m_taintparent.Position.Z + 0.02f;
1365 m_taintparent.Position = taintparentPosition;
1365 _parent_scene.AddPhysicsActorTaint(m_taintparent); 1366 _parent_scene.AddPhysicsActorTaint(m_taintparent);
1366 } 1367 }
1367 } 1368 }
@@ -1382,7 +1383,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1382 { 1383 {
1383 if (_parent == null) 1384 if (_parent == null)
1384 { 1385 {
1385 if (!m_taintAngularLock.IsIdentical(new PhysicsVector(1f, 1f, 1f), 0)) 1386 if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f))
1386 { 1387 {
1387 //d.BodySetFiniteRotationMode(Body, 0); 1388 //d.BodySetFiniteRotationMode(Body, 0);
1388 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z); 1389 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z);
@@ -1395,7 +1396,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1395 } 1396 }
1396 1397
1397 } 1398 }
1398 m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z); 1399 m_angularlock = m_taintAngularLock;
1399 1400
1400 } 1401 }
1401 #endregion 1402 #endregion
@@ -1460,17 +1461,17 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1460 // TODO: NEED btVector3 for Linear Velocity 1461 // TODO: NEED btVector3 for Linear Velocity
1461 // NEED btVector3 for Position 1462 // NEED btVector3 for Position
1462 1463
1463 PhysicsVector pos = new PhysicsVector(_position.X, _position.Y, _position.Z); //TODO: Insert values gotten from bullet 1464 Vector3 pos = _position; //TODO: Insert values gotten from bullet
1464 PhysicsVector vel = new PhysicsVector(_velocity.X, _velocity.Y, _velocity.Z); 1465 Vector3 vel = _velocity;
1465 1466
1466 _target_velocity = 1467 _target_velocity =
1467 new PhysicsVector( 1468 new Vector3(
1468 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), 1469 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1469 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep), 1470 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
1470 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep) 1471 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
1471 ); 1472 );
1472 1473
1473 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) 1474 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
1474 { 1475 {
1475 1476
1476 /* TODO: Do Bullet equiv 1477 /* TODO: Do Bullet equiv
@@ -1512,8 +1513,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1512 { 1513 {
1513 PID_G = m_PIDTau + 1; 1514 PID_G = m_PIDTau + 1;
1514 } 1515 }
1515 PhysicsVector pos = new PhysicsVector(0, 0, 0); //TODO: Insert values gotten from bullet 1516 Vector3 pos = Vector3.Zero; //TODO: Insert values gotten from bullet
1516 PhysicsVector vel = new PhysicsVector(0, 0, 0); 1517 Vector3 vel = Vector3.Zero;
1517 1518
1518 // determine what our target height really is based on HoverType 1519 // determine what our target height really is based on HoverType
1519 switch (m_PIDHoverType) 1520 switch (m_PIDHoverType)
@@ -1545,13 +1546,13 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1545 1546
1546 1547
1547 _target_velocity = 1548 _target_velocity =
1548 new PhysicsVector(0.0f, 0.0f, 1549 new Vector3(0.0f, 0.0f,
1549 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep) 1550 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
1550 ); 1551 );
1551 1552
1552 // if velocity is zero, use position control; otherwise, velocity control 1553 // if velocity is zero, use position control; otherwise, velocity control
1553 1554
1554 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) 1555 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
1555 { 1556 {
1556 1557
1557 /* TODO: Do Bullet Equiv 1558 /* TODO: Do Bullet Equiv
@@ -1626,8 +1627,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1626 else 1627 else
1627 { 1628 {
1628 if (m_zeroPosition == null) 1629 if (m_zeroPosition == null)
1629 m_zeroPosition = new PhysicsVector(0, 0, 0); 1630 m_zeroPosition = Vector3.Zero;
1630 m_zeroPosition.setValues(_position.X, _position.Y, _position.Z); 1631 m_zeroPosition = _position;
1631 return; 1632 return;
1632 } 1633 }
1633 } 1634 }
@@ -2177,7 +2178,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2177 2178
2178 //if (hasTrimesh) 2179 //if (hasTrimesh)
2179 //{ 2180 //{
2180 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); 2181 ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity);
2181 // createmesh returns null when it doesn't mesh. 2182 // createmesh returns null when it doesn't mesh.
2182 2183
2183 /* 2184 /*
@@ -2197,11 +2198,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2197 { 2198 {
2198 if (chld == null) 2199 if (chld == null)
2199 continue; 2200 continue;
2200 PhysicsVector offset = chld.Position - Position; 2201 Vector3 offset = chld.Position - Position;
2201 Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z); 2202 Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z);
2202 pos *= Quaternion.Inverse(Orientation); 2203 pos *= Quaternion.Inverse(Orientation);
2203 //pos *= Orientation; 2204 //pos *= Orientation;
2204 offset.setValues(pos.X, pos.Y, pos.Z); 2205 offset = pos;
2205 chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation); 2206 chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation);
2206 2207
2207 _mesh.Append(chld._mesh); 2208 _mesh.Append(chld._mesh);
@@ -2433,7 +2434,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2433 m_collisionscore = 0; 2434 m_collisionscore = 0;
2434 m_disabled = false; 2435 m_disabled = false;
2435 // The body doesn't already have a finite rotation mode set here 2436 // The body doesn't already have a finite rotation mode set here
2436 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 2437 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
2437 { 2438 {
2438 // TODO: Create Angular Motor on Axis Lock! 2439 // TODO: Create Angular Motor on Axis Lock!
2439 } 2440 }
@@ -2447,7 +2448,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2447 { 2448 {
2448 if (_parent == null) 2449 if (_parent == null)
2449 { 2450 {
2450 PhysicsVector pv = new PhysicsVector(0, 0, 0); 2451 Vector3 pv = Vector3.Zero;
2451 bool lastZeroFlag = _zeroFlag; 2452 bool lastZeroFlag = _zeroFlag;
2452 if (tempPosition3 != null && tempPosition3.Handle != IntPtr.Zero) 2453 if (tempPosition3 != null && tempPosition3.Handle != IntPtr.Zero)
2453 tempPosition3.Dispose(); 2454 tempPosition3.Dispose();
@@ -2471,10 +2472,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2471 tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel 2472 tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel
2472 tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel 2473 tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel
2473 2474
2474 _torque.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(), 2475 _torque = new Vector3(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(),
2475 tempAngularVelocity1.getZ()); 2476 tempAngularVelocity1.getZ());
2476 PhysicsVector l_position = new PhysicsVector(); 2477 Vector3 l_position = Vector3.Zero;
2477 Quaternion l_orientation = new Quaternion(); 2478 Quaternion l_orientation = Quaternion.Identity;
2478 m_lastposition = _position; 2479 m_lastposition = _position;
2479 m_lastorientation = _orientation; 2480 m_lastorientation = _orientation;
2480 2481
@@ -2598,20 +2599,18 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2598 _velocity.Z = tempLinearVelocity1.getZ(); 2599 _velocity.Z = tempLinearVelocity1.getZ();
2599 2600
2600 _acceleration = ((_velocity - m_lastVelocity) / 0.1f); 2601 _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
2601 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, 2602 _acceleration = new Vector3(_velocity.X - m_lastVelocity.X / 0.1f,
2602 _velocity.Y - m_lastVelocity.Y / 0.1f, 2603 _velocity.Y - m_lastVelocity.Y / 0.1f,
2603 _velocity.Z - m_lastVelocity.Z / 0.1f); 2604 _velocity.Z - m_lastVelocity.Z / 0.1f);
2604 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); 2605 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
2605 2606
2606 if (_velocity.IsIdentical(pv, 0.5f)) 2607 if (_velocity.ApproxEquals(pv, 0.5f))
2607 { 2608 {
2608 m_rotationalVelocity = pv; 2609 m_rotationalVelocity = pv;
2609 } 2610 }
2610 else 2611 else
2611 { 2612 {
2612 2613 m_rotationalVelocity = new Vector3(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(), tempAngularVelocity1.getZ());
2613 m_rotationalVelocity.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(),
2614 tempAngularVelocity1.getZ());
2615 } 2614 }
2616 2615
2617 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString()); 2616 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString());
@@ -2665,7 +2664,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2665 m_taintremove = true; 2664 m_taintremove = true;
2666 } 2665 }
2667 2666
2668 internal void EnableAxisMotor(PhysicsVector axislock) 2667 internal void EnableAxisMotor(Vector3 axislock)
2669 { 2668 {
2670 if (m_aMotor != null) 2669 if (m_aMotor != null)
2671 DisableAxisMotor(); 2670 DisableAxisMotor();
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs
index 18d4bab..9e048ab 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs
@@ -139,7 +139,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
139 139
140 } 140 }
141 141
142 public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) 142 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
143 { 143 {
144 BulletDotNETCharacter chr = new BulletDotNETCharacter(avName, this, position, size, avPIDD, avPIDP, 144 BulletDotNETCharacter chr = new BulletDotNETCharacter(avName, this, position, size, avPIDD, avPIDP,
145 avCapRadius, avStandupTensor, avDensity, 145 avCapRadius, avStandupTensor, avDensity,
@@ -177,14 +177,14 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
177 } 177 }
178 } 178 }
179 179
180 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, 180 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
181 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) 181 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
182 { 182 {
183 PhysicsVector pos = new PhysicsVector(position.X, position.Y, position.Z); 183 Vector3 pos = position;
184 //pos.X = position.X; 184 //pos.X = position.X;
185 //pos.Y = position.Y; 185 //pos.Y = position.Y;
186 //pos.Z = position.Z; 186 //pos.Z = position.Z;
187 PhysicsVector siz = new PhysicsVector(); 187 Vector3 siz = Vector3.Zero;
188 siz.X = size.X; 188 siz.X = size.X;
189 siz.Y = size.Y; 189 siz.Y = size.Y;
190 siz.Z = size.Z; 190 siz.Z = size.Z;
@@ -201,12 +201,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
201 return newPrim; 201 return newPrim;
202 } 202 }
203 203
204 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) 204 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation)
205 { 205 {
206 return AddPrimShape(primName, pbs, position, size, rotation, false); 206 return AddPrimShape(primName, pbs, position, size, rotation, false);
207 } 207 }
208 208
209 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) 209 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical)
210 { 210 {
211 PhysicsActor result; 211 PhysicsActor result;
212 IMesh mesh = null; 212 IMesh mesh = null;