remove unnecessary OdeScene._activeprims locking. Code is single-threaded

iar_mods
Justin Clark-Casey (justincc) 2011-11-21 21:15:15 +00:00
parent 7480f2fd0e
commit 82dc7886fc
1 changed files with 48 additions and 55 deletions

View File

@ -194,7 +194,14 @@ namespace OpenSim.Region.Physics.OdePlugin
/// </summary> /// </summary>
private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
/// <summary>
/// Prims in the physics scene.
/// </summary>
private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>();
/// <summary>
/// Prims in the physics scene that are subject to physics, not just collisions.
/// </summary>
private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
/// <summary> /// <summary>
@ -1565,8 +1572,6 @@ namespace OpenSim.Region.Physics.OdePlugin
//} //}
} }
lock (_activeprims)
{
List<OdePrim> removeprims = null; List<OdePrim> removeprims = null;
foreach (OdePrim chr in _activeprims) foreach (OdePrim chr in _activeprims)
{ {
@ -1606,7 +1611,6 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
} }
}
#endregion #endregion
@ -1770,14 +1774,11 @@ namespace OpenSim.Region.Physics.OdePlugin
internal void ActivatePrim(OdePrim prim) internal void ActivatePrim(OdePrim prim)
{ {
// adds active prim.. (ones that should be iterated over in collisions_optimized // adds active prim.. (ones that should be iterated over in collisions_optimized
lock (_activeprims)
{
if (!_activeprims.Contains(prim)) if (!_activeprims.Contains(prim))
_activeprims.Add(prim); _activeprims.Add(prim);
//else //else
// m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent"); // m_log.Warn("[PHYSICS]: Double Entry in _activeprims detected, potential crash immenent");
} }
}
public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
Vector3 size, Quaternion rotation, bool isPhysical, uint localid) Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
@ -2150,7 +2151,6 @@ namespace OpenSim.Region.Physics.OdePlugin
/// <param name="prim"></param> /// <param name="prim"></param>
internal void DeactivatePrim(OdePrim prim) internal void DeactivatePrim(OdePrim prim)
{ {
lock (_activeprims)
_activeprims.Remove(prim); _activeprims.Remove(prim);
} }
@ -2818,14 +2818,11 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
} }
// Move other active objects // Move other active objects
lock (_activeprims)
{
foreach (OdePrim prim in _activeprims) foreach (OdePrim prim in _activeprims)
{ {
prim.m_collisionscore = 0; prim.m_collisionscore = 0;
prim.Move(timeStep); prim.Move(timeStep);
} }
}
//if ((framecount % m_randomizeWater) == 0) //if ((framecount % m_randomizeWater) == 0)
// randomizeWater(waterlevel); // randomizeWater(waterlevel);
@ -2893,10 +2890,8 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
defects.Clear(); defects.Clear();
} }
lock (_activeprims)
{
//if (timeStep < 0.2f) //if (timeStep < 0.2f)
{
foreach (OdePrim prim in _activeprims) foreach (OdePrim prim in _activeprims)
{ {
if (prim.IsPhysical && (d.BodyIsEnabled(prim.Body) || !prim._zeroFlag)) if (prim.IsPhysical && (d.BodyIsEnabled(prim.Body) || !prim._zeroFlag))
@ -2907,8 +2902,6 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
SimulateActorPendingJoints(prim); SimulateActorPendingJoints(prim);
} }
} }
}
}
//DumpJointInfo(); //DumpJointInfo();