From bf9e8cb9878a89f16edcd0b86af62aabdd7b93bc Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 21 Dec 2008 14:50:58 +0000 Subject: * Fixes linking multiple linksets together. They no longer explode * Not out of the weeds yet. Rotating the root part with 'edit linked parts' still borks all child part rotations and rotating a selection of child parts with 'edit linked parts' still borks the position/rotation of the child parts selected --- OpenSim/Region/Environment/Scenes/SceneGraph.cs | 3 +++ .../Region/Environment/Scenes/SceneObjectGroup.cs | 31 +++++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/Scenes/SceneGraph.cs b/OpenSim/Region/Environment/Scenes/SceneGraph.cs index d261e2d..dbb8539 100644 --- a/OpenSim/Region/Environment/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Environment/Scenes/SceneGraph.cs @@ -1690,6 +1690,9 @@ namespace OpenSim.Region.Environment.Scenes copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0); copy.HasGroupChanged = true; copy.ScheduleGroupForFullUpdate(); + + // required for physics to update it's position + copy.AbsolutePosition = copy.AbsolutePosition; return copy; } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index f4ccc46..36ba683 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -2132,6 +2132,21 @@ namespace OpenSim.Region.Environment.Scenes private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum) { + + Quaternion parentRot = oldGroupRotation; + Quaternion oldRot = part.RotationOffset; + Quaternion worldRot = parentRot * oldRot; + + parentRot = oldGroupRotation; + + Vector3 axPos = part.OffsetPosition; + + axPos *= parentRot; + part.OffsetPosition = axPos; + part.GroupPosition = oldGroupPosition + part.OffsetPosition; + part.OffsetPosition = Vector3.Zero; + part.RotationOffset = worldRot; + part.SetParent(this); part.ParentID = m_rootPart.LocalId; @@ -2140,11 +2155,8 @@ namespace OpenSim.Region.Environment.Scenes part.LinkNum = linkNum; - Vector3 oldPos = part.OffsetPosition; - oldPos *= oldGroupRotation; - oldPos += oldGroupPosition; - Vector3 oldAbsolutePosition = oldPos; - part.OffsetPosition = oldAbsolutePosition - AbsolutePosition; + + part.OffsetPosition = part.GroupPosition - AbsolutePosition; Quaternion rootRotation = m_rootPart.RotationOffset; @@ -2152,11 +2164,10 @@ namespace OpenSim.Region.Environment.Scenes pos *= Quaternion.Inverse(rootRotation); part.OffsetPosition = pos; - Quaternion partRotation = part.RotationOffset; - - partRotation *= oldGroupRotation; - partRotation *= Quaternion.Inverse(rootRotation); - part.RotationOffset = partRotation; + parentRot = m_rootPart.RotationOffset; + oldRot = part.RotationOffset; + Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; + part.RotationOffset = newRot; } /// -- cgit v1.1