Reinsert PhysicsActor variable back into SOP.SubscribeForCollisionEvents() in order to avoid a race condition.
A separate PhysicsActor variable is used in case some other thread removes the PhysicsActor whilst this code is executing. If this is now impossible please revert - just adding this now whilst I remember. Also makes method comment into proper method doc.cpu-performance
parent
b4cb644a05
commit
d06c85ea77
|
@ -4272,10 +4272,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags);
|
// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subscribe for physics collision events if needed for scripts and sounds
|
/// <summary>
|
||||||
|
/// Subscribe for physics collision events if needed for scripts and sounds
|
||||||
|
/// </summary>
|
||||||
public void SubscribeForCollisionEvents()
|
public void SubscribeForCollisionEvents()
|
||||||
{
|
{
|
||||||
if (PhysActor != null)
|
PhysicsActor pa = PhysActor;
|
||||||
|
|
||||||
|
if (pa != null)
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
((AggregateScriptEvents & scriptEvents.collision) != 0) ||
|
((AggregateScriptEvents & scriptEvents.collision) != 0) ||
|
||||||
|
@ -4293,20 +4297,20 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
(CollisionSound != UUID.Zero)
|
(CollisionSound != UUID.Zero)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!PhysActor.SubscribedEvents())
|
if (!pa.SubscribedEvents())
|
||||||
{
|
{
|
||||||
// If not already subscribed for event, set up for a collision event.
|
// If not already subscribed for event, set up for a collision event.
|
||||||
PhysActor.OnCollisionUpdate += PhysicsCollision;
|
pa.OnCollisionUpdate += PhysicsCollision;
|
||||||
PhysActor.SubscribeEvents(1000);
|
pa.SubscribeEvents(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// There is no need to be subscribed to collisions so, if subscribed, remove subscription
|
// There is no need to be subscribed to collisions so, if subscribed, remove subscription
|
||||||
if (PhysActor.SubscribedEvents())
|
if (pa.SubscribedEvents())
|
||||||
{
|
{
|
||||||
PhysActor.OnCollisionUpdate -= PhysicsCollision;
|
pa.OnCollisionUpdate -= PhysicsCollision;
|
||||||
PhysActor.UnSubscribeEvents();
|
pa.UnSubscribeEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue