diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 89 |
1 files changed, 88 insertions, 1 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 76804d7..dce20c1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -2629,6 +2629,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2629 | /// <summary> | 2629 | /// <summary> |
2630 | /// Link the prims in a given group to this group | 2630 | /// Link the prims in a given group to this group |
2631 | /// </summary> | 2631 | /// </summary> |
2632 | /// <remarks> | ||
2633 | /// Do not call this method directly - use Scene.LinkObjects() instead to avoid races between threads. | ||
2634 | /// FIXME: There are places where scripts call these methods directly without locking. This is a potential race condition. | ||
2635 | /// </remarks> | ||
2632 | /// <param name="objectGroup">The group of prims which should be linked to this group</param> | 2636 | /// <param name="objectGroup">The group of prims which should be linked to this group</param> |
2633 | public void LinkToGroup(SceneObjectGroup objectGroup) | 2637 | public void LinkToGroup(SceneObjectGroup objectGroup) |
2634 | { | 2638 | { |
@@ -2710,6 +2714,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2710 | } | 2714 | } |
2711 | 2715 | ||
2712 | linkPart.LinkNum = linkNum++; | 2716 | linkPart.LinkNum = linkNum++; |
2717 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2713 | 2718 | ||
2714 | SceneObjectPart[] ogParts = objectGroup.Parts; | 2719 | SceneObjectPart[] ogParts = objectGroup.Parts; |
2715 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) | 2720 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) |
@@ -2761,6 +2766,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2761 | /// Delink the given prim from this group. The delinked prim is established as | 2766 | /// Delink the given prim from this group. The delinked prim is established as |
2762 | /// an independent SceneObjectGroup. | 2767 | /// an independent SceneObjectGroup. |
2763 | /// </summary> | 2768 | /// </summary> |
2769 | /// <remarks> | ||
2770 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2771 | /// condition. But currently there is no | ||
2772 | /// alternative method that does take a lonk to delink a single prim. | ||
2773 | /// </remarks> | ||
2764 | /// <param name="partID"></param> | 2774 | /// <param name="partID"></param> |
2765 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> | 2775 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> |
2766 | public SceneObjectGroup DelinkFromGroup(uint partID) | 2776 | public SceneObjectGroup DelinkFromGroup(uint partID) |
@@ -2772,6 +2782,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2772 | /// Delink the given prim from this group. The delinked prim is established as | 2782 | /// Delink the given prim from this group. The delinked prim is established as |
2773 | /// an independent SceneObjectGroup. | 2783 | /// an independent SceneObjectGroup. |
2774 | /// </summary> | 2784 | /// </summary> |
2785 | /// <remarks> | ||
2786 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2787 | /// condition. But currently there is no | ||
2788 | /// alternative method that does take a lonk to delink a single prim. | ||
2789 | /// </remarks> | ||
2775 | /// <param name="partID"></param> | 2790 | /// <param name="partID"></param> |
2776 | /// <param name="sendEvents"></param> | 2791 | /// <param name="sendEvents"></param> |
2777 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> | 2792 | /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns> |
@@ -2797,6 +2812,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2797 | /// Delink the given prim from this group. The delinked prim is established as | 2812 | /// Delink the given prim from this group. The delinked prim is established as |
2798 | /// an independent SceneObjectGroup. | 2813 | /// an independent SceneObjectGroup. |
2799 | /// </summary> | 2814 | /// </summary> |
2815 | /// <remarks> | ||
2816 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | ||
2817 | /// condition. But currently there is no | ||
2818 | /// alternative method that does take a lonk to delink a single prim. | ||
2819 | /// </remarks> | ||
2800 | /// <param name="partID"></param> | 2820 | /// <param name="partID"></param> |
2801 | /// <param name="sendEvents"></param> | 2821 | /// <param name="sendEvents"></param> |
2802 | /// <returns>The object group of the newly delinked prim.</returns> | 2822 | /// <returns>The object group of the newly delinked prim.</returns> |
@@ -2930,6 +2950,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2930 | oldRot = part.RotationOffset; | 2950 | oldRot = part.RotationOffset; |
2931 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; | 2951 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
2932 | part.RotationOffset = newRot; | 2952 | part.RotationOffset = newRot; |
2953 | |||
2954 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2933 | } | 2955 | } |
2934 | 2956 | ||
2935 | /// <summary> | 2957 | /// <summary> |
@@ -4140,7 +4162,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
4140 | for (int i = 0; i < parts.Length; i++) | 4162 | for (int i = 0; i < parts.Length; i++) |
4141 | parts[i].TriggerScriptChangedEvent(val); | 4163 | parts[i].TriggerScriptChangedEvent(val); |
4142 | } | 4164 | } |
4143 | 4165 | ||
4166 | /// <summary> | ||
4167 | /// Returns a count of the number of scripts in this groups parts. | ||
4168 | /// </summary> | ||
4169 | public int ScriptCount() | ||
4170 | { | ||
4171 | int count = 0; | ||
4172 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4173 | for (int i = 0; i < parts.Length; i++) | ||
4174 | count += parts[i].Inventory.ScriptCount(); | ||
4175 | |||
4176 | return count; | ||
4177 | } | ||
4178 | |||
4179 | /// <summary> | ||
4180 | /// A float the value is a representative execution time in milliseconds of all scripts in the link set. | ||
4181 | /// </summary> | ||
4182 | public float ScriptExecutionTime() | ||
4183 | { | ||
4184 | IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>(); | ||
4185 | |||
4186 | if (engines.Length == 0) // No engine at all | ||
4187 | return 0.0f; | ||
4188 | |||
4189 | float time = 0.0f; | ||
4190 | |||
4191 | // get all the scripts in all parts | ||
4192 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4193 | List<TaskInventoryItem> scripts = new List<TaskInventoryItem>(); | ||
4194 | for (int i = 0; i < parts.Length; i++) | ||
4195 | { | ||
4196 | scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL)); | ||
4197 | } | ||
4198 | // extract the UUIDs | ||
4199 | List<UUID> ids = new List<UUID>(scripts.Count); | ||
4200 | foreach (TaskInventoryItem script in scripts) | ||
4201 | { | ||
4202 | if (!ids.Contains(script.ItemID)) | ||
4203 | { | ||
4204 | ids.Add(script.ItemID); | ||
4205 | } | ||
4206 | } | ||
4207 | // Offer the list of script UUIDs to each engine found and accumulate the time | ||
4208 | foreach (IScriptModule e in engines) | ||
4209 | { | ||
4210 | if (e != null) | ||
4211 | { | ||
4212 | time += e.GetScriptExecutionTime(ids); | ||
4213 | } | ||
4214 | } | ||
4215 | return time; | ||
4216 | } | ||
4217 | |||
4218 | /// <summary> | ||
4219 | /// Returns a count of the number of running scripts in this groups parts. | ||
4220 | /// </summary> | ||
4221 | public int RunningScriptCount() | ||
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.RunningScriptCount(); | ||
4227 | |||
4228 | return count; | ||
4229 | } | ||
4230 | |||
4144 | public override string ToString() | 4231 | public override string ToString() |
4145 | { | 4232 | { |
4146 | return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); | 4233 | return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); |