aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-09-01 01:11:52 +0100
committerJustin Clark-Casey (justincc)2010-09-01 01:11:52 +0100
commit6cbf66827ba3cb878ab70b75fc4e3221b71d820e (patch)
tree59ba0c53b3672bd5b2a44bb321663df709de4098
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-6cbf66827ba3cb878ab70b75fc4e3221b71d820e.zip
opensim-SC-6cbf66827ba3cb878ab70b75fc4e3221b71d820e.tar.gz
opensim-SC-6cbf66827ba3cb878ab70b75fc4e3221b71d820e.tar.bz2
opensim-SC-6cbf66827ba3cb878ab70b75fc4e3221b71d820e.tar.xz
refactor: move SOG.AttachToAgent() into AttachmentsModule
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs81
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs71
2 files changed, 74 insertions, 78 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index de65460..6555b54 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -192,12 +192,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
192 192
193 SetAttachmentInventoryStatus(remoteClient, AttachmentPt, itemID, group); 193 SetAttachmentInventoryStatus(remoteClient, AttachmentPt, itemID, group);
194 194
195 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent); 195 AttachToAgent(sp, group, AttachmentPt, attachPos, silent);
196
197 // In case it is later dropped again, don't let
198 // it get cleaned up
199 group.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
200 group.HasGroupChanged = false;
201 } 196 }
202 else 197 else
203 { 198 {
@@ -525,6 +520,78 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
525 remoteClient.SendInventoryItemCreateUpdate(item, 0); 520 remoteClient.SendInventoryItemCreateUpdate(item, 0);
526 } 521 }
527 } 522 }
528 } 523 }
524
525 /// <summary>
526 /// Attach this scene object to the given avatar.
527 /// </summary>
528 ///
529 /// This isn't publicly available since attachments should always perform the corresponding inventory
530 /// operation (to show the attach in user inventory and update the asset with positional information).
531 ///
532 /// <param name="sp"></param>
533 /// <param name="so"></param>
534 /// <param name="attachmentpoint"></param>
535 /// <param name="AttachOffset"></param>
536 /// <param name="silent"></param>
537 protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 AttachOffset, bool silent)
538 {
539 // don't attach attachments to child agents
540 if (avatar.IsChildAgent) return;
541
542// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1}", Name, avatar.Name);
543
544 so.DetachFromBackup();
545
546 // Remove from database and parcel prim count
547 m_scene.DeleteFromStorage(so.UUID);
548 m_scene.EventManager.TriggerParcelPrimCountTainted();
549
550 so.RootPart.AttachedAvatar = avatar.UUID;
551
552 //Anakin Lohner bug #3839
553 lock (so.Children)
554 {
555 foreach (SceneObjectPart p in so.Children.Values)
556 {
557 p.AttachedAvatar = avatar.UUID;
558 }
559 }
560
561 if (so.RootPart.PhysActor != null)
562 {
563 m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor);
564 so.RootPart.PhysActor = null;
565 }
566
567 so.AbsolutePosition = AttachOffset;
568 so.RootPart.AttachedPos = AttachOffset;
569 so.RootPart.IsAttachment = true;
570
571 so.RootPart.SetParentLocalId(avatar.LocalId);
572 so.SetAttachmentPoint(Convert.ToByte(attachmentpoint));
573
574 avatar.AddAttachment(so);
575
576 if (!silent)
577 {
578 // Killing it here will cause the client to deselect it
579 // It then reappears on the avatar, deselected
580 // through the full update below
581 //
582 if (so.IsSelected)
583 {
584 m_scene.SendKillObject(so.RootPart.LocalId);
585 }
586
587 so.IsSelected = false; // fudge....
588 so.ScheduleGroupForFullUpdate();
589 }
590
591 // In case it is later dropped again, don't let
592 // it get cleaned up
593 so.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
594 so.HasGroupChanged = false;
595 }
529 } 596 }
530} \ No newline at end of file 597} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 40a8f83..64a6dd5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -977,77 +977,6 @@ namespace OpenSim.Region.Framework.Scenes
977 } 977 }
978 } 978 }
979 979
980 /// <summary>
981 /// Attach this scene object to the given avatar.
982 /// </summary>
983 /// <param name="agentID"></param>
984 /// <param name="attachmentpoint"></param>
985 /// <param name="AttachOffset"></param>
986 public void AttachToAgent(UUID agentID, uint attachmentpoint, Vector3 AttachOffset, bool silent)
987 {
988 ScenePresence avatar = m_scene.GetScenePresence(agentID);
989 if (avatar != null)
990 {
991 // don't attach attachments to child agents
992 if (avatar.IsChildAgent) return;
993
994// m_log.DebugFormat("[SOG]: Adding attachment {0} to avatar {1}", Name, avatar.Name);
995
996 DetachFromBackup();
997
998 // Remove from database and parcel prim count
999 m_scene.DeleteFromStorage(UUID);
1000 m_scene.EventManager.TriggerParcelPrimCountTainted();
1001
1002 m_rootPart.AttachedAvatar = agentID;
1003
1004 //Anakin Lohner bug #3839
1005 lock (m_parts)
1006 {
1007 foreach (SceneObjectPart p in m_parts.Values)
1008 {
1009 p.AttachedAvatar = agentID;
1010 }
1011 }
1012
1013 if (m_rootPart.PhysActor != null)
1014 {
1015 m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor);
1016 m_rootPart.PhysActor = null;
1017 }
1018
1019 AbsolutePosition = AttachOffset;
1020 m_rootPart.AttachedPos = AttachOffset;
1021 m_rootPart.IsAttachment = true;
1022
1023 m_rootPart.SetParentLocalId(avatar.LocalId);
1024 SetAttachmentPoint(Convert.ToByte(attachmentpoint));
1025
1026 avatar.AddAttachment(this);
1027
1028 if (!silent)
1029 {
1030 // Killing it here will cause the client to deselect it
1031 // It then reappears on the avatar, deselected
1032 // through the full update below
1033 //
1034 if (IsSelected)
1035 {
1036 m_scene.SendKillObject(m_rootPart.LocalId);
1037 }
1038
1039 IsSelected = false; // fudge....
1040 ScheduleGroupForFullUpdate();
1041 }
1042 }
1043 else
1044 {
1045 m_log.WarnFormat(
1046 "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present",
1047 UUID, agentID, Scene.RegionInfo.RegionName);
1048 }
1049 }
1050
1051 public byte GetAttachmentPoint() 980 public byte GetAttachmentPoint()
1052 { 981 {
1053 return m_rootPart.Shape.State; 982 return m_rootPart.Shape.State;