aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletDotNETPlugin
diff options
context:
space:
mode:
authorKittoFlora2009-10-27 22:42:55 +0100
committerKittoFlora2009-10-27 22:42:55 +0100
commit1113b3b6ebba3e358326a7be90b338d8c95af688 (patch)
treed923340600e5a2699ceaceeb52fd6c45994f334a /OpenSim/Region/Physics/BulletDotNETPlugin
parentllRotLookAt Pt 2 (diff)
parentMerge branch 'master' into vehicles (diff)
downloadopensim-SC_OLD-1113b3b6ebba3e358326a7be90b338d8c95af688.zip
opensim-SC_OLD-1113b3b6ebba3e358326a7be90b338d8c95af688.tar.gz
opensim-SC_OLD-1113b3b6ebba3e358326a7be90b338d8c95af688.tar.bz2
opensim-SC_OLD-1113b3b6ebba3e358326a7be90b338d8c95af688.tar.xz
Merge branch 'vehicles' into tests
Conflicts: OpenSim/Region/Physics/Manager/PhysicsActor.cs OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
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 d7aed3c..98681d6 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
@@ -640,7 +632,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
640 /// </summary> 632 /// </summary>
641 /// <param name="force"></param> 633 /// <param name="force"></param>
642 /// <param name="pushforce">Is this a push by a script?</param> 634 /// <param name="pushforce">Is this a push by a script?</param>
643 public override void AddForce(PhysicsVector force, bool pushforce) 635 public override void AddForce(Vector3 force, bool pushforce)
644 { 636 {
645 if (pushforce) 637 if (pushforce)
646 { 638 {
@@ -662,7 +654,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
662 //m_lastUpdateSent = false; 654 //m_lastUpdateSent = false;
663 } 655 }
664 656
665 public void doForce(PhysicsVector force, bool now) 657 public void doForce(Vector3 force, bool now)
666 { 658 {
667 659
668 tempVector3.setValue(force.X, force.Y, force.Z); 660 tempVector3.setValue(force.X, force.Y, force.Z);
@@ -677,7 +669,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
677 } 669 }
678 } 670 }
679 671
680 public void doImpulse(PhysicsVector force, bool now) 672 public void doImpulse(Vector3 force, bool now)
681 { 673 {
682 674
683 tempVector3.setValue(force.X, force.Y, force.Z); 675 tempVector3.setValue(force.X, force.Y, force.Z);
@@ -692,12 +684,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
692 } 684 }
693 } 685 }
694 686
695 public override void AddAngularForce(PhysicsVector force, bool pushforce) 687 public override void AddAngularForce(Vector3 force, bool pushforce)
696 { 688 {
697 689
698 } 690 }
699 691
700 public override void SetMomentum(PhysicsVector momentum) 692 public override void SetMomentum(Vector3 momentum)
701 { 693 {
702 694
703 } 695 }
@@ -814,7 +806,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
814 806
815 AvatarGeomAndBodyCreation(m_position.X, m_position.Y, 807 AvatarGeomAndBodyCreation(m_position.X, m_position.Y,
816 m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2)); 808 m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2));
817 Velocity = new PhysicsVector(0f, 0f, 0f); 809 Velocity = Vector3.Zero;
818 810
819 } 811 }
820 else 812 else
@@ -858,9 +850,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
858 } 850 }
859 //PidStatus = true; 851 //PidStatus = true;
860 852
861 PhysicsVector vec = new PhysicsVector(); 853 Vector3 vec = Vector3.Zero;
862 854
863 PhysicsVector vel = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); 855 Vector3 vel = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ());
864 856
865 float movementdivisor = 1f; 857 float movementdivisor = 1f;
866 858
@@ -891,7 +883,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
891 // Avatar to Avatar collisions 883 // Avatar to Avatar collisions
892 // Prim to avatar collisions 884 // Prim to avatar collisions
893 885
894 PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); 886 Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
895 vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2); 887 vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2);
896 vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2); 888 vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2);
897 if (m_flying) 889 if (m_flying)
@@ -933,7 +925,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
933 { 925 {
934 // We're colliding with something and we're not flying but we're moving 926 // We're colliding with something and we're not flying but we're moving
935 // This means we're walking or running. 927 // This means we're walking or running.
936 PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); 928 Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
937 vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P; 929 vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P;
938 if (m_target_velocity.X > 0) 930 if (m_target_velocity.X > 0)
939 { 931 {
@@ -1022,7 +1014,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1022 tempVector2 = Body.getInterpolationLinearVelocity(); 1014 tempVector2 = Body.getInterpolationLinearVelocity();
1023 1015
1024 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 1016 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
1025 PhysicsVector vec = new PhysicsVector(tempVector1.getX(),tempVector1.getY(),tempVector1.getZ()); 1017 Vector3 vec = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
1026 1018
1027 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 1019 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
1028 if (vec.X < -10.0f) vec.X = 0.0f; 1020 if (vec.X < -10.0f) vec.X = 0.0f;
@@ -1054,7 +1046,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1054 else 1046 else
1055 { 1047 {
1056 m_lastUpdateSent = false; 1048 m_lastUpdateSent = false;
1057 vec = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); 1049 vec = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ());
1058 m_velocity.X = (vec.X); 1050 m_velocity.X = (vec.X);
1059 m_velocity.Y = (vec.Y); 1051 m_velocity.Y = (vec.Y);
1060 1052
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
index 977b463..d931f126 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
@@ -572,20 +571,20 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
572 public override float APIDDamping { set { return; } } 571 public override float APIDDamping { set { return; } }
573 572
574 573
575 public override void AddForce(PhysicsVector force, bool pushforce) 574 public override void AddForce(Vector3 force, bool pushforce)
576 { 575 {
577 m_forcelist.Add(force); 576 m_forcelist.Add(force);
578 m_taintforce = true; 577 m_taintforce = true;
579 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); 578 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString());
580 } 579 }
581 580
582 public override void AddAngularForce(PhysicsVector force, bool pushforce) 581 public override void AddAngularForce(Vector3 force, bool pushforce)
583 { 582 {
584 m_angularforcelist.Add(force); 583 m_angularforcelist.Add(force);
585 m_taintaddangularforce = true; 584 m_taintaddangularforce = true;
586 } 585 }
587 586
588 public override void SetMomentum(PhysicsVector momentum) 587 public override void SetMomentum(Vector3 momentum)
589 { 588 {
590 } 589 }
591 590
@@ -783,7 +782,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
783 782
784 } 783 }
785 784
786 if (!_position.IsIdentical(m_taintposition, 0f)) 785 if (!_position.ApproxEquals(m_taintposition, 0f))
787 { 786 {
788 m_log.Debug("[PHYSICS]: TaintMove"); 787 m_log.Debug("[PHYSICS]: TaintMove");
789 changemove(timestep); 788 changemove(timestep);
@@ -801,7 +800,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
801 } 800 }
802 // 801 //
803 802
804 if (!_size.IsIdentical(m_taintsize, 0)) 803 if (!_size.ApproxEquals(m_taintsize, 0f))
805 { 804 {
806 m_log.Debug("[PHYSICS]: TaintSize"); 805 m_log.Debug("[PHYSICS]: TaintSize");
807 changesize(timestep); 806 changesize(timestep);
@@ -825,7 +824,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
825 m_log.Debug("[PHYSICS]: TaintAngularForce"); 824 m_log.Debug("[PHYSICS]: TaintAngularForce");
826 changeAddAngularForce(timestep); 825 changeAddAngularForce(timestep);
827 } 826 }
828 if (!m_taintTorque.IsIdentical(PhysicsVector.Zero, 0.001f)) 827 if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f))
829 { 828 {
830 m_log.Debug("[PHYSICS]: TaintTorque"); 829 m_log.Debug("[PHYSICS]: TaintTorque");
831 changeSetTorque(timestep); 830 changeSetTorque(timestep);
@@ -840,7 +839,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
840 m_log.Debug("[PHYSICS]: TaintSelected"); 839 m_log.Debug("[PHYSICS]: TaintSelected");
841 changeSelectedStatus(timestep); 840 changeSelectedStatus(timestep);
842 } 841 }
843 if (!m_taintVelocity.IsIdentical(PhysicsVector.Zero, 0.001f)) 842 if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f))
844 { 843 {
845 m_log.Debug("[PHYSICS]: TaintVelocity"); 844 m_log.Debug("[PHYSICS]: TaintVelocity");
846 changevelocity(timestep); 845 changevelocity(timestep);
@@ -854,7 +853,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
854 { 853 {
855 changefloatonwater(timestep); 854 changefloatonwater(timestep);
856 } 855 }
857 if (!m_angularlock.IsIdentical(m_taintAngularLock, 0)) 856 if (!m_angularlock.ApproxEquals(m_taintAngularLock, 0))
858 { 857 {
859 m_log.Debug("[PHYSICS]: TaintAngularLock"); 858 m_log.Debug("[PHYSICS]: TaintAngularLock");
860 changeAngularLock(timestep); 859 changeAngularLock(timestep);
@@ -1017,7 +1016,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1017 { 1016 {
1018 if (_parent_scene.needsMeshing(_pbs)) 1017 if (_parent_scene.needsMeshing(_pbs))
1019 { 1018 {
1020 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); 1019 ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity);
1021 // createmesh returns null when it doesn't mesh. 1020 // createmesh returns null when it doesn't mesh.
1022 CreateGeom(IntPtr.Zero, _mesh); 1021 CreateGeom(IntPtr.Zero, _mesh);
1023 } 1022 }
@@ -1034,7 +1033,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1034 return _parent_scene.needsMeshing(_pbs); 1033 return _parent_scene.needsMeshing(_pbs);
1035 } 1034 }
1036 1035
1037 internal void ProcessGeomCreationAsTriMesh(PhysicsVector positionOffset, Quaternion orientation) 1036 internal void ProcessGeomCreationAsTriMesh(Vector3 positionOffset, Quaternion orientation)
1038 { 1037 {
1039 // Don't need to re-enable body.. it's done in SetMesh 1038 // Don't need to re-enable body.. it's done in SetMesh
1040 float meshlod = _parent_scene.meshSculptLOD; 1039 float meshlod = _parent_scene.meshSculptLOD;
@@ -1043,7 +1042,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1043 meshlod = _parent_scene.MeshSculptphysicalLOD; 1042 meshlod = _parent_scene.MeshSculptphysicalLOD;
1044 1043
1045 IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical); 1044 IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical);
1046 if (!positionOffset.IsIdentical(PhysicsVector.Zero, 0.001f) || orientation != Quaternion.Identity) 1045 if (!positionOffset.ApproxEquals(Vector3.Zero, 0.001f) || orientation != Quaternion.Identity)
1047 { 1046 {
1048 1047
1049 float[] xyz = new float[3]; 1048 float[] xyz = new float[3];
@@ -1207,7 +1206,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1207 //m_log.Info("[PHYSICS]: dequeing forcelist"); 1206 //m_log.Info("[PHYSICS]: dequeing forcelist");
1208 if (IsPhysical) 1207 if (IsPhysical)
1209 { 1208 {
1210 PhysicsVector iforce = new PhysicsVector(); 1209 Vector3 iforce = Vector3.Zero;
1211 for (int i = 0; i < m_forcelist.Count; i++) 1210 for (int i = 0; i < m_forcelist.Count; i++)
1212 { 1211 {
1213 iforce = iforce + m_forcelist[i]; 1212 iforce = iforce + m_forcelist[i];
@@ -1242,7 +1241,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1242 //m_log.Info("[PHYSICS]: dequeing forcelist"); 1241 //m_log.Info("[PHYSICS]: dequeing forcelist");
1243 if (IsPhysical) 1242 if (IsPhysical)
1244 { 1243 {
1245 PhysicsVector iforce = new PhysicsVector(); 1244 Vector3 iforce = Vector3.Zero;
1246 for (int i = 0; i < m_angularforcelist.Count; i++) 1245 for (int i = 0; i < m_angularforcelist.Count; i++)
1247 { 1246 {
1248 iforce = iforce + m_angularforcelist[i]; 1247 iforce = iforce + m_angularforcelist[i];
@@ -1281,7 +1280,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1281 } 1280 }
1282 } 1281 }
1283 } 1282 }
1284 m_taintTorque = new PhysicsVector(0, 0, 0); 1283 m_taintTorque = Vector3.Zero;
1285 } 1284 }
1286 1285
1287 private void changedisable(float timestep) 1286 private void changedisable(float timestep)
@@ -1322,7 +1321,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1322 1321
1323 //resetCollisionAccounting(); 1322 //resetCollisionAccounting();
1324 } 1323 }
1325 m_taintVelocity = PhysicsVector.Zero; 1324 m_taintVelocity = Vector3.Zero;
1326 } 1325 }
1327 1326
1328 private void changelink(float timestep) 1327 private void changelink(float timestep)
@@ -1366,7 +1365,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1366 1365
1367 if (m_taintparent != null) 1366 if (m_taintparent != null)
1368 { 1367 {
1369 m_taintparent.Position.Z = m_taintparent.Position.Z + 0.02f; 1368 Vector3 taintparentPosition = m_taintparent.Position;
1369 taintparentPosition.Z = m_taintparent.Position.Z + 0.02f;
1370 m_taintparent.Position = taintparentPosition;
1370 _parent_scene.AddPhysicsActorTaint(m_taintparent); 1371 _parent_scene.AddPhysicsActorTaint(m_taintparent);
1371 } 1372 }
1372 } 1373 }
@@ -1387,7 +1388,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1387 { 1388 {
1388 if (_parent == null) 1389 if (_parent == null)
1389 { 1390 {
1390 if (!m_taintAngularLock.IsIdentical(new PhysicsVector(1f, 1f, 1f), 0)) 1391 if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f))
1391 { 1392 {
1392 //d.BodySetFiniteRotationMode(Body, 0); 1393 //d.BodySetFiniteRotationMode(Body, 0);
1393 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z); 1394 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z);
@@ -1400,7 +1401,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1400 } 1401 }
1401 1402
1402 } 1403 }
1403 m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z); 1404 m_angularlock = m_taintAngularLock;
1404 1405
1405 } 1406 }
1406 #endregion 1407 #endregion
@@ -1465,17 +1466,17 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1465 // TODO: NEED btVector3 for Linear Velocity 1466 // TODO: NEED btVector3 for Linear Velocity
1466 // NEED btVector3 for Position 1467 // NEED btVector3 for Position
1467 1468
1468 PhysicsVector pos = new PhysicsVector(_position.X, _position.Y, _position.Z); //TODO: Insert values gotten from bullet 1469 Vector3 pos = _position; //TODO: Insert values gotten from bullet
1469 PhysicsVector vel = new PhysicsVector(_velocity.X, _velocity.Y, _velocity.Z); 1470 Vector3 vel = _velocity;
1470 1471
1471 _target_velocity = 1472 _target_velocity =
1472 new PhysicsVector( 1473 new Vector3(
1473 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), 1474 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1474 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep), 1475 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
1475 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep) 1476 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
1476 ); 1477 );
1477 1478
1478 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) 1479 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
1479 { 1480 {
1480 1481
1481 /* TODO: Do Bullet equiv 1482 /* TODO: Do Bullet equiv
@@ -1517,8 +1518,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1517 { 1518 {
1518 PID_G = m_PIDTau + 1; 1519 PID_G = m_PIDTau + 1;
1519 } 1520 }
1520 PhysicsVector pos = new PhysicsVector(0, 0, 0); //TODO: Insert values gotten from bullet 1521 Vector3 pos = Vector3.Zero; //TODO: Insert values gotten from bullet
1521 PhysicsVector vel = new PhysicsVector(0, 0, 0); 1522 Vector3 vel = Vector3.Zero;
1522 1523
1523 // determine what our target height really is based on HoverType 1524 // determine what our target height really is based on HoverType
1524 switch (m_PIDHoverType) 1525 switch (m_PIDHoverType)
@@ -1550,13 +1551,13 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1550 1551
1551 1552
1552 _target_velocity = 1553 _target_velocity =
1553 new PhysicsVector(0.0f, 0.0f, 1554 new Vector3(0.0f, 0.0f,
1554 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep) 1555 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
1555 ); 1556 );
1556 1557
1557 // if velocity is zero, use position control; otherwise, velocity control 1558 // if velocity is zero, use position control; otherwise, velocity control
1558 1559
1559 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) 1560 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
1560 { 1561 {
1561 1562
1562 /* TODO: Do Bullet Equiv 1563 /* TODO: Do Bullet Equiv
@@ -1631,8 +1632,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1631 else 1632 else
1632 { 1633 {
1633 if (m_zeroPosition == null) 1634 if (m_zeroPosition == null)
1634 m_zeroPosition = new PhysicsVector(0, 0, 0); 1635 m_zeroPosition = Vector3.Zero;
1635 m_zeroPosition.setValues(_position.X, _position.Y, _position.Z); 1636 m_zeroPosition = _position;
1636 return; 1637 return;
1637 } 1638 }
1638 } 1639 }
@@ -2182,7 +2183,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2182 2183
2183 //if (hasTrimesh) 2184 //if (hasTrimesh)
2184 //{ 2185 //{
2185 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); 2186 ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity);
2186 // createmesh returns null when it doesn't mesh. 2187 // createmesh returns null when it doesn't mesh.
2187 2188
2188 /* 2189 /*
@@ -2202,11 +2203,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2202 { 2203 {
2203 if (chld == null) 2204 if (chld == null)
2204 continue; 2205 continue;
2205 PhysicsVector offset = chld.Position - Position; 2206 Vector3 offset = chld.Position - Position;
2206 Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z); 2207 Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z);
2207 pos *= Quaternion.Inverse(Orientation); 2208 pos *= Quaternion.Inverse(Orientation);
2208 //pos *= Orientation; 2209 //pos *= Orientation;
2209 offset.setValues(pos.X, pos.Y, pos.Z); 2210 offset = pos;
2210 chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation); 2211 chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation);
2211 2212
2212 _mesh.Append(chld._mesh); 2213 _mesh.Append(chld._mesh);
@@ -2438,7 +2439,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2438 m_collisionscore = 0; 2439 m_collisionscore = 0;
2439 m_disabled = false; 2440 m_disabled = false;
2440 // The body doesn't already have a finite rotation mode set here 2441 // The body doesn't already have a finite rotation mode set here
2441 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 2442 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
2442 { 2443 {
2443 // TODO: Create Angular Motor on Axis Lock! 2444 // TODO: Create Angular Motor on Axis Lock!
2444 } 2445 }
@@ -2452,7 +2453,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2452 { 2453 {
2453 if (_parent == null) 2454 if (_parent == null)
2454 { 2455 {
2455 PhysicsVector pv = new PhysicsVector(0, 0, 0); 2456 Vector3 pv = Vector3.Zero;
2456 bool lastZeroFlag = _zeroFlag; 2457 bool lastZeroFlag = _zeroFlag;
2457 if (tempPosition3 != null && tempPosition3.Handle != IntPtr.Zero) 2458 if (tempPosition3 != null && tempPosition3.Handle != IntPtr.Zero)
2458 tempPosition3.Dispose(); 2459 tempPosition3.Dispose();
@@ -2476,10 +2477,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2476 tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel 2477 tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel
2477 tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel 2478 tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel
2478 2479
2479 _torque.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(), 2480 _torque = new Vector3(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(),
2480 tempAngularVelocity1.getZ()); 2481 tempAngularVelocity1.getZ());
2481 PhysicsVector l_position = new PhysicsVector(); 2482 Vector3 l_position = Vector3.Zero;
2482 Quaternion l_orientation = new Quaternion(); 2483 Quaternion l_orientation = Quaternion.Identity;
2483 m_lastposition = _position; 2484 m_lastposition = _position;
2484 m_lastorientation = _orientation; 2485 m_lastorientation = _orientation;
2485 2486
@@ -2603,20 +2604,18 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2603 _velocity.Z = tempLinearVelocity1.getZ(); 2604 _velocity.Z = tempLinearVelocity1.getZ();
2604 2605
2605 _acceleration = ((_velocity - m_lastVelocity) / 0.1f); 2606 _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
2606 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, 2607 _acceleration = new Vector3(_velocity.X - m_lastVelocity.X / 0.1f,
2607 _velocity.Y - m_lastVelocity.Y / 0.1f, 2608 _velocity.Y - m_lastVelocity.Y / 0.1f,
2608 _velocity.Z - m_lastVelocity.Z / 0.1f); 2609 _velocity.Z - m_lastVelocity.Z / 0.1f);
2609 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); 2610 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
2610 2611
2611 if (_velocity.IsIdentical(pv, 0.5f)) 2612 if (_velocity.ApproxEquals(pv, 0.5f))
2612 { 2613 {
2613 m_rotationalVelocity = pv; 2614 m_rotationalVelocity = pv;
2614 } 2615 }
2615 else 2616 else
2616 { 2617 {
2617 2618 m_rotationalVelocity = new Vector3(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(), tempAngularVelocity1.getZ());
2618 m_rotationalVelocity.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(),
2619 tempAngularVelocity1.getZ());
2620 } 2619 }
2621 2620
2622 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString()); 2621 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString());
@@ -2670,7 +2669,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2670 m_taintremove = true; 2669 m_taintremove = true;
2671 } 2670 }
2672 2671
2673 internal void EnableAxisMotor(PhysicsVector axislock) 2672 internal void EnableAxisMotor(Vector3 axislock)
2674 { 2673 {
2675 if (m_aMotor != null) 2674 if (m_aMotor != null)
2676 DisableAxisMotor(); 2675 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;