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/BulletDotNETCharacter.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/BulletDotNETCharacter.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs | 96 |
1 files changed, 44 insertions, 52 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 | ||