aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-04-07 00:33:02 +0100
committerJustin Clark-Casey (justincc)2012-04-07 00:33:02 +0100
commit7d8bb33c5b2420d4e744269f67a25dd2b9746a35 (patch)
tree53e2c0d0258e81c4e87ae78521e85d98d115becc
parentrefactor: Eliminate unnecessary SOP.m_physActor (diff)
downloadopensim-SC-7d8bb33c5b2420d4e744269f67a25dd2b9746a35.zip
opensim-SC-7d8bb33c5b2420d4e744269f67a25dd2b9746a35.tar.gz
opensim-SC-7d8bb33c5b2420d4e744269f67a25dd2b9746a35.tar.bz2
opensim-SC-7d8bb33c5b2420d4e744269f67a25dd2b9746a35.tar.xz
Store FromItemID for attachments once on SOG instead of on every SOP and only ever using the root part entry.
This eliminates some pointless memory use.
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs20
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs5
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs28
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs2
8 files changed, 29 insertions, 34 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 9395233..619ef14 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -4957,7 +4957,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4957 update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim 4957 update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
4958 if (data.ParentGroup.IsAttachment) 4958 if (data.ParentGroup.IsAttachment)
4959 { 4959 {
4960 update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.FromItemID); 4960 update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID);
4961 update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16)); 4961 update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
4962 } 4962 }
4963 else 4963 else
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 7086e6c..faa413e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -239,7 +239,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
239 // At the moment we can only deal with a single attachment 239 // At the moment we can only deal with a single attachment
240 if (attachments.Count != 0) 240 if (attachments.Count != 0)
241 { 241 {
242 UUID oldAttachmentItemID = attachments[0].GetFromItemID(); 242 UUID oldAttachmentItemID = attachments[0].FromItemID;
243 243
244 if (oldAttachmentItemID != UUID.Zero) 244 if (oldAttachmentItemID != UUID.Zero)
245 DetachSingleAttachmentToInvInternal(sp, oldAttachmentItemID); 245 DetachSingleAttachmentToInvInternal(sp, oldAttachmentItemID);
@@ -250,7 +250,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
250 } 250 }
251 251
252 // Add the new attachment to inventory if we don't already have it. 252 // Add the new attachment to inventory if we don't already have it.
253 UUID newAttachmentItemID = group.GetFromItemID(); 253 UUID newAttachmentItemID = group.FromItemID;
254 if (newAttachmentItemID == UUID.Zero) 254 if (newAttachmentItemID == UUID.Zero)
255 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID; 255 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
256 256
@@ -285,7 +285,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
285 List<SceneObjectGroup> existingAttachments = sp.GetAttachments(); 285 List<SceneObjectGroup> existingAttachments = sp.GetAttachments();
286 foreach (SceneObjectGroup so in existingAttachments) 286 foreach (SceneObjectGroup so in existingAttachments)
287 { 287 {
288 if (so.GetFromItemID() == itemID) 288 if (so.FromItemID == itemID)
289 { 289 {
290 alreadyOn = true; 290 alreadyOn = true;
291 break; 291 break;
@@ -342,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
342 if (so.AttachedAvatar != sp.UUID) 342 if (so.AttachedAvatar != sp.UUID)
343 return; 343 return;
344 344
345 UUID inventoryID = so.GetFromItemID(); 345 UUID inventoryID = so.FromItemID;
346 346
347// m_log.DebugFormat( 347// m_log.DebugFormat(
348// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}", 348// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}",
@@ -359,9 +359,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
359 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); 359 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
360 360
361 sp.RemoveAttachment(so); 361 sp.RemoveAttachment(so);
362 so.FromItemID = UUID.Zero;
362 363
363 SceneObjectPart rootPart = so.RootPart; 364 SceneObjectPart rootPart = so.RootPart;
364 rootPart.FromItemID = UUID.Zero;
365 so.AbsolutePosition = sp.AbsolutePosition; 365 so.AbsolutePosition = sp.AbsolutePosition;
366 so.AttachedAvatar = UUID.Zero; 366 so.AttachedAvatar = UUID.Zero;
367 rootPart.SetParentLocalId(0); 367 rootPart.SetParentLocalId(0);
@@ -475,7 +475,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
475 475
476 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); 476 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
477 477
478 InventoryItemBase item = new InventoryItemBase(grp.GetFromItemID(), sp.UUID); 478 InventoryItemBase item = new InventoryItemBase(grp.FromItemID, sp.UUID);
479 item = m_scene.InventoryService.GetItem(item); 479 item = m_scene.InventoryService.GetItem(item);
480 480
481 if (item != null) 481 if (item != null)
@@ -647,7 +647,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
647 item.CreationDate = Util.UnixTimeSinceEpoch(); 647 item.CreationDate = Util.UnixTimeSinceEpoch();
648 648
649 // sets itemID so client can show item as 'attached' in inventory 649 // sets itemID so client can show item as 'attached' in inventory
650 grp.SetFromItemID(item.ID); 650 grp.FromItemID = item.ID;
651 651
652 if (m_scene.AddInventoryItem(item)) 652 if (m_scene.AddInventoryItem(item))
653 { 653 {
@@ -683,7 +683,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
683 if (entity is SceneObjectGroup) 683 if (entity is SceneObjectGroup)
684 { 684 {
685 group = (SceneObjectGroup)entity; 685 group = (SceneObjectGroup)entity;
686 if (group.GetFromItemID() == itemID) 686 if (group.FromItemID == itemID)
687 { 687 {
688 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); 688 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
689 sp.RemoveAttachment(group); 689 sp.RemoveAttachment(group);
@@ -889,7 +889,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
889 // Calls attach with a Zero position 889 // Calls attach with a Zero position
890 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) 890 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false))
891 { 891 {
892 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); 892 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId);
893 893
894 // Save avatar attachment information 894 // Save avatar attachment information
895 m_log.Debug( 895 m_log.Debug(
@@ -912,7 +912,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
912 ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); 912 ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
913 SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID); 913 SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID);
914 if (sp != null && group != null) 914 if (sp != null && group != null)
915 DetachSingleAttachmentToInv(sp, group.GetFromItemID()); 915 DetachSingleAttachmentToInv(sp, group.FromItemID);
916 } 916 }
917 917
918 private void Client_OnDetachAttachmentIntoInv(UUID itemID, IClientAPI remoteClient) 918 private void Client_OnDetachAttachmentIntoInv(UUID itemID, IClientAPI remoteClient)
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 86cfb32..bfe5e4a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -120,8 +120,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
120 Assert.That(attSo.IsTemporary, Is.False); 120 Assert.That(attSo.IsTemporary, Is.False);
121 121
122 // Check item status 122 // Check item status
123 Assert.That(m_presence.Appearance.GetAttachpoint( 123 Assert.That(
124 attSo.GetFromItemID()), Is.EqualTo((int)AttachmentPoint.Chest)); 124 m_presence.Appearance.GetAttachpoint(attSo.FromItemID),
125 Is.EqualTo((int)AttachmentPoint.Chest));
125 } 126 }
126 127
127 [Test] 128 [Test]
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 4dd89d2..88c21af 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -1008,7 +1008,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1008 rootPart.TrimPermissions(); 1008 rootPart.TrimPermissions();
1009 1009
1010 if (isAttachment) 1010 if (isAttachment)
1011 so.SetFromItemID(item.ID); 1011 so.FromItemID = item.ID;
1012 } 1012 }
1013 1013
1014 return true; 1014 return true;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d8cac66..e488fe1 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2566,7 +2566,7 @@ namespace OpenSim.Region.Framework.Scenes
2566 SceneObjectGroup grp = sceneObject; 2566 SceneObjectGroup grp = sceneObject;
2567 2567
2568 m_log.DebugFormat( 2568 m_log.DebugFormat(
2569 "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.GetFromItemID(), grp.UUID); 2569 "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID);
2570 m_log.DebugFormat( 2570 m_log.DebugFormat(
2571 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2571 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2572 2572
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 87fdc41..3586e95 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -571,7 +571,9 @@ namespace OpenSim.Region.Framework.Scenes
571 set { m_LoopSoundSlavePrims = value; } 571 set { m_LoopSoundSlavePrims = value; }
572 } 572 }
573 573
574 // The UUID for the Region this Object is in. 574 /// <summary>
575 /// The UUID for the region this object is in.
576 /// </summary>
575 public UUID RegionUUID 577 public UUID RegionUUID
576 { 578 {
577 get 579 get
@@ -584,6 +586,11 @@ namespace OpenSim.Region.Framework.Scenes
584 } 586 }
585 } 587 }
586 588
589 /// <summary>
590 /// The item ID that this object was rezzed from, if applicable.
591 /// </summary>
592 public UUID FromItemID { get; set; }
593
587 #endregion 594 #endregion
588 595
589// ~SceneObjectGroup() 596// ~SceneObjectGroup()
@@ -646,18 +653,6 @@ namespace OpenSim.Region.Framework.Scenes
646 } 653 }
647 } 654 }
648 655
649 public void SetFromItemID(UUID AssetId)
650 {
651 SceneObjectPart[] parts = m_parts.GetArray();
652 for (int i = 0; i < parts.Length; i++)
653 parts[i].FromItemID = AssetId;
654 }
655
656 public UUID GetFromItemID()
657 {
658 return m_rootPart.FromItemID;
659 }
660
661 /// <summary> 656 /// <summary>
662 /// Hooks this object up to the backup event so that it is persisted to the database when the update thread executes. 657 /// Hooks this object up to the backup event so that it is persisted to the database when the update thread executes.
663 /// </summary> 658 /// </summary>
@@ -2687,6 +2682,7 @@ namespace OpenSim.Region.Framework.Scenes
2687 { 2682 {
2688 m_rootPart.AttachedPos = pos; 2683 m_rootPart.AttachedPos = pos;
2689 } 2684 }
2685
2690 if (RootPart.GetStatusSandbox()) 2686 if (RootPart.GetStatusSandbox())
2691 { 2687 {
2692 if (Util.GetDistanceTo(RootPart.StatusSandboxPos, pos) > 10) 2688 if (Util.GetDistanceTo(RootPart.StatusSandboxPos, pos) > 10)
@@ -2697,8 +2693,8 @@ namespace OpenSim.Region.Framework.Scenes
2697 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); 2693 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
2698 } 2694 }
2699 } 2695 }
2700 AbsolutePosition = pos;
2701 2696
2697 AbsolutePosition = pos;
2702 HasGroupChanged = true; 2698 HasGroupChanged = true;
2703 } 2699 }
2704 2700
@@ -3270,7 +3266,7 @@ namespace OpenSim.Region.Framework.Scenes
3270 3266
3271 public virtual string ExtraToXmlString() 3267 public virtual string ExtraToXmlString()
3272 { 3268 {
3273 return "<ExtraFromItemID>" + GetFromItemID().ToString() + "</ExtraFromItemID>"; 3269 return "<ExtraFromItemID>" + FromItemID.ToString() + "</ExtraFromItemID>";
3274 } 3270 }
3275 3271
3276 public virtual void ExtraFromXmlString(string xmlstr) 3272 public virtual void ExtraFromXmlString(string xmlstr)
@@ -3282,7 +3278,7 @@ namespace OpenSim.Region.Framework.Scenes
3282 UUID uuid = UUID.Zero; 3278 UUID uuid = UUID.Zero;
3283 UUID.TryParse(id, out uuid); 3279 UUID.TryParse(id, out uuid);
3284 3280
3285 SetFromItemID(uuid); 3281 FromItemID = uuid;
3286 } 3282 }
3287 3283
3288 #endregion 3284 #endregion
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 2fcce1c..fffaa06 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -181,8 +181,6 @@ namespace OpenSim.Region.Framework.Scenes
181 public uint TimeStampLastActivity; // Will be used for AutoReturn 181 public uint TimeStampLastActivity; // Will be used for AutoReturn
182 182
183 public uint TimeStampTerse; 183 public uint TimeStampTerse;
184
185 public UUID FromItemID;
186 184
187 public UUID FromFolderID; 185 public UUID FromFolderID;
188 186
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 8223d95..291f52e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3080,7 +3080,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3080 SceneObjectPart host = (SceneObjectPart)o; 3080 SceneObjectPart host = (SceneObjectPart)o;
3081 3081
3082 SceneObjectGroup grp = host.ParentGroup; 3082 SceneObjectGroup grp = host.ParentGroup;
3083 UUID itemID = grp.GetFromItemID(); 3083 UUID itemID = grp.FromItemID;
3084 ScenePresence presence = World.GetScenePresence(host.OwnerID); 3084 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3085 3085
3086 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 3086 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;