Add an option to processes physics collisions using FireAndForget.
Off by default but set with [Startup]ShouldUseFireAndForgetForCollsions=true There is a problem with physics colliions sometimes stopping. One suspicion is that the long callback path from the physics engine into the script engine is causing problems. Enabling this feature passes the collision into the script engine on a separate thread and not the main simulation thread. Tester can enable this and see if the collsions stay around. If they still fail, this commit should be reverted and another solution looked for.0.8.2-post-fixes
parent
ce62824b1f
commit
fdb7a804fc
|
@ -423,6 +423,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
private int landMS;
|
private int landMS;
|
||||||
private int spareMS;
|
private int spareMS;
|
||||||
|
|
||||||
|
// A temporary configuration flag to enable using FireAndForget to process
|
||||||
|
// collisions from the physics engine. There is a problem with collisions
|
||||||
|
// stopping sometimes and MB's suspicion is some race condition passing
|
||||||
|
// collisions from the physics engine callback to the script engine.
|
||||||
|
// This causes the collision events to be passed with a FireAndForget
|
||||||
|
// call which should eliminate that linkage. Testers can turn this on
|
||||||
|
// and see if collisions stop. If they don't, the problem is somewhere else.
|
||||||
|
// This feature defaults to 'off' so, by default, the simulator operation
|
||||||
|
// is not changed.
|
||||||
|
public bool ShouldUseFireAndForgetForCollisions = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tick at which the last frame was processed.
|
/// Tick at which the last frame was processed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1075,8 +1086,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_update_presences = startupConfig.GetInt("UpdateAgentsEveryNFrames", m_update_presences);
|
m_update_presences = startupConfig.GetInt("UpdateAgentsEveryNFrames", m_update_presences);
|
||||||
m_update_terrain = startupConfig.GetInt("UpdateTerrainEveryNFrames", m_update_terrain);
|
m_update_terrain = startupConfig.GetInt("UpdateTerrainEveryNFrames", m_update_terrain);
|
||||||
m_update_temp_cleaning = startupConfig.GetInt("UpdateTempCleaningEveryNSeconds", m_update_temp_cleaning);
|
m_update_temp_cleaning = startupConfig.GetInt("UpdateTempCleaningEveryNSeconds", m_update_temp_cleaning);
|
||||||
|
|
||||||
|
if (startupConfig.Contains("ShouldUseFireAndForgetForCollisions"))
|
||||||
|
{
|
||||||
|
ShouldUseFireAndForgetForCollisions = startupConfig.GetBoolean("ShouldUseFireAndForgetForCollisions", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME: Ultimately this should be in a module.
|
// FIXME: Ultimately this should be in a module.
|
||||||
SendPeriodicAppearanceUpdates = false;
|
SendPeriodicAppearanceUpdates = false;
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
private bool shouldUseFireAndForgetForCollisions = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dynamic attributes can be created and deleted as required.
|
/// Dynamic attributes can be created and deleted as required.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2392,7 +2394,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
CollidingMessage = CreateColliderArgs(this, colliders);
|
CollidingMessage = CreateColliderArgs(this, colliders);
|
||||||
|
|
||||||
if (CollidingMessage.Colliders.Count > 0)
|
if (CollidingMessage.Colliders.Count > 0)
|
||||||
notify(LocalId, CollidingMessage);
|
DoNotify(notify, LocalId, CollidingMessage);
|
||||||
|
|
||||||
if (PassCollisions)
|
if (PassCollisions)
|
||||||
sendToRoot = true;
|
sendToRoot = true;
|
||||||
|
@ -2406,7 +2408,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
CollidingMessage = CreateColliderArgs(ParentGroup.RootPart, colliders);
|
CollidingMessage = CreateColliderArgs(ParentGroup.RootPart, colliders);
|
||||||
if (CollidingMessage.Colliders.Count > 0)
|
if (CollidingMessage.Colliders.Count > 0)
|
||||||
notify(ParentGroup.RootPart.LocalId, CollidingMessage);
|
DoNotify(notify, ParentGroup.RootPart.LocalId, CollidingMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2421,7 +2423,33 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
colliding.Add(CreateDetObjectForGround());
|
colliding.Add(CreateDetObjectForGround());
|
||||||
LandCollidingMessage.Colliders = colliding;
|
LandCollidingMessage.Colliders = colliding;
|
||||||
|
|
||||||
notify(LocalId, LandCollidingMessage);
|
DoNotify(notify, LocalId, LandCollidingMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoNotify(ScriptCollidingNotification notify, uint id, ColliderArgs collargs)
|
||||||
|
{
|
||||||
|
if (m_parentGroup != null && ParentGroup.Scene != null && ParentGroup.Scene.ShouldUseFireAndForgetForCollisions)
|
||||||
|
{
|
||||||
|
// For those learning C#, FireAndForget takes a function, an object to pass
|
||||||
|
// to that function and an ID string. The "oo => {}" construct is a lambda expression
|
||||||
|
// for a function with one arguement ('oo'). The 'new Object[] {}" construct creates an Object
|
||||||
|
// that is an object array and initializes it with three items (the parameters
|
||||||
|
// being passed). The parameters passed are the function to call ('notify') and
|
||||||
|
// its two arguements. Finally, once in the function (called later by the FireAndForget
|
||||||
|
// thread scheduler), the passed object is cast to an object array and then each
|
||||||
|
// of its items (aoo[0] to aoo[2]) are individually cast to what they are and
|
||||||
|
// then used in a call of the passed ScriptCollidingNotification function.
|
||||||
|
Util.FireAndForget(oo =>
|
||||||
|
{
|
||||||
|
Object[] aoo = (Object[])oo;
|
||||||
|
((ScriptCollidingNotification)aoo[0])((uint)aoo[1], (ColliderArgs)aoo[2]);
|
||||||
|
|
||||||
|
}, new Object[] { notify, id, collargs }, "SOP.Collision");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
notify(id, collargs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue