aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs8
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs28
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs26
4 files changed, 36 insertions, 28 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index a9b1365..526dbad 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -529,22 +529,20 @@ public class BSCharacter : BSPhysObject
529 // The collision, if it should be reported to the character, is placed in a collection 529 // The collision, if it should be reported to the character, is placed in a collection
530 // that will later be sent to the simulator when SendCollisions() is called. 530 // that will later be sent to the simulator when SendCollisions() is called.
531 CollisionEventUpdate collisionCollection = null; 531 CollisionEventUpdate collisionCollection = null;
532 public override bool Collide(uint collidingWith, BSPhysObject collidee, ActorTypes type, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth) 532 public override bool Collide(uint collidingWith, BSPhysObject collidee, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth)
533 { 533 {
534 // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith);
535
536 bool ret = false; 534 bool ret = false;
537 535
538 // The following makes IsColliding() and IsCollidingGround() work 536 // The following makes IsColliding() and IsCollidingGround() work
539 _collidingStep = Scene.SimulationStep; 537 _collidingStep = Scene.SimulationStep;
540 if (collidingWith == BSScene.TERRAIN_ID || collidingWith == BSScene.GROUNDPLANE_ID) 538 if (collidingWith <= Scene.TerrainManager.HighestTerrainID)
541 { 539 {
542 _collidingGroundStep = Scene.SimulationStep; 540 _collidingGroundStep = Scene.SimulationStep;
543 } 541 }
544 // DetailLog("{0},BSCharacter.Collison,call,with={1}", LocalID, collidingWith); 542 // DetailLog("{0},BSCharacter.Collison,call,with={1}", LocalID, collidingWith);
545 543
546 // throttle collisions to the rate specified in the subscription 544 // throttle collisions to the rate specified in the subscription
547 if (_subscribedEventsMs != 0) { 545 if (SubscribedEvents()) {
548 int nowTime = Scene.SimulationNowTime; 546 int nowTime = Scene.SimulationNowTime;
549 if (nowTime >= _nextCollisionOkTime) { 547 if (nowTime >= _nextCollisionOkTime) {
550 _nextCollisionOkTime = nowTime + _subscribedEventsMs; 548 _nextCollisionOkTime = nowTime + _subscribedEventsMs;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index 969c53e..3fe71e1 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -41,7 +41,7 @@ public abstract class BSPhysObject : PhysicsActor
41{ 41{
42 public abstract BSLinkset Linkset { get; set; } 42 public abstract BSLinkset Linkset { get; set; }
43 43
44 public abstract bool Collide(uint collidingWith, BSPhysObject collidee, ActorTypes type, 44 public abstract bool Collide(uint collidingWith, BSPhysObject collidee,
45 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth); 45 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth);
46 public abstract void SendCollisions(); 46 public abstract void SendCollisions();
47 47
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
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 9c958d5..c38867f 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -583,27 +583,21 @@ public class BSScene : PhysicsScene, IPhysicsParameters
583 return; // don't send collisions to the terrain 583 return; // don't send collisions to the terrain
584 } 584 }
585 585
586 BSPhysObject collider = PhysObjects[localID]; 586 BSPhysObject collider;
587 // TODO: as of this code, terrain was not in the physical object list. 587 if (!PhysObjects.TryGetValue(localID, out collider))
588 // When BSTerrain is created and it will be in the list, we can remove
589 // the possibility that it's not there and just fetch the collidee.
590 BSPhysObject collidee = null;
591
592 ActorTypes type = ActorTypes.Prim;
593 if (collidingWith <= TerrainManager.HighestTerrainID)
594 { 588 {
595 type = ActorTypes.Ground; 589 // If the object that is colliding cannot be found, just ignore the collision.
596 } 590 return;
597 else
598 {
599 collidee = PhysObjects[collidingWith];
600 if (collidee is BSCharacter)
601 type = ActorTypes.Agent;
602 } 591 }
603 592
593 // The terrain is not in the physical object list so 'collidee'
594 // can be null when Collide() is called.
595 BSPhysObject collidee = null;
596 PhysObjects.TryGetValue(collidingWith, out collidee);
597
604 // DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith); 598 // DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith);
605 599
606 if (collider.Collide(collidingWith, collidee, type, collidePoint, collideNormal, penetration)) 600 if (collider.Collide(collidingWith, collidee, collidePoint, collideNormal, penetration))
607 { 601 {
608 // If a collision was posted, remember to send it to the simulator 602 // If a collision was posted, remember to send it to the simulator
609 m_objectsWithCollisions.Add(collider); 603 m_objectsWithCollisions.Add(collider);