From 88553bb884c5c8849ec61362e65fe0950c1e3080 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 25 Apr 2012 19:09:22 +0100 Subject: Port Avination link order to make OpenSim behave like SL. Make Primstar scripts work. Fixes Mantis #5990 --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 42 ++++++++++++++++++++-- .../Shared/Api/Implementation/LSL_Api.cs | 12 ++++--- 2 files changed, 47 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 49a3485..2686004 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1969,6 +1969,11 @@ namespace OpenSim.Region.Framework.Scenes /// The group of prims which should be linked to this group public void LinkToGroup(SceneObjectGroup objectGroup) { + LinkToGroup(objectGroup, false); + } + + public void LinkToGroup(SceneObjectGroup objectGroup, bool insert) + { // m_log.DebugFormat( // "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); @@ -1979,6 +1984,10 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart linkPart = objectGroup.m_rootPart; + // physics flags from group to be applied to linked parts + bool grpusephys = UsesPhysics; + bool grptemporary = IsTemporary; + Vector3 oldGroupPosition = linkPart.GroupPosition; Quaternion oldRootRotation = linkPart.RotationOffset; @@ -2002,15 +2011,35 @@ namespace OpenSim.Region.Framework.Scenes lock (m_parts.SyncRoot) { - int linkNum = PrimCount + 1; + int linkNum; + if (insert) + { + linkNum = 2; + foreach (SceneObjectPart part in Parts) + { + if (part.LinkNum > 1) + part.LinkNum++; + } + } + else + { + linkNum = PrimCount + 1; + } m_parts.Add(linkPart.UUID, linkPart); linkPart.SetParent(this); linkPart.CreateSelected = true; + // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now + linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive); + if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) + { + linkPart.PhysActor.link(m_rootPart.PhysActor); + this.Scene.PhysicsScene.AddPhysicsActorTaint(linkPart.PhysActor); + } + linkPart.LinkNum = linkNum++; - linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); SceneObjectPart[] ogParts = objectGroup.Parts; Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) @@ -2022,7 +2051,16 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = ogParts[i]; if (part.UUID != objectGroup.m_rootPart.UUID) + { LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); + // let physics know + part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive); + if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) + { + part.PhysActor.link(m_rootPart.PhysActor); + this.Scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); + } + } part.ClearUndoState(); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d4c872c..d641958 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -832,8 +832,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRegionSayTo(string target, int channel, string msg) { - string error = String.Empty; - if (msg.Length > 1023) msg = msg.Substring(0, 1023); @@ -3548,7 +3546,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llCreateLink(string target, int parent) { m_host.AddScriptLPS(1); - UUID targetID; if (!UUID.TryParse(target, out targetID)) @@ -3572,11 +3569,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (targetPart.ParentGroup.AttachmentPoint != 0) return; // Fail silently if attached + + if (targetPart.ParentGroup.RootPart.OwnerID != m_host.ParentGroup.RootPart.OwnerID) + return; + SceneObjectGroup parentPrim = null, childPrim = null; if (targetPart != null) { - if (parent != 0) { + if (parent != 0) + { parentPrim = m_host.ParentGroup; childPrim = targetPart.ParentGroup; } @@ -3588,7 +3590,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Required for linking childPrim.RootPart.ClearUpdateSchedule(); - parentPrim.LinkToGroup(childPrim); + parentPrim.LinkToGroup(childPrim, true); } parentPrim.TriggerScriptChangedEvent(Changed.LINK); -- cgit v1.1