aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs28
1 files changed, 22 insertions, 6 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 04b7be5..6827be0 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -545,14 +545,31 @@ public sealed class BSPrim : BSPhysObject
545 { 545 {
546 // Not a Bullet static object 546 // Not a Bullet static object
547 m_currentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.CF_STATIC_OBJECT); 547 m_currentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.CF_STATIC_OBJECT);
548
549 // Set various physical properties so internal things will get computed correctly as they are set
550 BulletSimAPI.SetFriction2(BSBody.Ptr, Scene.Params.defaultFriction);
551 BulletSimAPI.SetRestitution2(BSBody.Ptr, Scene.Params.defaultRestitution);
552 // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382
553 BulletSimAPI.SetInterpolationLinearVelocity2(BSBody.Ptr, OMV.Vector3.Zero);
554 BulletSimAPI.SetInterpolationAngularVelocity2(BSBody.Ptr, OMV.Vector3.Zero);
555 BulletSimAPI.SetInterpolationVelocity2(BSBody.Ptr, OMV.Vector3.Zero, OMV.Vector3.Zero);
556
548 // A dynamic object has mass 557 // A dynamic object has mass
549 IntPtr collisionShapePtr = BulletSimAPI.GetCollisionShape2(BSBody.Ptr); 558 IntPtr collisionShapePtr = BulletSimAPI.GetCollisionShape2(BSBody.Ptr);
550 OMV.Vector3 inertia = BulletSimAPI.CalculateLocalInertia2(collisionShapePtr, Linkset.LinksetMass); 559 OMV.Vector3 inertia = BulletSimAPI.CalculateLocalInertia2(collisionShapePtr, Linkset.LinksetMass);
551 BulletSimAPI.SetMassProps2(BSBody.Ptr, _mass, inertia); 560 BulletSimAPI.SetMassProps2(BSBody.Ptr, _mass, inertia);
552 // Inertia is based on our new mass 561 // Inertia is based on our new mass
553 BulletSimAPI.UpdateInertiaTensor2(BSBody.Ptr); 562 BulletSimAPI.UpdateInertiaTensor2(BSBody.Ptr);
563
564 // Various values for simulation limits
565 BulletSimAPI.SetDamping2(BSBody.Ptr, Scene.Params.linearDamping, Scene.Params.angularDamping);
566 BulletSimAPI.SetDeactivationTime2(BSBody.Ptr, Scene.Params.deactivationTime);
567 BulletSimAPI.SetSleepingThresholds2(BSBody.Ptr, Scene.Params.linearSleepingThreshold, Scene.Params.angularSleepingThreshold);
568 BulletSimAPI.SetContactProcessingThreshold2(BSBody.Ptr, Scene.Params.contactProcessingThreshold);
569
554 // There can be special things needed for implementing linksets 570 // There can be special things needed for implementing linksets
555 Linkset.MakeDynamic(this); 571 Linkset.MakeDynamic(this);
572
556 // Force activation of the object so Bullet will act on it. 573 // Force activation of the object so Bullet will act on it.
557 BulletSimAPI.Activate2(BSBody.Ptr, true); 574 BulletSimAPI.Activate2(BSBody.Ptr, true);
558 } 575 }
@@ -1475,16 +1492,15 @@ public sealed class BSPrim : BSPhysObject
1475 // I've collided with something 1492 // I've collided with something
1476 // Called at taint time from within the Step() function 1493 // Called at taint time from within the Step() function
1477 CollisionEventUpdate collisionCollection; 1494 CollisionEventUpdate collisionCollection;
1478 public override bool Collide(uint collidingWith, BSPhysObject collidee, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) 1495 public override bool Collide(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
1479 { 1496 {
1480 // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith);
1481 bool ret = false; 1497 bool ret = false;
1482 1498
1483 // The following lines make IsColliding() and IsCollidingGround() work 1499 // The following lines make IsColliding() and IsCollidingGround() work
1484 _collidingStep = _scene.SimulationStep; 1500 _collidingStep = Scene.SimulationStep;
1485 if (collidingWith == BSScene.TERRAIN_ID || collidingWith == BSScene.GROUNDPLANE_ID) 1501 if (collidingWith <= Scene.TerrainManager.HighestTerrainID)
1486 { 1502 {
1487 _collidingGroundStep = _scene.SimulationStep; 1503 _collidingGroundStep = Scene.SimulationStep;
1488 } 1504 }
1489 1505
1490 // DetailLog("{0},BSPrim.Collison,call,with={1}", LocalID, collidingWith); 1506 // DetailLog("{0},BSPrim.Collison,call,with={1}", LocalID, collidingWith);
@@ -1498,7 +1514,7 @@ public sealed class BSPrim : BSPhysObject
1498 // if someone has subscribed for collision events.... 1514 // if someone has subscribed for collision events....
1499 if (SubscribedEvents()) { 1515 if (SubscribedEvents()) {
1500 // throttle the collisions to the number of milliseconds specified in the subscription 1516 // throttle the collisions to the number of milliseconds specified in the subscription
1501 int nowTime = _scene.SimulationNowTime; 1517 int nowTime = Scene.SimulationNowTime;
1502 if (nowTime >= _nextCollisionOkTime) { 1518 if (nowTime >= _nextCollisionOkTime) {
1503 _nextCollisionOkTime = nowTime + _subscribedEventsMs; 1519 _nextCollisionOkTime = nowTime + _subscribedEventsMs;
1504 1520