add a lock to CollisionEventsThisFrame

avinationmerge
UbitUmarov 2013-01-02 20:06:57 +00:00
parent 7980a1d849
commit be6b6bf191
1 changed files with 30 additions and 21 deletions

View File

@ -1540,8 +1540,11 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (CollisionEventsThisFrame != null) if (CollisionEventsThisFrame != null)
{ {
CollisionEventsThisFrame.Clear(); lock (CollisionEventsThisFrame)
CollisionEventsThisFrame = null; {
CollisionEventsThisFrame.Clear();
CollisionEventsThisFrame = null;
}
} }
m_eventsubscription = 0; m_eventsubscription = 0;
} }
@ -1550,8 +1553,11 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (CollisionEventsThisFrame == null) if (CollisionEventsThisFrame == null)
CollisionEventsThisFrame = new CollisionEventUpdate(); CollisionEventsThisFrame = new CollisionEventUpdate();
CollisionEventsThisFrame.AddCollider(CollidedWith, contact); lock (CollisionEventsThisFrame)
_parent_scene.AddCollisionEventReporting(this); {
CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
_parent_scene.AddCollisionEventReporting(this);
}
} }
public void SendCollisions() public void SendCollisions()
@ -1559,26 +1565,29 @@ namespace OpenSim.Region.Physics.OdePlugin
if (CollisionEventsThisFrame == null) if (CollisionEventsThisFrame == null)
return; return;
if (m_cureventsubscription < m_eventsubscription) lock (CollisionEventsThisFrame)
return;
m_cureventsubscription = 0;
int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
if (!SentEmptyCollisionsEvent || ncolisions > 0)
{ {
base.SendCollisionUpdate(CollisionEventsThisFrame); if (m_cureventsubscription < m_eventsubscription)
return;
if (ncolisions == 0) m_cureventsubscription = 0;
int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
if (!SentEmptyCollisionsEvent || ncolisions > 0)
{ {
SentEmptyCollisionsEvent = true; base.SendCollisionUpdate(CollisionEventsThisFrame);
_parent_scene.RemoveCollisionEventReporting(this);
} if (ncolisions == 0)
else {
{ SentEmptyCollisionsEvent = true;
SentEmptyCollisionsEvent = false; _parent_scene.RemoveCollisionEventReporting(this);
CollisionEventsThisFrame.Clear(); }
else
{
SentEmptyCollisionsEvent = false;
CollisionEventsThisFrame.Clear();
}
} }
} }
} }