diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 91 |
1 files changed, 89 insertions, 2 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f9c2193..72d96d1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -2681,6 +2681,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2681 | /// <summary> | 2681 | /// <summary> |
2682 | /// Link the prims in a given group to this group | 2682 | /// Link the prims in a given group to this group |
2683 | /// </summary> | 2683 | /// </summary> |
2684 | /// <remarks> | ||
2685 | /// Do not call this method directly - use Scene.LinkObjects() instead to avoid races between threads. | ||
2686 | /// FIXME: There are places where scripts call these methods directly without locking. This is a potential race condition. | ||
2687 | /// </remarks> | ||
2684 | /// <param name="objectGroup">The group of prims which should be linked to this group</param> | 2688 | /// <param name="objectGroup">The group of prims which should be linked to this group</param> |
2685 | public void LinkToGroup(SceneObjectGroup objectGroup) | 2689 | public void LinkToGroup(SceneObjectGroup objectGroup) |
2686 | { | 2690 | { |
@@ -2762,6 +2766,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2762 | } | 2766 | } |
2763 | 2767 | ||
2764 | linkPart.LinkNum = linkNum++; | 2768 | linkPart.LinkNum = linkNum++; |
2769 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2765 | 2770 | ||
2766 | SceneObjectPart[] ogParts = objectGroup.Parts; | 2771 | SceneObjectPart[] ogParts = objectGroup.Parts; |
2767 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) | 2772 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) |
@@ -2813,6 +2818,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2813 | /// Delink the given prim from this group. The delinked prim is established as | 2818 | /// Delink the given prim from this group. The delinked prim is established as |
2814 | /// an independent SceneObjectGroup. | 2819 | /// an independent SceneObjectGroup. |
2815 | /// </summary> | 2820 | /// </summary> |
2821 | /// <remarks> | ||
2822 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2823 | /// condition. But currently there is no | ||
2824 | /// alternative method that does take a lonk to delink a single prim. | ||
2825 | /// </remarks> | ||
2816 | /// <param name="partID"></param> | 2826 | /// <param name="partID"></param> |
2817 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> | 2827 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> |
2818 | public SceneObjectGroup DelinkFromGroup(uint partID) | 2828 | public SceneObjectGroup DelinkFromGroup(uint partID) |
@@ -2824,6 +2834,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2824 | /// Delink the given prim from this group. The delinked prim is established as | 2834 | /// Delink the given prim from this group. The delinked prim is established as |
2825 | /// an independent SceneObjectGroup. | 2835 | /// an independent SceneObjectGroup. |
2826 | /// </summary> | 2836 | /// </summary> |
2837 | /// <remarks> | ||
2838 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2839 | /// condition. But currently there is no | ||
2840 | /// alternative method that does take a lonk to delink a single prim. | ||
2841 | /// </remarks> | ||
2827 | /// <param name="partID"></param> | 2842 | /// <param name="partID"></param> |
2828 | /// <param name="sendEvents"></param> | 2843 | /// <param name="sendEvents"></param> |
2829 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> | 2844 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> |
@@ -2849,6 +2864,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2849 | /// Delink the given prim from this group. The delinked prim is established as | 2864 | /// Delink the given prim from this group. The delinked prim is established as |
2850 | /// an independent SceneObjectGroup. | 2865 | /// an independent SceneObjectGroup. |
2851 | /// </summary> | 2866 | /// </summary> |
2867 | /// <remarks> | ||
2868 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2869 | /// condition. But currently there is no | ||
2870 | /// alternative method that does take a lonk to delink a single prim. | ||
2871 | /// </remarks> | ||
2852 | /// <param name="partID"></param> | 2872 | /// <param name="partID"></param> |
2853 | /// <param name="sendEvents"></param> | 2873 | /// <param name="sendEvents"></param> |
2854 | /// <returns>The object group of the newly delinked prim.</returns> | 2874 | /// <returns>The object group of the newly delinked prim.</returns> |
@@ -2982,6 +3002,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2982 | oldRot = part.RotationOffset; | 3002 | oldRot = part.RotationOffset; |
2983 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; | 3003 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
2984 | part.RotationOffset = newRot; | 3004 | part.RotationOffset = newRot; |
3005 | |||
3006 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2985 | } | 3007 | } |
2986 | 3008 | ||
2987 | /// <summary> | 3009 | /// <summary> |
@@ -3493,7 +3515,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3493 | 3515 | ||
3494 | //we need to do a terse update even if the move wasn't allowed | 3516 | //we need to do a terse update even if the move wasn't allowed |
3495 | // so that the position is reset in the client (the object snaps back) | 3517 | // so that the position is reset in the client (the object snaps back) |
3496 | ScheduleGroupForTerseUpdate(); | 3518 | RootPart.ScheduleTerseUpdate(); |
3497 | } | 3519 | } |
3498 | 3520 | ||
3499 | /// <summary> | 3521 | /// <summary> |
@@ -4192,7 +4214,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
4192 | for (int i = 0; i < parts.Length; i++) | 4214 | for (int i = 0; i < parts.Length; i++) |
4193 | parts[i].TriggerScriptChangedEvent(val); | 4215 | parts[i].TriggerScriptChangedEvent(val); |
4194 | } | 4216 | } |
4195 | 4217 | ||
4218 | /// <summary> | ||
4219 | /// Returns a count of the number of scripts in this groups parts. | ||
4220 | /// </summary> | ||
4221 | public int ScriptCount() | ||
4222 | { | ||
4223 | int count = 0; | ||
4224 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4225 | for (int i = 0; i < parts.Length; i++) | ||
4226 | count += parts[i].Inventory.ScriptCount(); | ||
4227 | |||
4228 | return count; | ||
4229 | } | ||
4230 | |||
4231 | /// <summary> | ||
4232 | /// A float the value is a representative execution time in milliseconds of all scripts in the link set. | ||
4233 | /// </summary> | ||
4234 | public float ScriptExecutionTime() | ||
4235 | { | ||
4236 | IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>(); | ||
4237 | |||
4238 | if (engines.Length == 0) // No engine at all | ||
4239 | return 0.0f; | ||
4240 | |||
4241 | float time = 0.0f; | ||
4242 | |||
4243 | // get all the scripts in all parts | ||
4244 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4245 | List<TaskInventoryItem> scripts = new List<TaskInventoryItem>(); | ||
4246 | for (int i = 0; i < parts.Length; i++) | ||
4247 | { | ||
4248 | scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL)); | ||
4249 | } | ||
4250 | // extract the UUIDs | ||
4251 | List<UUID> ids = new List<UUID>(scripts.Count); | ||
4252 | foreach (TaskInventoryItem script in scripts) | ||
4253 | { | ||
4254 | if (!ids.Contains(script.ItemID)) | ||
4255 | { | ||
4256 | ids.Add(script.ItemID); | ||
4257 | } | ||
4258 | } | ||
4259 | // Offer the list of script UUIDs to each engine found and accumulate the time | ||
4260 | foreach (IScriptModule e in engines) | ||
4261 | { | ||
4262 | if (e != null) | ||
4263 | { | ||
4264 | time += e.GetScriptExecutionTime(ids); | ||
4265 | } | ||
4266 | } | ||
4267 | return time; | ||
4268 | } | ||
4269 | |||
4270 | /// <summary> | ||
4271 | /// Returns a count of the number of running scripts in this groups parts. | ||
4272 | /// </summary> | ||
4273 | public int RunningScriptCount() | ||
4274 | { | ||
4275 | int count = 0; | ||
4276 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4277 | for (int i = 0; i < parts.Length; i++) | ||
4278 | count += parts[i].Inventory.RunningScriptCount(); | ||
4279 | |||
4280 | return count; | ||
4281 | } | ||
4282 | |||
4196 | public override string ToString() | 4283 | public override string ToString() |
4197 | { | 4284 | { |
4198 | return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); | 4285 | return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); |