aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRobert Adams2014-06-20 21:42:08 -0700
committerRobert Adams2014-06-20 21:42:08 -0700
commit481b7c71c34167e903b8e0d65bc8932076929675 (patch)
tree4231a260d335747ffd8a5ef04d84461ec9175c4e /OpenSim
parentImproved line map heuristics. (diff)
downloadopensim-SC_OLD-481b7c71c34167e903b8e0d65bc8932076929675.zip
opensim-SC_OLD-481b7c71c34167e903b8e0d65bc8932076929675.tar.gz
opensim-SC_OLD-481b7c71c34167e903b8e0d65bc8932076929675.tar.bz2
opensim-SC_OLD-481b7c71c34167e903b8e0d65bc8932076929675.tar.xz
BulletSim: add some locking for collision lists to prevent collsions
from locking up when running BulletSim on a separate thread.
Diffstat (limited to 'OpenSim')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs9
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs10
2 files changed, 15 insertions, 4 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index f89b376..7a46550 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -462,7 +462,10 @@ public abstract class BSPhysObject : PhysicsActor
462 462
463 // If someone has subscribed for collision events log the collision so it will be reported up 463 // If someone has subscribed for collision events log the collision so it will be reported up
464 if (SubscribedEvents()) { 464 if (SubscribedEvents()) {
465 CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); 465 lock (PhysScene.CollisionLock)
466 {
467 CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
468 }
466 DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5},colliderMoving={6}", 469 DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5},colliderMoving={6}",
467 LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth, ColliderIsMoving); 470 LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth, ColliderIsMoving);
468 471
@@ -474,12 +477,14 @@ public abstract class BSPhysObject : PhysicsActor
474 // Send the collected collisions into the simulator. 477 // Send the collected collisions into the simulator.
475 // Called at taint time from within the Step() function thus no locking problems 478 // Called at taint time from within the Step() function thus no locking problems
476 // with CollisionCollection and ObjectsWithNoMoreCollisions. 479 // with CollisionCollection and ObjectsWithNoMoreCollisions.
480 // Called with BSScene.CollisionLock locked to protect the collision lists.
477 // Return 'true' if there were some actual collisions passed up 481 // Return 'true' if there were some actual collisions passed up
478 public virtual bool SendCollisions() 482 public virtual bool SendCollisions()
479 { 483 {
480 bool ret = true; 484 bool ret = true;
481 485
482 // If the 'no collision' call, force it to happen right now so quick collision_end 486 // If no collisions this call but there were collisions last call, force the collision
487 // event to be happen right now so quick collision_end.
483 bool force = (CollisionCollection.Count == 0 && CollisionsLastReported.Count != 0); 488 bool force = (CollisionCollection.Count == 0 && CollisionsLastReported.Count != 0);
484 489
485 // throttle the collisions to the number of milliseconds specified in the subscription 490 // throttle the collisions to the number of milliseconds specified in the subscription
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 23bada9..17d26a9 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -705,7 +705,10 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
705 // this is is under UpdateLock. 705 // this is is under UpdateLock.
706 public void PostUpdate(BSPhysObject updatee) 706 public void PostUpdate(BSPhysObject updatee)
707 { 707 {
708 ObjectsWithUpdates.Add(updatee); 708 lock (UpdateLock)
709 {
710 ObjectsWithUpdates.Add(updatee);
711 }
709 } 712 }
710 713
711 // The simulator thinks it is physics time so return all the collisions and position 714 // The simulator thinks it is physics time so return all the collisions and position
@@ -803,7 +806,10 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
803 if (collider.Collide(collidingWith, collidee, collidePoint, collideNormal, penetration)) 806 if (collider.Collide(collidingWith, collidee, collidePoint, collideNormal, penetration))
804 { 807 {
805 // If a collision was 'good', remember to send it to the simulator 808 // If a collision was 'good', remember to send it to the simulator
806 ObjectsWithCollisions.Add(collider); 809 lock (CollisionLock)
810 {
811 ObjectsWithCollisions.Add(collider);
812 }
807 } 813 }
808 } 814 }
809 815