diff options
author | KittoFlora | 2009-10-27 22:42:55 +0100 |
---|---|---|
committer | KittoFlora | 2009-10-27 22:42:55 +0100 |
commit | 1113b3b6ebba3e358326a7be90b338d8c95af688 (patch) | |
tree | d923340600e5a2699ceaceeb52fd6c45994f334a /OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs | |
parent | llRotLookAt Pt 2 (diff) | |
parent | Merge branch 'master' into vehicles (diff) | |
download | opensim-SC-1113b3b6ebba3e358326a7be90b338d8c95af688.zip opensim-SC-1113b3b6ebba3e358326a7be90b338d8c95af688.tar.gz opensim-SC-1113b3b6ebba3e358326a7be90b338d8c95af688.tar.bz2 opensim-SC-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/BulletDotNETPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs | 257 |
1 files changed, 128 insertions, 129 deletions
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(); |