aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
authorRobert Adams2012-10-09 12:58:06 -0700
committerRobert Adams2012-10-11 14:01:07 -0700
commit68698975f1537725a1f53bc4b2db2cfc798ac7f3 (patch)
tree7a021b67a3bde146160a1e7d8befef053698e71e /OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
parentBulletSim: Fix crash when linking large physical linksets. (diff)
downloadopensim-SC-68698975f1537725a1f53bc4b2db2cfc798ac7f3.zip
opensim-SC-68698975f1537725a1f53bc4b2db2cfc798ac7f3.tar.gz
opensim-SC-68698975f1537725a1f53bc4b2db2cfc798ac7f3.tar.bz2
opensim-SC-68698975f1537725a1f53bc4b2db2cfc798ac7f3.tar.xz
BulletSim: Add Force* operations to objects to allow direct push to engine.
Update BSDynamics to use same (don't want to delay updates til next taint-time. Suppress queuing a taint update for position and orientation calls if value does not change. Move Bullet timing statistics call from C# back to C++ code. Throttle taints per simulation step and add parameter to set. By default, don't create hulls for physical objects. Add a parameter to turn on and off.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs33
1 files changed, 29 insertions, 4 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 98a18a1..d408be0 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -265,6 +265,11 @@ public sealed class BSPrim : BSPhysObject
265 return _position; 265 return _position;
266 } 266 }
267 set { 267 set {
268 // If you must push the position into the physics engine, use ForcePosition.
269 if (_position == value)
270 {
271 return;
272 }
268 _position = value; 273 _position = value;
269 // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? 274 // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint?
270 PositionSanityCheck(); 275 PositionSanityCheck();
@@ -453,7 +458,6 @@ public sealed class BSPrim : BSPhysObject
453 } 458 }
454 return; 459 return;
455 } 460 }
456
457 public override OMV.Vector3 Velocity { 461 public override OMV.Vector3 Velocity {
458 get { return _velocity; } 462 get { return _velocity; }
459 set { 463 set {
@@ -465,6 +469,13 @@ public sealed class BSPrim : BSPhysObject
465 }); 469 });
466 } 470 }
467 } 471 }
472 public override OMV.Vector3 ForceVelocity {
473 get { return _velocity; }
474 set {
475 _velocity = value;
476 BulletSimAPI.SetLinearVelocity2(BSBody.ptr, _velocity);
477 }
478 }
468 public override OMV.Vector3 Torque { 479 public override OMV.Vector3 Torque {
469 get { return _torque; } 480 get { return _torque; }
470 set { _torque = value; 481 set { _torque = value;
@@ -490,6 +501,8 @@ public sealed class BSPrim : BSPhysObject
490 return _orientation; 501 return _orientation;
491 } 502 }
492 set { 503 set {
504 if (_orientation == value)
505 return;
493 _orientation = value; 506 _orientation = value;
494 // TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint? 507 // TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint?
495 PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate() 508 PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate()
@@ -621,9 +634,9 @@ public sealed class BSPrim : BSPhysObject
621 // There can be special things needed for implementing linksets 634 // There can be special things needed for implementing linksets
622 Linkset.MakeStatic(this); 635 Linkset.MakeStatic(this);
623 // The activation state is 'disabled' so Bullet will not try to act on it. 636 // The activation state is 'disabled' so Bullet will not try to act on it.
624 // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.DISABLE_SIMULATION); 637 BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.DISABLE_SIMULATION);
625 // Start it out sleeping and physical actions could wake it up. 638 // Start it out sleeping and physical actions could wake it up.
626 BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ISLAND_SLEEPING); 639 // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ISLAND_SLEEPING);
627 640
628 BSBody.collisionFilter = CollisionFilterGroups.StaticObjectFilter; 641 BSBody.collisionFilter = CollisionFilterGroups.StaticObjectFilter;
629 BSBody.collisionMask = CollisionFilterGroups.StaticObjectMask; 642 BSBody.collisionMask = CollisionFilterGroups.StaticObjectMask;
@@ -640,6 +653,9 @@ public sealed class BSPrim : BSPhysObject
640 // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 653 // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382
641 BulletSimAPI.ClearAllForces2(BSBody.ptr); 654 BulletSimAPI.ClearAllForces2(BSBody.ptr);
642 655
656 // For good measure, make sure the transform is set through to the motion state
657 BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation);
658
643 // A dynamic object has mass 659 // A dynamic object has mass
644 IntPtr collisionShapePtr = BulletSimAPI.GetCollisionShape2(BSBody.ptr); 660 IntPtr collisionShapePtr = BulletSimAPI.GetCollisionShape2(BSBody.ptr);
645 OMV.Vector3 inertia = BulletSimAPI.CalculateLocalInertia2(collisionShapePtr, Mass); 661 OMV.Vector3 inertia = BulletSimAPI.CalculateLocalInertia2(collisionShapePtr, Mass);
@@ -776,6 +792,15 @@ public sealed class BSPrim : BSPhysObject
776 }); 792 });
777 } 793 }
778 } 794 }
795 public override OMV.Vector3 ForceRotationalVelocity {
796 get {
797 return _rotationalVelocity;
798 }
799 set {
800 _rotationalVelocity = value;
801 BulletSimAPI.SetAngularVelocity2(BSBody.ptr, _rotationalVelocity);
802 }
803 }
779 public override bool Kinematic { 804 public override bool Kinematic {
780 get { return _kinematic; } 805 get { return _kinematic; }
781 set { _kinematic = value; 806 set { _kinematic = value;
@@ -1307,7 +1332,7 @@ public sealed class BSPrim : BSPhysObject
1307 /* 1332 /*
1308 else 1333 else
1309 { 1334 {
1310 // For debugging, we can also report the movement of children 1335 // For debugging, report the movement of children
1311 DetailLog("{0},BSPrim.UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}", 1336 DetailLog("{0},BSPrim.UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
1312 LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, 1337 LocalID, entprop.Position, entprop.Rotation, entprop.Velocity,
1313 entprop.Acceleration, entprop.RotationalVelocity); 1338 entprop.Acceleration, entprop.RotationalVelocity);