diff options
author | Justin Clark-Casey (justincc) | 2011-08-26 23:06:41 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-26 23:06:41 +0100 |
commit | 15a514fcbc8f7447fc3a5997b6bbc2fe35974c9a (patch) | |
tree | 25b452008eb21a6426617c65af866161cf3bcae8 | |
parent | refactor: move SOG.DetachToGround() to AttachmentsModule.DetachSceneObjectToG... (diff) | |
download | opensim-SC_OLD-15a514fcbc8f7447fc3a5997b6bbc2fe35974c9a.zip opensim-SC_OLD-15a514fcbc8f7447fc3a5997b6bbc2fe35974c9a.tar.gz opensim-SC_OLD-15a514fcbc8f7447fc3a5997b6bbc2fe35974c9a.tar.bz2 opensim-SC_OLD-15a514fcbc8f7447fc3a5997b6bbc2fe35974c9a.tar.xz |
refactor: simplify SOP.AttachedAvatar into SOG.AttachedAvatar
This does a tiny bit to reduce code complexity, memory requirement and the cpu time of pointlessly setting this field to the same value in every SOP
7 files changed, 26 insertions, 27 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 93920b0..3e1cb02 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -456,7 +456,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
456 | if (so == null) | 456 | if (so == null) |
457 | return; | 457 | return; |
458 | 458 | ||
459 | if (so.RootPart.AttachedAvatar != remoteClient.AgentId) | 459 | if (so.AttachedAvatar != remoteClient.AgentId) |
460 | return; | 460 | return; |
461 | 461 | ||
462 | UUID inventoryID = so.GetFromItemID(); | 462 | UUID inventoryID = so.GetFromItemID(); |
@@ -498,7 +498,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
498 | 498 | ||
499 | rootPart.FromItemID = UUID.Zero; | 499 | rootPart.FromItemID = UUID.Zero; |
500 | so.AbsolutePosition = sp.AbsolutePosition; | 500 | so.AbsolutePosition = sp.AbsolutePosition; |
501 | so.ForEachPart(part => part.AttachedAvatar = UUID.Zero); | 501 | so.AttachedAvatar = UUID.Zero; |
502 | rootPart.SetParentLocalId(0); | 502 | rootPart.SetParentLocalId(0); |
503 | so.ClearPartAttachmentData(); | 503 | so.ClearPartAttachmentData(); |
504 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim); | 504 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim); |
@@ -534,11 +534,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
534 | sp.RemoveAttachment(group); | 534 | sp.RemoveAttachment(group); |
535 | 535 | ||
536 | // Prepare sog for storage | 536 | // Prepare sog for storage |
537 | group.AttachedAvatar = UUID.Zero; | ||
538 | |||
537 | group.ForEachPart( | 539 | group.ForEachPart( |
538 | delegate(SceneObjectPart part) | 540 | delegate(SceneObjectPart part) |
539 | { | 541 | { |
540 | part.AttachedAvatar = UUID.Zero; | ||
541 | |||
542 | // If there are any scripts, | 542 | // If there are any scripts, |
543 | // then always trigger a new object and state persistence in UpdateKnownItem() | 543 | // then always trigger a new object and state persistence in UpdateKnownItem() |
544 | if (part.Inventory.ContainsScripts()) | 544 | if (part.Inventory.ContainsScripts()) |
@@ -656,12 +656,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
656 | m_scene.DeleteFromStorage(so.UUID); | 656 | m_scene.DeleteFromStorage(so.UUID); |
657 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | 657 | m_scene.EventManager.TriggerParcelPrimCountTainted(); |
658 | 658 | ||
659 | so.RootPart.AttachedAvatar = avatar.UUID; | 659 | so.AttachedAvatar = avatar.UUID; |
660 | |||
661 | //Anakin Lohner bug #3839 | ||
662 | SceneObjectPart[] parts = so.Parts; | ||
663 | for (int i = 0; i < parts.Length; i++) | ||
664 | parts[i].AttachedAvatar = avatar.UUID; | ||
665 | 660 | ||
666 | if (so.RootPart.PhysActor != null) | 661 | if (so.RootPart.PhysActor != null) |
667 | { | 662 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 4595a29..2a76755 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs | |||
@@ -116,14 +116,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
116 | return priority; | 116 | return priority; |
117 | } | 117 | } |
118 | 118 | ||
119 | |||
120 | private uint GetPriorityByTime(IClientAPI client, ISceneEntity entity) | 119 | private uint GetPriorityByTime(IClientAPI client, ISceneEntity entity) |
121 | { | 120 | { |
122 | // And anything attached to this avatar gets top priority as well | 121 | // And anything attached to this avatar gets top priority as well |
123 | if (entity is SceneObjectPart) | 122 | if (entity is SceneObjectPart) |
124 | { | 123 | { |
125 | SceneObjectPart sop = (SceneObjectPart)entity; | 124 | SceneObjectPart sop = (SceneObjectPart)entity; |
126 | if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar) | 125 | if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar) |
127 | return 1; | 126 | return 1; |
128 | } | 127 | } |
129 | 128 | ||
@@ -136,7 +135,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
136 | if (entity is SceneObjectPart) | 135 | if (entity is SceneObjectPart) |
137 | { | 136 | { |
138 | SceneObjectPart sop = (SceneObjectPart)entity; | 137 | SceneObjectPart sop = (SceneObjectPart)entity; |
139 | if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar) | 138 | if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar) |
140 | return 1; | 139 | return 1; |
141 | } | 140 | } |
142 | 141 | ||
@@ -149,7 +148,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
149 | if (entity is SceneObjectPart) | 148 | if (entity is SceneObjectPart) |
150 | { | 149 | { |
151 | SceneObjectPart sop = (SceneObjectPart)entity; | 150 | SceneObjectPart sop = (SceneObjectPart)entity; |
152 | if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar) | 151 | if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar) |
153 | return 1; | 152 | return 1; |
154 | } | 153 | } |
155 | 154 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index e3b8fc8..fada688 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -169,6 +169,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
169 | } | 169 | } |
170 | 170 | ||
171 | /// <summary> | 171 | /// <summary> |
172 | /// The avatar to which this scene object is attached. | ||
173 | /// </summary> | ||
174 | /// <remarks> | ||
175 | /// If we're not attached to an avatar then this is UUID.Zero | ||
176 | /// </remarks> | ||
177 | public UUID AttachedAvatar { get; set; } | ||
178 | |||
179 | /// <summary> | ||
172 | /// Is this scene object phantom? | 180 | /// Is this scene object phantom? |
173 | /// </summary> | 181 | /// </summary> |
174 | /// <remarks> | 182 | /// <remarks> |
@@ -1540,7 +1548,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1540 | { | 1548 | { |
1541 | if (IsAttachment) | 1549 | if (IsAttachment) |
1542 | { | 1550 | { |
1543 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | 1551 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); |
1544 | if (avatar != null) | 1552 | if (avatar != null) |
1545 | { | 1553 | { |
1546 | avatar.PushForce(impulse); | 1554 | avatar.PushForce(impulse); |
@@ -1622,7 +1630,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1622 | { | 1630 | { |
1623 | if (IsAttachment) | 1631 | if (IsAttachment) |
1624 | { | 1632 | { |
1625 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | 1633 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); |
1626 | if (avatar != null) | 1634 | if (avatar != null) |
1627 | { | 1635 | { |
1628 | avatar.MoveToTarget(target, false); | 1636 | avatar.MoveToTarget(target, false); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a0e87d0..e510611 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -221,9 +221,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
221 | public scriptEvents AggregateScriptEvents; | 221 | public scriptEvents AggregateScriptEvents; |
222 | 222 | ||
223 | 223 | ||
224 | public UUID AttachedAvatar; | ||
225 | |||
226 | |||
227 | public Vector3 AttachedPos; | 224 | public Vector3 AttachedPos; |
228 | 225 | ||
229 | 226 | ||
@@ -728,7 +725,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
728 | 725 | ||
729 | if (IsAttachment) | 726 | if (IsAttachment) |
730 | { | 727 | { |
731 | ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); | 728 | ScenePresence sp = m_parentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); |
732 | if (sp != null) | 729 | if (sp != null) |
733 | return sp.AbsolutePosition; | 730 | return sp.AbsolutePosition; |
734 | } | 731 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a690e3b..81f1f38 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -2099,7 +2099,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2099 | { | 2099 | { |
2100 | if (part.ParentGroup.RootPart.AttachmentPoint != 0) | 2100 | if (part.ParentGroup.RootPart.AttachmentPoint != 0) |
2101 | { | 2101 | { |
2102 | ScenePresence avatar = World.GetScenePresence(part.AttachedAvatar); | 2102 | ScenePresence avatar = World.GetScenePresence(part.ParentGroup.AttachedAvatar); |
2103 | if (avatar != null) | 2103 | if (avatar != null) |
2104 | { | 2104 | { |
2105 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) | 2105 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) |
@@ -2243,7 +2243,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2243 | 2243 | ||
2244 | if (m_host.IsAttachment) | 2244 | if (m_host.IsAttachment) |
2245 | { | 2245 | { |
2246 | ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.AttachedAvatar); | 2246 | ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); |
2247 | vel = avatar.Velocity; | 2247 | vel = avatar.Velocity; |
2248 | } | 2248 | } |
2249 | else | 2249 | else |
@@ -3388,7 +3388,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3388 | 3388 | ||
3389 | m_host.AddScriptLPS(1); | 3389 | m_host.AddScriptLPS(1); |
3390 | 3390 | ||
3391 | if (m_host.ParentGroup.IsAttachment && (UUID)agent == m_host.ParentGroup.RootPart.AttachedAvatar) | 3391 | if (m_host.ParentGroup.IsAttachment && (UUID)agent == m_host.ParentGroup.AttachedAvatar) |
3392 | { | 3392 | { |
3393 | // When attached, certain permissions are implicit if requested from owner | 3393 | // When attached, certain permissions are implicit if requested from owner |
3394 | int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | | 3394 | int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | |
@@ -7460,7 +7460,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7460 | Quaternion q; | 7460 | Quaternion q; |
7461 | if (m_host.ParentGroup.RootPart.AttachmentPoint != 0) | 7461 | if (m_host.ParentGroup.RootPart.AttachmentPoint != 0) |
7462 | { | 7462 | { |
7463 | ScenePresence avatar = World.GetScenePresence(m_host.AttachedAvatar); | 7463 | ScenePresence avatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); |
7464 | if (avatar != null) | 7464 | if (avatar != null) |
7465 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) | 7465 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) |
7466 | q = avatar.CameraRotation; // Mouselook | 7466 | q = avatar.CameraRotation; // Mouselook |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index e53a61a..bf74760 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -308,7 +308,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
308 | // In attachments, the sensor cone always orients with the | 308 | // In attachments, the sensor cone always orients with the |
309 | // avatar rotation. This may include a nonzero elevation if | 309 | // avatar rotation. This may include a nonzero elevation if |
310 | // in mouselook. | 310 | // in mouselook. |
311 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); | 311 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
312 | q = avatar.Rotation; | 312 | q = avatar.Rotation; |
313 | } | 313 | } |
314 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 314 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
@@ -428,7 +428,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
428 | // In attachments, the sensor cone always orients with the | 428 | // In attachments, the sensor cone always orients with the |
429 | // avatar rotation. This may include a nonzero elevation if | 429 | // avatar rotation. This may include a nonzero elevation if |
430 | // in mouselook. | 430 | // in mouselook. |
431 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); | 431 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
432 | q = avatar.Rotation; | 432 | q = avatar.Rotation; |
433 | } | 433 | } |
434 | 434 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 783791f..ef9b2ac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -233,7 +233,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
233 | m_MaxScriptQueue = maxScriptQueue; | 233 | m_MaxScriptQueue = maxScriptQueue; |
234 | m_stateSource = stateSource; | 234 | m_stateSource = stateSource; |
235 | m_postOnRez = postOnRez; | 235 | m_postOnRez = postOnRez; |
236 | m_AttachedAvatar = part.AttachedAvatar; | 236 | m_AttachedAvatar = part.ParentGroup.AttachedAvatar; |
237 | m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; | 237 | m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; |
238 | 238 | ||
239 | if (part != null) | 239 | if (part != null) |