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 ba353c4..66a6520 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.Inverse(parentRot) * worldRot; | 2951 | Quaternion newRot = Quaternion.Inverse(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> |
@@ -4092,7 +4114,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
4092 | for (int i = 0; i < parts.Length; i++) | 4114 | for (int i = 0; i < parts.Length; i++) |
4093 | parts[i].TriggerScriptChangedEvent(val); | 4115 | parts[i].TriggerScriptChangedEvent(val); |
4094 | } | 4116 | } |
4095 | 4117 | ||
4118 | /// <summary> | ||
4119 | /// Returns a count of the number of scripts in this groups parts. | ||
4120 | /// </summary> | ||
4121 | public int ScriptCount() | ||
4122 | { | ||
4123 | int count = 0; | ||
4124 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4125 | for (int i = 0; i < parts.Length; i++) | ||
4126 | count += parts[i].Inventory.ScriptCount(); | ||
4127 | |||
4128 | return count; | ||
4129 | } | ||
4130 | |||
4131 | /// <summary> | ||
4132 | /// A float the value is a representative execution time in milliseconds of all scripts in the link set. | ||
4133 | /// </summary> | ||
4134 | public float ScriptExecutionTime() | ||
4135 | { | ||
4136 | IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>(); | ||
4137 | |||
4138 | if (engines.Length == 0) // No engine at all | ||
4139 | return 0.0f; | ||
4140 | |||
4141 | float time = 0.0f; | ||
4142 | |||
4143 | // get all the scripts in all parts | ||
4144 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4145 | List<TaskInventoryItem> scripts = new List<TaskInventoryItem>(); | ||
4146 | for (int i = 0; i < parts.Length; i++) | ||
4147 | { | ||
4148 | scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL)); | ||
4149 | } | ||
4150 | // extract the UUIDs | ||
4151 | List<UUID> ids = new List<UUID>(scripts.Count); | ||
4152 | foreach (TaskInventoryItem script in scripts) | ||
4153 | { | ||
4154 | if (!ids.Contains(script.ItemID)) | ||
4155 | { | ||
4156 | ids.Add(script.ItemID); | ||
4157 | } | ||
4158 | } | ||
4159 | // Offer the list of script UUIDs to each engine found and accumulate the time | ||
4160 | foreach (IScriptModule e in engines) | ||
4161 | { | ||
4162 | if (e != null) | ||
4163 | { | ||
4164 | time += e.GetScriptExecutionTime(ids); | ||
4165 | } | ||
4166 | } | ||
4167 | return time; | ||
4168 | } | ||
4169 | |||
4170 | /// <summary> | ||
4171 | /// Returns a count of the number of running scripts in this groups parts. | ||
4172 | /// </summary> | ||
4173 | public int RunningScriptCount() | ||
4174 | { | ||
4175 | int count = 0; | ||
4176 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4177 | for (int i = 0; i < parts.Length; i++) | ||
4178 | count += parts[i].Inventory.RunningScriptCount(); | ||
4179 | |||
4180 | return count; | ||
4181 | } | ||
4182 | |||
4096 | public override string ToString() | 4183 | public override string ToString() |
4097 | { | 4184 | { |
4098 | return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); | 4185 | return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); |