aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs78
1 files changed, 76 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 74784ae..38152cc 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -471,12 +471,86 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
471 SceneObjectSerializer.ToOriginalXmlFormat(group); 471 SceneObjectSerializer.ToOriginalXmlFormat(group);
472 group.DetachToInventoryPrep(); 472 group.DetachToInventoryPrep();
473 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); 473 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
474 m_scene.UpdateKnownItem(remoteClient, group,group.GetFromItemID(), group.OwnerID); 474 UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID);
475 m_scene.DeleteSceneObject(group, false); 475 m_scene.DeleteSceneObject(group, false);
476 return; 476 return;
477 } 477 }
478 } 478 }
479 } 479 }
480 } 480 }
481
482 public void UpdateAttachmentPosition(IClientAPI client, SceneObjectGroup sog, Vector3 pos)
483 {
484 // If this is an attachment, then we need to save the modified
485 // object back into the avatar's inventory. First we save the
486 // attachment point information, then we update the relative
487 // positioning (which caused this method to get driven in the
488 // first place. Then we have to mark the object as NOT an
489 // attachment. This is necessary in order to correctly save
490 // and retrieve GroupPosition information for the attachment.
491 // Then we save the asset back into the appropriate inventory
492 // entry. Finally, we restore the object's attachment status.
493 byte attachmentPoint = sog.GetAttachmentPoint();
494 sog.UpdateGroupPosition(pos);
495 sog.RootPart.IsAttachment = false;
496 sog.AbsolutePosition = sog.RootPart.AttachedPos;
497 UpdateKnownItem(client, sog, sog.GetFromItemID(), sog.OwnerID);
498 sog.SetAttachmentPoint(attachmentPoint);
499 }
500
501 /// <summary>
502 /// Update the attachment asset for the new sog details if they have changed.
503 /// </summary>
504 ///
505 /// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects,
506 /// these details are not stored on the region.
507 ///
508 /// <param name="remoteClient"></param>
509 /// <param name="grp"></param>
510 /// <param name="itemID"></param>
511 /// <param name="agentID"></param>
512 protected void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
513 {
514 if (grp != null)
515 {
516 if (!grp.HasGroupChanged)
517 {
518 m_log.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID);
519 return;
520 }
521
522 m_log.DebugFormat(
523 "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
524 grp.UUID, grp.GetAttachmentPoint());
525
526 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
527
528 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
529 item = m_scene.InventoryService.GetItem(item);
530
531 if (item != null)
532 {
533 AssetBase asset = m_scene.CreateAsset(
534 grp.GetPartName(grp.LocalId),
535 grp.GetPartDescription(grp.LocalId),
536 (sbyte)AssetType.Object,
537 Utils.StringToBytes(sceneObjectXml),
538 remoteClient.AgentId);
539 m_scene.AssetService.Store(asset);
540
541 item.AssetID = asset.FullID;
542 item.Description = asset.Description;
543 item.Name = asset.Name;
544 item.AssetType = asset.Type;
545 item.InvType = (int)InventoryType.Object;
546
547 m_scene.InventoryService.UpdateItem(item);
548
549 // this gets called when the agent logs off!
550 if (remoteClient != null)
551 remoteClient.SendInventoryItemCreateUpdate(item, 0);
552 }
553 }
554 }
481 } 555 }
482} 556} \ No newline at end of file