From 2dc92e7de11086c7649d3ee0f8adc974efce6805 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Sun, 4 Aug 2013 19:19:11 +0200 Subject: Preserve attachment point & position when attachment is rezzed in world Patch taken from http://opensimulator.org/mantis/view.php?id=4905 originally by Greg C. Fixed to apply to r/23314 commit ba9daf849e7c8db48e7c03e7cdedb77776b2052f (cherry picked from commit 4ff9fbca441110cc2b93edc7286e0e9339e61cbe) --- .../Avatar/Attachments/AttachmentsModule.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2818712..d0e0b35 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -422,6 +422,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments attachPos = Vector3.Zero; } + // if the attachment point is the same as previous, make sure we get the saved + // position info. + if (attachmentPt != 0 && attachmentPt == group.RootPart.Shape.LastAttachPoint) + { + attachPos = group.RootPart.AttachedPos; + } + // AttachmentPt 0 means the client chose to 'wear' the attachment. if (attachmentPt == (uint)AttachmentPoint.Default) { @@ -429,6 +436,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments attachmentPt = group.AttachmentPoint; } + // if we didn't find an attach point, look for where it was last attached + if (attachmentPt == 0) + { + attachmentPt = (uint)group.RootPart.Shape.LastAttachPoint; + attachPos = group.RootPart.AttachedPos; + group.HasGroupChanged = true; + } + // if we still didn't find a suitable attachment point....... if (attachmentPt == 0) { @@ -619,6 +634,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments so.ClearPartAttachmentData(); rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive); so.HasGroupChanged = true; + so.RootPart.Shape.LastAttachPoint = (byte)so.AttachmentPoint; rootPart.Rezzed = DateTime.Now; rootPart.RemFlag(PrimFlags.TemporaryOnRez); so.AttachToBackup(); @@ -1210,4 +1226,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments #endregion } -} \ No newline at end of file +} -- cgit v1.1