aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.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/BulletDotNETCharacter.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/BulletDotNETCharacter.cs')
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs96
1 files changed, 44 insertions, 52 deletions
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
index 8da9687..5ed3b14 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
@@ -60,15 +60,15 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
60 private btQuaternion m_bodyOrientation; 60 private btQuaternion m_bodyOrientation;
61 private btDefaultMotionState m_bodyMotionState; 61 private btDefaultMotionState m_bodyMotionState;
62 private btGeneric6DofConstraint m_aMotor; 62 private btGeneric6DofConstraint m_aMotor;
63 // private PhysicsVector m_movementComparision; 63 // private Vector3 m_movementComparision;
64 private PhysicsVector m_position; 64 private Vector3 m_position;
65 private PhysicsVector m_zeroPosition; 65 private Vector3 m_zeroPosition;
66 private bool m_zeroFlag = false; 66 private bool m_zeroFlag = false;
67 private bool m_lastUpdateSent = false; 67 private bool m_lastUpdateSent = false;
68 private PhysicsVector m_velocity; 68 private Vector3 m_velocity;
69 private PhysicsVector m_target_velocity; 69 private Vector3 m_target_velocity;
70 private PhysicsVector m_acceleration; 70 private Vector3 m_acceleration;
71 private PhysicsVector m_rotationalVelocity; 71 private Vector3 m_rotationalVelocity;
72 private bool m_pidControllerActive = true; 72 private bool m_pidControllerActive = true;
73 public float PID_D = 80.0f; 73 public float PID_D = 80.0f;
74 public float PID_P = 90.0f; 74 public float PID_P = 90.0f;
@@ -96,8 +96,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
96 private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes. 96 private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes.
97 private bool m_taintRemove = false; 97 private bool m_taintRemove = false;
98 // private bool m_taintedPosition = false; 98 // private bool m_taintedPosition = false;
99 // private PhysicsVector m_taintedPosition_value; 99 // private Vector3 m_taintedPosition_value;
100 private PhysicsVector m_taintedForce; 100 private Vector3 m_taintedForce;
101 101
102 private float m_buoyancy = 0f; 102 private float m_buoyancy = 0f;
103 103
@@ -115,14 +115,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
115 public int m_eventsubscription = 0; 115 public int m_eventsubscription = 0;
116 // private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); 116 // private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
117 117
118 public BulletDotNETCharacter(string avName, BulletDotNETScene parent_scene, PhysicsVector pos, PhysicsVector size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) 118 public BulletDotNETCharacter(string avName, BulletDotNETScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor)
119 { 119 {
120 m_taintedForce = new PhysicsVector();
121 m_velocity = new PhysicsVector();
122 m_target_velocity = new PhysicsVector();
123 m_position = pos; 120 m_position = pos;
124 m_zeroPosition = new PhysicsVector(pos.X, pos.Y, pos.Z); // this is a class, not a struct. Must make new, or m_zeroPosition will == position regardless 121 m_zeroPosition = pos;
125 m_acceleration = new PhysicsVector();
126 m_parent_scene = parent_scene; 122 m_parent_scene = parent_scene;
127 PID_D = pid_d; 123 PID_D = pid_d;
128 PID_P = pid_p; 124 PID_P = pid_p;
@@ -161,9 +157,6 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
161 tempTrans1 = new btTransform(tempQuat1, tempVector1); 157 tempTrans1 = new btTransform(tempQuat1, tempVector1);
162 // m_movementComparision = new PhysicsVector(0, 0, 0); 158 // m_movementComparision = new PhysicsVector(0, 0, 0);
163 m_CapsuleOrientationAxis = new btVector3(1, 0, 1); 159 m_CapsuleOrientationAxis = new btVector3(1, 0, 1);
164
165
166
167 } 160 }
168 161
169 /// <summary> 162 /// <summary>
@@ -254,18 +247,18 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
254 get { return m_zeroFlag; } 247 get { return m_zeroFlag; }
255 } 248 }
256 249
257 public override PhysicsVector Size 250 public override Vector3 Size
258 { 251 {
259 get { return new PhysicsVector(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } 252 get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); }
260 set 253 set
261 { 254 {
262 m_pidControllerActive = true; 255 m_pidControllerActive = true;
263 256
264 PhysicsVector SetSize = value; 257 Vector3 SetSize = value;
265 m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f; 258 m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
266 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); 259 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
267 260
268 Velocity = new PhysicsVector(0f, 0f, 0f); 261 Velocity = Vector3.Zero;
269 262
270 m_parent_scene.AddPhysicsActorTaint(this); 263 m_parent_scene.AddPhysicsActorTaint(this);
271 } 264 }
@@ -317,12 +310,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
317 310
318 } 311 }
319 312
320 public override void LockAngularMotion(PhysicsVector axis) 313 public override void LockAngularMotion(Vector3 axis)
321 { 314 {
322 315
323 } 316 }
324 317
325 public override PhysicsVector Position 318 public override Vector3 Position
326 { 319 {
327 get { return m_position; } 320 get { return m_position; }
328 set 321 set
@@ -342,9 +335,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
342 } 335 }
343 } 336 }
344 337
345 public override PhysicsVector Force 338 public override Vector3 Force
346 { 339 {
347 get { return new PhysicsVector(m_target_velocity.X, m_target_velocity.Y, m_target_velocity.Z); } 340 get { return m_target_velocity; }
348 set { return; } 341 set { return; }
349 } 342 }
350 343
@@ -359,7 +352,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
359 352
360 } 353 }
361 354
362 public override void VehicleVectorParam(int param, PhysicsVector value) 355 public override void VehicleVectorParam(int param, Vector3 value)
363 { 356 {
364 357
365 } 358 }
@@ -374,23 +367,22 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
374 367
375 } 368 }
376 369
377 public override PhysicsVector GeometricCenter 370 public override Vector3 GeometricCenter
378 { 371 {
379 get { return PhysicsVector.Zero; } 372 get { return Vector3.Zero; }
380 } 373 }
381 374
382 public override PhysicsVector CenterOfMass 375 public override Vector3 CenterOfMass
383 { 376 {
384 get { return PhysicsVector.Zero; } 377 get { return Vector3.Zero; }
385 } 378 }
386 379
387 public override PhysicsVector Velocity 380 public override Vector3 Velocity
388 { 381 {
389 get 382 get
390 { 383 {
391 // There's a problem with PhysicsVector.Zero! Don't Use it Here!
392 if (m_zeroFlag) 384 if (m_zeroFlag)
393 return new PhysicsVector(0f, 0f, 0f); 385 return Vector3.Zero;
394 m_lastUpdateSent = false; 386 m_lastUpdateSent = false;
395 return m_velocity; 387 return m_velocity;
396 } 388 }
@@ -401,9 +393,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
401 } 393 }
402 } 394 }
403 395
404 public override PhysicsVector Torque 396 public override Vector3 Torque
405 { 397 {
406 get { return PhysicsVector.Zero; } 398 get { return Vector3.Zero; }
407 set { return; } 399 set { return; }
408 } 400 }
409 401
@@ -413,7 +405,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
413 set { } 405 set { }
414 } 406 }
415 407
416 public override PhysicsVector Acceleration 408 public override Vector3 Acceleration
417 { 409 {
418 get { return m_acceleration; } 410 get { return m_acceleration; }
419 } 411 }
@@ -586,7 +578,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
586 set { return; } 578 set { return; }
587 } 579 }
588 580
589 public override PhysicsVector RotationalVelocity 581 public override Vector3 RotationalVelocity
590 { 582 {
591 get { return m_rotationalVelocity; } 583 get { return m_rotationalVelocity; }
592 set { m_rotationalVelocity = value; } 584 set { m_rotationalVelocity = value; }
@@ -604,7 +596,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
604 set { m_buoyancy = value; } 596 set { m_buoyancy = value; }
605 } 597 }
606 598
607 public override PhysicsVector PIDTarget { set { return; } } 599 public override Vector3 PIDTarget { set { return; } }
608 public override bool PIDActive { set { return; } } 600 public override bool PIDActive { set { return; } }
609 public override float PIDTau { set { return; } } 601 public override float PIDTau { set { return; } }
610 602
@@ -634,7 +626,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
634 /// </summary> 626 /// </summary>
635 /// <param name="force"></param> 627 /// <param name="force"></param>
636 /// <param name="pushforce">Is this a push by a script?</param> 628 /// <param name="pushforce">Is this a push by a script?</param>
637 public override void AddForce(PhysicsVector force, bool pushforce) 629 public override void AddForce(Vector3 force, bool pushforce)
638 { 630 {
639 if (pushforce) 631 if (pushforce)
640 { 632 {
@@ -656,7 +648,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
656 //m_lastUpdateSent = false; 648 //m_lastUpdateSent = false;
657 } 649 }
658 650
659 public void doForce(PhysicsVector force, bool now) 651 public void doForce(Vector3 force, bool now)
660 { 652 {
661 653
662 tempVector3.setValue(force.X, force.Y, force.Z); 654 tempVector3.setValue(force.X, force.Y, force.Z);
@@ -671,7 +663,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
671 } 663 }
672 } 664 }
673 665
674 public void doImpulse(PhysicsVector force, bool now) 666 public void doImpulse(Vector3 force, bool now)
675 { 667 {
676 668
677 tempVector3.setValue(force.X, force.Y, force.Z); 669 tempVector3.setValue(force.X, force.Y, force.Z);
@@ -686,12 +678,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
686 } 678 }
687 } 679 }
688 680
689 public override void AddAngularForce(PhysicsVector force, bool pushforce) 681 public override void AddAngularForce(Vector3 force, bool pushforce)
690 { 682 {
691 683
692 } 684 }
693 685
694 public override void SetMomentum(PhysicsVector momentum) 686 public override void SetMomentum(Vector3 momentum)
695 { 687 {
696 688
697 } 689 }
@@ -808,7 +800,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
808 800
809 AvatarGeomAndBodyCreation(m_position.X, m_position.Y, 801 AvatarGeomAndBodyCreation(m_position.X, m_position.Y,
810 m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2)); 802 m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2));
811 Velocity = new PhysicsVector(0f, 0f, 0f); 803 Velocity = Vector3.Zero;
812 804
813 } 805 }
814 else 806 else
@@ -852,9 +844,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
852 } 844 }
853 //PidStatus = true; 845 //PidStatus = true;
854 846
855 PhysicsVector vec = new PhysicsVector(); 847 Vector3 vec = Vector3.Zero;
856 848
857 PhysicsVector vel = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); 849 Vector3 vel = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ());
858 850
859 float movementdivisor = 1f; 851 float movementdivisor = 1f;
860 852
@@ -885,7 +877,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
885 // Avatar to Avatar collisions 877 // Avatar to Avatar collisions
886 // Prim to avatar collisions 878 // Prim to avatar collisions
887 879
888 PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); 880 Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
889 vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2); 881 vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2);
890 vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2); 882 vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2);
891 if (m_flying) 883 if (m_flying)
@@ -927,7 +919,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
927 { 919 {
928 // We're colliding with something and we're not flying but we're moving 920 // We're colliding with something and we're not flying but we're moving
929 // This means we're walking or running. 921 // This means we're walking or running.
930 PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); 922 Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
931 vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P; 923 vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P;
932 if (m_target_velocity.X > 0) 924 if (m_target_velocity.X > 0)
933 { 925 {
@@ -1016,7 +1008,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1016 tempVector2 = Body.getInterpolationLinearVelocity(); 1008 tempVector2 = Body.getInterpolationLinearVelocity();
1017 1009
1018 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 1010 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
1019 PhysicsVector vec = new PhysicsVector(tempVector1.getX(),tempVector1.getY(),tempVector1.getZ()); 1011 Vector3 vec = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
1020 1012
1021 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 1013 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
1022 if (vec.X < -10.0f) vec.X = 0.0f; 1014 if (vec.X < -10.0f) vec.X = 0.0f;
@@ -1048,7 +1040,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1048 else 1040 else
1049 { 1041 {
1050 m_lastUpdateSent = false; 1042 m_lastUpdateSent = false;
1051 vec = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); 1043 vec = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ());
1052 m_velocity.X = (vec.X); 1044 m_velocity.X = (vec.X);
1053 m_velocity.Y = (vec.Y); 1045 m_velocity.Y = (vec.Y);
1054 1046