aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-25 23:16:12 -0700
committerJohn Hurliman2009-10-26 18:23:43 -0700
commitd199767e6991d6f368661fce9c5a072e564b8a4b (patch)
treed9347b8a424c0164e208f908613aa8fe1511444b /OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
parent* Double the priority on avatar bake texture requests to get avatars rezzing ... (diff)
downloadopensim-SC_OLD-d199767e6991d6f368661fce9c5a072e564b8a4b.zip
opensim-SC_OLD-d199767e6991d6f368661fce9c5a072e564b8a4b.tar.gz
opensim-SC_OLD-d199767e6991d6f368661fce9c5a072e564b8a4b.tar.bz2
opensim-SC_OLD-d199767e6991d6f368661fce9c5a072e564b8a4b.tar.xz
Experimental change of PhysicsVector to Vector3. Untested
Diffstat (limited to 'OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs257
1 files changed, 128 insertions, 129 deletions
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();