From 644db1e5400504ec70b22c3e928873948f1247c3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 17 Aug 2009 09:40:38 +0100 Subject: Add System.Xml reference to the console project --- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 38 +++++++++++++++++++++------ 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index b7030f1..80d7598 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -156,10 +156,10 @@ namespace OpenSim.Region.Physics.OdePlugin private const uint m_regionWidth = Constants.RegionSize; private const uint m_regionHeight = Constants.RegionSize; - + private bool IsLocked = false; private float ODE_STEPSIZE = 0.020f; private float metersInSpace = 29.9f; - + private List RemoveQueue; public float gravityx = 0f; public float gravityy = 0f; public float gravityz = -9.8f; @@ -376,6 +376,7 @@ namespace OpenSim.Region.Physics.OdePlugin // Initialize the mesh plugin public override void Initialise(IMesher meshmerizer, IConfigSource config) { + RemoveQueue = new List(); mesher = meshmerizer; m_config = config; // Defaults @@ -2047,13 +2048,21 @@ namespace OpenSim.Region.Physics.OdePlugin { if (prim is OdePrim) { - lock (OdeLock) + if (!IsLocked) //Fix a deadlock situation.. have we been locked by Simulate? { - OdePrim p = (OdePrim) prim; + lock (OdeLock) + { + OdePrim p = (OdePrim)prim; - p.setPrimForRemoval(); - AddPhysicsActorTaint(prim); - //RemovePrimThreadLocked(p); + p.setPrimForRemoval(); + AddPhysicsActorTaint(prim); + //RemovePrimThreadLocked(p); + } + } + else + { + //Add the prim to a queue which will be removed when Simulate has finished what it's doing. + RemoveQueue.Add(prim); } } } @@ -2575,7 +2584,7 @@ namespace OpenSim.Region.Physics.OdePlugin DeleteRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks CreateRequestedJoints(); // this must be outside of the lock (OdeLock) to avoid deadlocks } - + IsLocked = true; lock (OdeLock) { // Process 10 frames if the sim is running normal.. @@ -2988,6 +2997,19 @@ namespace OpenSim.Region.Physics.OdePlugin d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix); } } + IsLocked = false; + if (RemoveQueue.Count > 0) + { + do + { + if (RemoveQueue[0] != null) + { + RemovePrimThreadLocked((OdePrim)RemoveQueue[0]); + } + RemoveQueue.RemoveAt(0); + } + while (RemoveQueue.Count > 0); + } return fps; } -- cgit v1.1