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.0.7.3-extended
parent
c2fbaaa95d
commit
c7d664f9d0
|
@ -4959,7 +4959,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
|
update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
|
||||||
if (data.ParentGroup.IsAttachment)
|
if (data.ParentGroup.IsAttachment)
|
||||||
{
|
{
|
||||||
update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.FromItemID);
|
update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID);
|
||||||
update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
|
update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -239,7 +239,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
// At the moment we can only deal with a single attachment
|
// At the moment we can only deal with a single attachment
|
||||||
if (attachments.Count != 0)
|
if (attachments.Count != 0)
|
||||||
{
|
{
|
||||||
UUID oldAttachmentItemID = attachments[0].GetFromItemID();
|
UUID oldAttachmentItemID = attachments[0].FromItemID;
|
||||||
|
|
||||||
if (oldAttachmentItemID != UUID.Zero)
|
if (oldAttachmentItemID != UUID.Zero)
|
||||||
DetachSingleAttachmentToInvInternal(sp, oldAttachmentItemID);
|
DetachSingleAttachmentToInvInternal(sp, oldAttachmentItemID);
|
||||||
|
@ -250,7 +250,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the new attachment to inventory if we don't already have it.
|
// Add the new attachment to inventory if we don't already have it.
|
||||||
UUID newAttachmentItemID = group.GetFromItemID();
|
UUID newAttachmentItemID = group.FromItemID;
|
||||||
if (newAttachmentItemID == UUID.Zero)
|
if (newAttachmentItemID == UUID.Zero)
|
||||||
newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
|
newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
List<SceneObjectGroup> existingAttachments = sp.GetAttachments();
|
List<SceneObjectGroup> existingAttachments = sp.GetAttachments();
|
||||||
foreach (SceneObjectGroup so in existingAttachments)
|
foreach (SceneObjectGroup so in existingAttachments)
|
||||||
{
|
{
|
||||||
if (so.GetFromItemID() == itemID)
|
if (so.FromItemID == itemID)
|
||||||
{
|
{
|
||||||
alreadyOn = true;
|
alreadyOn = true;
|
||||||
break;
|
break;
|
||||||
|
@ -342,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
if (so.AttachedAvatar != sp.UUID)
|
if (so.AttachedAvatar != sp.UUID)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UUID inventoryID = so.GetFromItemID();
|
UUID inventoryID = so.FromItemID;
|
||||||
|
|
||||||
// m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}",
|
// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}",
|
||||||
|
@ -359,9 +359,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
|
m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
|
||||||
|
|
||||||
sp.RemoveAttachment(so);
|
sp.RemoveAttachment(so);
|
||||||
|
so.FromItemID = UUID.Zero;
|
||||||
|
|
||||||
SceneObjectPart rootPart = so.RootPart;
|
SceneObjectPart rootPart = so.RootPart;
|
||||||
rootPart.FromItemID = UUID.Zero;
|
|
||||||
so.AbsolutePosition = sp.AbsolutePosition;
|
so.AbsolutePosition = sp.AbsolutePosition;
|
||||||
so.AttachedAvatar = UUID.Zero;
|
so.AttachedAvatar = UUID.Zero;
|
||||||
rootPart.SetParentLocalId(0);
|
rootPart.SetParentLocalId(0);
|
||||||
|
@ -475,7 +475,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
|
|
||||||
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
|
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
|
||||||
|
|
||||||
InventoryItemBase item = new InventoryItemBase(grp.GetFromItemID(), sp.UUID);
|
InventoryItemBase item = new InventoryItemBase(grp.FromItemID, sp.UUID);
|
||||||
item = m_scene.InventoryService.GetItem(item);
|
item = m_scene.InventoryService.GetItem(item);
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
|
@ -647,7 +647,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
item.CreationDate = Util.UnixTimeSinceEpoch();
|
item.CreationDate = Util.UnixTimeSinceEpoch();
|
||||||
|
|
||||||
// sets itemID so client can show item as 'attached' in inventory
|
// sets itemID so client can show item as 'attached' in inventory
|
||||||
grp.SetFromItemID(item.ID);
|
grp.FromItemID = item.ID;
|
||||||
|
|
||||||
if (m_scene.AddInventoryItem(item))
|
if (m_scene.AddInventoryItem(item))
|
||||||
{
|
{
|
||||||
|
@ -683,7 +683,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
if (entity is SceneObjectGroup)
|
if (entity is SceneObjectGroup)
|
||||||
{
|
{
|
||||||
group = (SceneObjectGroup)entity;
|
group = (SceneObjectGroup)entity;
|
||||||
if (group.GetFromItemID() == itemID)
|
if (group.FromItemID == itemID)
|
||||||
{
|
{
|
||||||
m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
|
m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
|
||||||
sp.RemoveAttachment(group);
|
sp.RemoveAttachment(group);
|
||||||
|
@ -889,7 +889,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
// Calls attach with a Zero position
|
// Calls attach with a Zero position
|
||||||
if (AttachObject(sp, part.ParentGroup, AttachmentPt, false))
|
if (AttachObject(sp, part.ParentGroup, AttachmentPt, false))
|
||||||
{
|
{
|
||||||
m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId);
|
m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId);
|
||||||
|
|
||||||
// Save avatar attachment information
|
// Save avatar attachment information
|
||||||
m_log.Debug(
|
m_log.Debug(
|
||||||
|
@ -912,7 +912,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
|
ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
|
||||||
SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID);
|
SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID);
|
||||||
if (sp != null && group != null)
|
if (sp != null && group != null)
|
||||||
DetachSingleAttachmentToInv(sp, group.GetFromItemID());
|
DetachSingleAttachmentToInv(sp, group.FromItemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Client_OnDetachAttachmentIntoInv(UUID itemID, IClientAPI remoteClient)
|
private void Client_OnDetachAttachmentIntoInv(UUID itemID, IClientAPI remoteClient)
|
||||||
|
|
|
@ -120,8 +120,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||||
Assert.That(attSo.IsTemporary, Is.False);
|
Assert.That(attSo.IsTemporary, Is.False);
|
||||||
|
|
||||||
// Check item status
|
// Check item status
|
||||||
Assert.That(m_presence.Appearance.GetAttachpoint(
|
Assert.That(
|
||||||
attSo.GetFromItemID()), Is.EqualTo((int)AttachmentPoint.Chest));
|
m_presence.Appearance.GetAttachpoint(attSo.FromItemID),
|
||||||
|
Is.EqualTo((int)AttachmentPoint.Chest));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
|
@ -1003,7 +1003,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
rootPart.TrimPermissions();
|
rootPart.TrimPermissions();
|
||||||
|
|
||||||
if (isAttachment)
|
if (isAttachment)
|
||||||
so.SetFromItemID(item.ID);
|
so.FromItemID = item.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -2565,7 +2565,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
SceneObjectGroup grp = sceneObject;
|
SceneObjectGroup grp = sceneObject;
|
||||||
|
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.GetFromItemID(), grp.UUID);
|
"[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.FromItemID, grp.UUID);
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
|
"[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
|
||||||
|
|
||||||
|
|
|
@ -553,7 +553,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
set { m_LoopSoundSlavePrims = value; }
|
set { m_LoopSoundSlavePrims = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// The UUID for the Region this Object is in.
|
/// <summary>
|
||||||
|
/// The UUID for the region this object is in.
|
||||||
|
/// </summary>
|
||||||
public UUID RegionUUID
|
public UUID RegionUUID
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -566,6 +568,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The item ID that this object was rezzed from, if applicable.
|
||||||
|
/// </summary>
|
||||||
|
public UUID FromItemID { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// ~SceneObjectGroup()
|
// ~SceneObjectGroup()
|
||||||
|
@ -628,18 +635,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFromItemID(UUID AssetId)
|
|
||||||
{
|
|
||||||
SceneObjectPart[] parts = m_parts.GetArray();
|
|
||||||
for (int i = 0; i < parts.Length; i++)
|
|
||||||
parts[i].FromItemID = AssetId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID GetFromItemID()
|
|
||||||
{
|
|
||||||
return m_rootPart.FromItemID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hooks this object up to the backup event so that it is persisted to the database when the update thread executes.
|
/// Hooks this object up to the backup event so that it is persisted to the database when the update thread executes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2698,6 +2693,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
m_rootPart.AttachedPos = pos;
|
m_rootPart.AttachedPos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RootPart.GetStatusSandbox())
|
if (RootPart.GetStatusSandbox())
|
||||||
{
|
{
|
||||||
if (Util.GetDistanceTo(RootPart.StatusSandboxPos, pos) > 10)
|
if (Util.GetDistanceTo(RootPart.StatusSandboxPos, pos) > 10)
|
||||||
|
@ -2708,8 +2704,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
|
ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AbsolutePosition = pos;
|
|
||||||
|
|
||||||
|
AbsolutePosition = pos;
|
||||||
HasGroupChanged = true;
|
HasGroupChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3281,7 +3277,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public virtual string ExtraToXmlString()
|
public virtual string ExtraToXmlString()
|
||||||
{
|
{
|
||||||
return "<ExtraFromItemID>" + GetFromItemID().ToString() + "</ExtraFromItemID>";
|
return "<ExtraFromItemID>" + FromItemID.ToString() + "</ExtraFromItemID>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ExtraFromXmlString(string xmlstr)
|
public virtual void ExtraFromXmlString(string xmlstr)
|
||||||
|
@ -3293,7 +3289,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
UUID uuid = UUID.Zero;
|
UUID uuid = UUID.Zero;
|
||||||
UUID.TryParse(id, out uuid);
|
UUID.TryParse(id, out uuid);
|
||||||
|
|
||||||
SetFromItemID(uuid);
|
FromItemID = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -179,8 +179,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public uint TimeStampLastActivity; // Will be used for AutoReturn
|
public uint TimeStampLastActivity; // Will be used for AutoReturn
|
||||||
|
|
||||||
public uint TimeStampTerse;
|
public uint TimeStampTerse;
|
||||||
|
|
||||||
public UUID FromItemID;
|
|
||||||
|
|
||||||
public UUID FromFolderID;
|
public UUID FromFolderID;
|
||||||
|
|
||||||
|
|
|
@ -3055,7 +3055,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
SceneObjectPart host = (SceneObjectPart)o;
|
SceneObjectPart host = (SceneObjectPart)o;
|
||||||
|
|
||||||
SceneObjectGroup grp = host.ParentGroup;
|
SceneObjectGroup grp = host.ParentGroup;
|
||||||
UUID itemID = grp.GetFromItemID();
|
UUID itemID = grp.FromItemID;
|
||||||
ScenePresence presence = World.GetScenePresence(host.OwnerID);
|
ScenePresence presence = World.GetScenePresence(host.OwnerID);
|
||||||
|
|
||||||
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
|
IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
|
||||||
|
|
Loading…
Reference in New Issue