From fab0389cb17cd74e47156c58b52dd62b098c8494 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 26 May 2014 20:29:45 -0700 Subject: BulletSim: add locking of PhysObjects while processing simulation step updates and collisions. This is an attempt to fix a crash reported by Justin when doing high velocity teleports. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 34 +++++++++++++++---------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 9fa55ce..23bada9 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -639,15 +639,18 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters { if (collidersCount > 0) { - for (int ii = 0; ii < collidersCount; ii++) + lock (PhysObjects) { - uint cA = m_collisionArray[ii].aID; - uint cB = m_collisionArray[ii].bID; - Vector3 point = m_collisionArray[ii].point; - Vector3 normal = m_collisionArray[ii].normal; - float penetration = m_collisionArray[ii].penetration; - SendCollision(cA, cB, point, normal, penetration); - SendCollision(cB, cA, point, -normal, penetration); + for (int ii = 0; ii < collidersCount; ii++) + { + uint cA = m_collisionArray[ii].aID; + uint cB = m_collisionArray[ii].bID; + Vector3 point = m_collisionArray[ii].point; + Vector3 normal = m_collisionArray[ii].normal; + float penetration = m_collisionArray[ii].penetration; + SendCollision(cA, cB, point, normal, penetration); + SendCollision(cB, cA, point, -normal, penetration); + } } } } @@ -658,14 +661,17 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters { if (updatedEntityCount > 0) { - for (int ii = 0; ii < updatedEntityCount; ii++) + lock (PhysObjects) { - EntityProperties entprop = m_updateArray[ii]; - BSPhysObject pobj; - if (PhysObjects.TryGetValue(entprop.ID, out pobj)) + for (int ii = 0; ii < updatedEntityCount; ii++) { - if (pobj.IsInitialized) - pobj.UpdateProperties(entprop); + EntityProperties entprop = m_updateArray[ii]; + BSPhysObject pobj; + if (PhysObjects.TryGetValue(entprop.ID, out pobj)) + { + if (pobj.IsInitialized) + pobj.UpdateProperties(entprop); + } } } } -- cgit v1.1