diff options
author | Robert Adams | 2015-08-02 22:31:53 -0700 |
---|---|---|
committer | Robert Adams | 2015-08-02 22:31:53 -0700 |
commit | fdb7a804fcbcddec0e2f2edc15ad1ede1bfee2aa (patch) | |
tree | 11c29fa37155b08858ac991b85d855af32cb6311 /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |
parent | Add HGFSAssetService to the HypergridService to provide HG support for FSAssets. (diff) | |
download | opensim-SC-fdb7a804fcbcddec0e2f2edc15ad1ede1bfee2aa.zip opensim-SC-fdb7a804fcbcddec0e2f2edc15ad1ede1bfee2aa.tar.gz opensim-SC-fdb7a804fcbcddec0e2f2edc15ad1ede1bfee2aa.tar.bz2 opensim-SC-fdb7a804fcbcddec0e2f2edc15ad1ede1bfee2aa.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 781c20c..f52c9c8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -126,6 +126,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
126 | 126 | ||
127 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 127 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
128 | 128 | ||
129 | private bool shouldUseFireAndForgetForCollisions = true; | ||
130 | |||
129 | /// <summary> | 131 | /// <summary> |
130 | /// Dynamic attributes can be created and deleted as required. | 132 | /// Dynamic attributes can be created and deleted as required. |
131 | /// </summary> | 133 | /// </summary> |
@@ -2392,7 +2394,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2392 | CollidingMessage = CreateColliderArgs(this, colliders); | 2394 | CollidingMessage = CreateColliderArgs(this, colliders); |
2393 | 2395 | ||
2394 | if (CollidingMessage.Colliders.Count > 0) | 2396 | if (CollidingMessage.Colliders.Count > 0) |
2395 | notify(LocalId, CollidingMessage); | 2397 | DoNotify(notify, LocalId, CollidingMessage); |
2396 | 2398 | ||
2397 | if (PassCollisions) | 2399 | if (PassCollisions) |
2398 | sendToRoot = true; | 2400 | sendToRoot = true; |
@@ -2406,7 +2408,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2406 | { | 2408 | { |
2407 | CollidingMessage = CreateColliderArgs(ParentGroup.RootPart, colliders); | 2409 | CollidingMessage = CreateColliderArgs(ParentGroup.RootPart, colliders); |
2408 | if (CollidingMessage.Colliders.Count > 0) | 2410 | if (CollidingMessage.Colliders.Count > 0) |
2409 | notify(ParentGroup.RootPart.LocalId, CollidingMessage); | 2411 | DoNotify(notify, ParentGroup.RootPart.LocalId, CollidingMessage); |
2410 | } | 2412 | } |
2411 | } | 2413 | } |
2412 | } | 2414 | } |
@@ -2421,7 +2423,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
2421 | colliding.Add(CreateDetObjectForGround()); | 2423 | colliding.Add(CreateDetObjectForGround()); |
2422 | LandCollidingMessage.Colliders = colliding; | 2424 | LandCollidingMessage.Colliders = colliding; |
2423 | 2425 | ||
2424 | notify(LocalId, LandCollidingMessage); | 2426 | DoNotify(notify, LocalId, LandCollidingMessage); |
2427 | } | ||
2428 | } | ||
2429 | |||
2430 | private void DoNotify(ScriptCollidingNotification notify, uint id, ColliderArgs collargs) | ||
2431 | { | ||
2432 | if (m_parentGroup != null && ParentGroup.Scene != null && ParentGroup.Scene.ShouldUseFireAndForgetForCollisions) | ||
2433 | { | ||
2434 | // For those learning C#, FireAndForget takes a function, an object to pass | ||
2435 | // to that function and an ID string. The "oo => {}" construct is a lambda expression | ||
2436 | // for a function with one arguement ('oo'). The 'new Object[] {}" construct creates an Object | ||
2437 | // that is an object array and initializes it with three items (the parameters | ||
2438 | // being passed). The parameters passed are the function to call ('notify') and | ||
2439 | // its two arguements. Finally, once in the function (called later by the FireAndForget | ||
2440 | // thread scheduler), the passed object is cast to an object array and then each | ||
2441 | // of its items (aoo[0] to aoo[2]) are individually cast to what they are and | ||
2442 | // then used in a call of the passed ScriptCollidingNotification function. | ||
2443 | Util.FireAndForget(oo => | ||
2444 | { | ||
2445 | Object[] aoo = (Object[])oo; | ||
2446 | ((ScriptCollidingNotification)aoo[0])((uint)aoo[1], (ColliderArgs)aoo[2]); | ||
2447 | |||
2448 | }, new Object[] { notify, id, collargs }, "SOP.Collision"); | ||
2449 | } | ||
2450 | else | ||
2451 | { | ||
2452 | notify(id, collargs); | ||
2425 | } | 2453 | } |
2426 | } | 2454 | } |
2427 | 2455 | ||