From e947d04038f7b42929368d9f7b6d440be139e675 Mon Sep 17 00:00:00 2001 From: Tom Grimshaw Date: Mon, 5 Jul 2010 05:44:35 -0700 Subject: Undo fix is now complete. This commit repairs the special case of the root prim moving or rotating independently of the rest of the group. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 49 +++++++++++++++++----- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 - OpenSim/Region/Framework/Scenes/UndoState.cs | 5 ++- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 7492601..f85d3d9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3386,10 +3386,27 @@ namespace OpenSim.Region.Framework.Scenes } lockPartsForRead(false); - AbsolutePosition = newPos; + //We have to set undoing here because otherwise an undo state will be saved + if (!m_rootPart.Undoing) + { + m_rootPart.Undoing = true; + AbsolutePosition = newPos; + m_rootPart.Undoing = false; + } + else + { + AbsolutePosition = newPos; + } HasGroupChanged = true; - ScheduleGroupForTerseUpdate(); + if (m_rootPart.Undoing) + { + ScheduleGroupForFullUpdate(); + } + else + { + ScheduleGroupForTerseUpdate(); + } } public void OffsetForNewRegion(Vector3 offset) @@ -3488,7 +3505,16 @@ namespace OpenSim.Region.Framework.Scenes if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); - AbsolutePosition = pos; + if (!m_rootPart.Undoing) + { + m_rootPart.Undoing = true; + AbsolutePosition = pos; + m_rootPart.Undoing = false; + } + else + { + AbsolutePosition = pos; + } } else { @@ -3511,6 +3537,12 @@ namespace OpenSim.Region.Framework.Scenes Quaternion oldParentRot = m_rootPart.RotationOffset; m_rootPart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); + bool cancelUndo = false; + if (!m_rootPart.Undoing) + { + m_rootPart.Undoing = true; + cancelUndo = true; + } m_rootPart.UpdateRotation(rot); if (m_rootPart.PhysActor != null) { @@ -3534,18 +3566,13 @@ namespace OpenSim.Region.Framework.Scenes newRot *= Quaternion.Inverse(axRot); prim.RotationOffset = newRot; prim.ScheduleTerseUpdate(); + prim.IgnoreUndoUpdate = false; } } - - foreach (SceneObjectPart childpart in Children.Values) + if (cancelUndo == true) { - if (childpart != m_rootPart) - { - childpart.IgnoreUndoUpdate = false; - childpart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); - } + m_rootPart.Undoing = false; } - lockPartsForRead(false); m_rootPart.ScheduleTerseUpdate(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 93a23ca..3327b1e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3506,8 +3506,6 @@ namespace OpenSim.Region.Framework.Scenes } public void StoreUndoState(UndoType type) { - - if (!Undoing && (m_parentGroup == null || m_parentGroup.RootPart == null || !m_parentGroup.RootPart.Undoing)) { if (!IgnoreUndoUpdate) diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 2af3316..f71b507 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -172,8 +172,9 @@ namespace OpenSim.Region.Framework.Scenes if (part.ParentID == 0 && GroupChange == false) { if (Position != Vector3.Zero) - part.ParentGroup.AbsolutePosition = Position; - part.RotationOffset = Rotation; + + part.ParentGroup.UpdateSinglePosition(Position, part.LocalId); + part.ParentGroup.UpdateSingleRotation(Rotation, part.LocalId); if (Scale != Vector3.Zero) part.Resize(Scale); part.ParentGroup.ScheduleGroupForTerseUpdate(); -- cgit v1.1