From 3d3b81e67698cc361a9eca28083f5f526ff1de2e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 7 Mar 2012 07:31:26 +0000 Subject: changes on undo/redo (untested/incomplete). Think we may consider moving this mfrom SOP to client side. At least does seem to work a bit better ( again there wwas a issue on sop.copy ) --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 8 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 72 ++++------- OpenSim/Region/Framework/Scenes/UndoState.cs | 139 +++++---------------- 3 files changed, 66 insertions(+), 153 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8809cd0..038eaa4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -549,11 +549,12 @@ namespace OpenSim.Region.Framework.Scenes val.Z = Util.Clamp(oldp.Z, 0.5f, 4096.0f); } } - +/* don't see the need but worse don't see where is restored to false if things stay in foreach (SceneObjectPart part in m_parts.GetArray()) { part.IgnoreUndoUpdate = true; } + */ if (RootPart.GetStatusSandbox()) { if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) @@ -3519,7 +3520,7 @@ namespace OpenSim.Region.Framework.Scenes if (part.UUID == m_rootPart.UUID) { UpdateRootRotation(rot); - if (!m_rootPart.Undoing) +/* if (!m_rootPart.Undoing) { m_rootPart.Undoing = true; AbsolutePosition = pos; @@ -3527,8 +3528,9 @@ namespace OpenSim.Region.Framework.Scenes } else { + */ AbsolutePosition = pos; - } +// } } else { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 9c06786..8dd2c76 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -263,8 +263,8 @@ namespace OpenSim.Region.Framework.Scenes private bool m_occupied; // KF if any av is sitting on this prim private string m_text = String.Empty; private string m_touchName = String.Empty; - private readonly Stack m_undo = new Stack(5); - private readonly Stack m_redo = new Stack(5); + private Stack m_undo = new Stack(5); + private Stack m_redo = new Stack(5); private bool m_passTouches; @@ -1711,6 +1711,11 @@ namespace OpenSim.Region.Framework.Scenes dupe.Category = Category; dupe.m_rezzed = m_rezzed; + dupe.m_undo = new Stack(5); + dupe.m_redo = new Stack(5); + dupe.IgnoreUndoUpdate = false; + dupe.Undoing = false; + dupe.m_inventory = new SceneObjectPartInventory(dupe); dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); @@ -3661,61 +3666,38 @@ namespace OpenSim.Region.Framework.Scenes public void StoreUndoState(bool forGroup) { - if (!Undoing) + if (!Undoing && !IgnoreUndoUpdate) // just to read better - undo is in progress, or suspended { - if (!IgnoreUndoUpdate) + if (ParentGroup != null) { - if (ParentGroup != null) + lock (m_undo) { - lock (m_undo) + if (m_undo.Count > 0) { - if (m_undo.Count > 0) - { - UndoState last = m_undo.Peek(); - if (last != null) - { - // TODO: May need to fix for group comparison - if (last.Compare(this)) - { - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", - // Name, LocalId, m_undo.Count); + // see if we had a change - return; - } + UndoState last = m_undo.Peek(); + if (last != null) + { + if (last.Compare(this, forGroup)) + { + return; } } - - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", - // Name, LocalId, forGroup, m_undo.Count); - - if (ParentGroup.GetSceneMaxUndo() > 0) - { - UndoState nUndo = new UndoState(this, forGroup); + } - m_undo.Push(nUndo); + if (ParentGroup.GetSceneMaxUndo() > 0) + { + UndoState nUndo = new UndoState(this, forGroup); - if (m_redo.Count > 0) - m_redo.Clear(); + m_undo.Push(nUndo); - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", - // Name, LocalId, forGroup, m_undo.Count); - } + if (m_redo.Count > 0) + m_redo.Clear(); } } } - // else - // { - // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); - // } } - // else - // { - // m_log.DebugFormat( - // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); - // } } /// @@ -3751,7 +3733,7 @@ namespace OpenSim.Region.Framework.Scenes nUndo = new UndoState(this, goback.ForGroup); } - goback.PlaybackState(this); + goback.PlayState(this); if (nUndo != null) m_redo.Push(nUndo); @@ -3785,7 +3767,7 @@ namespace OpenSim.Region.Framework.Scenes m_undo.Push(nUndo); } - gofwd.PlayfwdState(this); + gofwd.PlayState(this); } // m_log.DebugFormat( diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 5ed3c79..029c828 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs @@ -66,43 +66,25 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// True if the undo is for an entire group + /// only for root parts ???? public UndoState(SceneObjectPart part, bool forGroup) { if (part.ParentID == 0) { ForGroup = forGroup; - - // if (ForGroup) Position = part.ParentGroup.AbsolutePosition; - // else - // Position = part.OffsetPosition; - - // m_log.DebugFormat( - // "[UNDO STATE]: Storing undo position {0} for root part", Position); - Rotation = part.RotationOffset; - - // m_log.DebugFormat( - // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); - - Scale = part.Shape.Scale; - - // m_log.DebugFormat( - // "[UNDO STATE]: Storing undo scale {0} for root part", Scale); + if (!forGroup) + Scale = part.Shape.Scale; + else + Scale = Vector3.Zero; // until we fix it } else { + ForGroup = false; // previus code implies only root parts can undo grp Position = part.OffsetPosition; - // m_log.DebugFormat( - // "[UNDO STATE]: Storing undo position {0} for child part", Position); - Rotation = part.RotationOffset; - // m_log.DebugFormat( - // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); - Scale = part.Shape.Scale; - // m_log.DebugFormat( - // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); } } @@ -111,35 +93,42 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// true if both the part's position, rotation and scale match those in this undo state. False otherwise. - public bool Compare(SceneObjectPart part) + public bool Compare(SceneObjectPart part, bool forgrp) { + if (ForGroup != forgrp) // if diferent targets, then they are diferent + return false; + if (part != null) { if (part.ParentID == 0) - return - Position == part.ParentGroup.AbsolutePosition - && Rotation == part.RotationOffset - && Scale == part.Shape.Scale; + { + // root part + // grp position is same as part + if (Position != part.ParentGroup.AbsolutePosition) + return false; + if (Rotation != part.RotationOffset) + return false; + if (ForGroup) + return true; // for now don't do grp scale + return (Scale == part.Shape.Scale); + } else - return - Position == part.OffsetPosition + { + return (Position == part.OffsetPosition && Rotation == part.RotationOffset - && Scale == part.Shape.Scale; + && Scale == part.Shape.Scale); + } } return false; } - public void PlaybackState(SceneObjectPart part) + public void PlayState(SceneObjectPart part) { part.Undoing = true; if (part.ParentID == 0) { - // m_log.DebugFormat( - // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", - // Position, part.Name, part.LocalId); - if (Position != Vector3.Zero) { if (ForGroup) @@ -148,10 +137,6 @@ namespace OpenSim.Region.Framework.Scenes part.ParentGroup.UpdateRootPosition(Position); } - // m_log.DebugFormat( - // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", - // part.RotationOffset, Rotation, part.Name, part.LocalId); - if (ForGroup) part.UpdateRotation(Rotation); else @@ -159,86 +144,30 @@ namespace OpenSim.Region.Framework.Scenes if (Scale != Vector3.Zero) { - // m_log.DebugFormat( - // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", - // part.Shape.Scale, Scale, part.Name, part.LocalId); - - if (ForGroup) - part.ParentGroup.GroupResize(Scale); - else + // if (ForGroup) + // part.ParentGroup.GroupResize(Scale); + // else + if (!ForGroup) // we don't have grp scale for now part.Resize(Scale); } - part.ParentGroup.ScheduleGroupForTerseUpdate(); } else { - // Note: Updating these properties on sop automatically schedules an update if needed - if (Position != Vector3.Zero) - { - // m_log.DebugFormat( - // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", - // part.OffsetPosition, Position, part.Name, part.LocalId); - - part.OffsetPosition = Position; - } - - // m_log.DebugFormat( - // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", - // part.RotationOffset, Rotation, part.Name, part.LocalId); + if (ForGroup) // trap for group since seems parts can't do it + return; + // Note: Updating these properties on sop automatically schedules an update if needed + part.OffsetPosition = Position; part.UpdateRotation(Rotation); - if (Scale != Vector3.Zero) { - // m_log.DebugFormat( - // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", - // part.Shape.Scale, Scale, part.Name, part.LocalId); - part.Resize(Scale); } } part.Undoing = false; } - - public void PlayfwdState(SceneObjectPart part) - { - part.Undoing = true; - - if (part.ParentID == 0) - { - if (Position != Vector3.Zero) - part.ParentGroup.AbsolutePosition = Position; - - if (Rotation != Quaternion.Identity) - part.UpdateRotation(Rotation); - - if (Scale != Vector3.Zero) - { - if (ForGroup) - part.ParentGroup.GroupResize(Scale); - else - part.Resize(Scale); - } - - part.ParentGroup.ScheduleGroupForTerseUpdate(); - } - else - { - // Note: Updating these properties on sop automatically schedules an update if needed - if (Position != Vector3.Zero) - part.OffsetPosition = Position; - - if (Rotation != Quaternion.Identity) - part.UpdateRotation(Rotation); - - if (Scale != Vector3.Zero) - part.Resize(Scale); - } - - part.Undoing = false; - } } public class LandUndoState -- cgit v1.1 From b8c27252c1c65cab64cff4e143c70be6441099c9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 8 Mar 2012 18:31:58 +0100 Subject: Hold a ref to the prim we're sat on rather than querying scene each time the check for significant is carried out. Prevents a deadlock condition. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 57 +++++++++++++----------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 26fa6c0..8a7c06a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -527,15 +527,8 @@ namespace OpenSim.Region.Framework.Scenes // without the parent rotation applied. if (ParentID != 0) { - SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID); - if (part != null) - { + SceneObjectPart part = ParentPart; return part.AbsolutePosition + (m_pos * part.GetWorldRotation()); - } - else - { - return ParentPosition + m_pos; - } } } return m_pos; @@ -653,6 +646,13 @@ namespace OpenSim.Region.Framework.Scenes } private UUID m_parentUUID = UUID.Zero; + public SceneObjectPart ParentPart + { + get { return m_parentPart; } + set { m_parentPart = value; } + } + private SceneObjectPart m_parentPart = null; + public float Health { get { return m_health; } @@ -891,6 +891,7 @@ namespace OpenSim.Region.Framework.Scenes part.SitTargetAvatar = UUID; ParentPosition = part.GetWorldPosition(); ParentID = part.LocalId; + ParentPart = part; m_pos = m_prevSitOffset; pos = ParentPosition; } @@ -1865,37 +1866,35 @@ namespace OpenSim.Region.Framework.Scenes if (ParentID != 0) { - SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID); - if (part != null) + SceneObjectPart part = ParentPart; + TaskInventoryDictionary taskIDict = part.TaskInventory; + if (taskIDict != null) { - TaskInventoryDictionary taskIDict = part.TaskInventory; - if (taskIDict != null) + lock (taskIDict) { - lock (taskIDict) + foreach (UUID taskID in taskIDict.Keys) { - foreach (UUID taskID in taskIDict.Keys) - { - UnRegisterControlEventsToScript(LocalId, taskID); - taskIDict[taskID].PermsMask &= ~( - 2048 | //PERMISSION_CONTROL_CAMERA - 4); // PERMISSION_TAKE_CONTROLS - } + UnRegisterControlEventsToScript(LocalId, taskID); + taskIDict[taskID].PermsMask &= ~( + 2048 | //PERMISSION_CONTROL_CAMERA + 4); // PERMISSION_TAKE_CONTROLS } } + } - // Reset sit target. - if (part.SitTargetAvatar == UUID) - part.SitTargetAvatar = UUID.Zero; + // Reset sit target. + if (part.SitTargetAvatar == UUID) + part.SitTargetAvatar = UUID.Zero; - part.ParentGroup.DeleteAvatar(UUID); - ParentPosition = part.GetWorldPosition(); - ControllingClient.SendClearFollowCamProperties(part.ParentUUID); - } + part.ParentGroup.DeleteAvatar(UUID); + ParentPosition = part.GetWorldPosition(); + ControllingClient.SendClearFollowCamProperties(part.ParentUUID); m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); ParentPosition = Vector3.Zero; ParentID = 0; + ParentPart = null; if (PhysicsActor == null) AddToPhysicalScene(false); @@ -2356,6 +2355,10 @@ namespace OpenSim.Region.Framework.Scenes return; } + ParentPart = m_scene.GetSceneObjectPart(m_requestedSitTargetID); + if (ParentPart == null) + return; + ParentID = m_requestedSitTargetID; Velocity = Vector3.Zero; -- cgit v1.1