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 )

avinationmerge
UbitUmarov 2012-03-07 07:31:26 +00:00
parent 0be4ed3df4
commit 3d3b81e676
3 changed files with 66 additions and 153 deletions

View File

@ -549,11 +549,12 @@ namespace OpenSim.Region.Framework.Scenes
val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f); val.Z = Util.Clamp<float>(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()) foreach (SceneObjectPart part in m_parts.GetArray())
{ {
part.IgnoreUndoUpdate = true; part.IgnoreUndoUpdate = true;
} }
*/
if (RootPart.GetStatusSandbox()) if (RootPart.GetStatusSandbox())
{ {
if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10)
@ -3519,7 +3520,7 @@ namespace OpenSim.Region.Framework.Scenes
if (part.UUID == m_rootPart.UUID) if (part.UUID == m_rootPart.UUID)
{ {
UpdateRootRotation(rot); UpdateRootRotation(rot);
if (!m_rootPart.Undoing) /* if (!m_rootPart.Undoing)
{ {
m_rootPart.Undoing = true; m_rootPart.Undoing = true;
AbsolutePosition = pos; AbsolutePosition = pos;
@ -3527,8 +3528,9 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
*/
AbsolutePosition = pos; AbsolutePosition = pos;
} // }
} }
else else
{ {

View File

@ -263,8 +263,8 @@ namespace OpenSim.Region.Framework.Scenes
private bool m_occupied; // KF if any av is sitting on this prim private bool m_occupied; // KF if any av is sitting on this prim
private string m_text = String.Empty; private string m_text = String.Empty;
private string m_touchName = String.Empty; private string m_touchName = String.Empty;
private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5); private Stack<UndoState> m_undo = new Stack<UndoState>(5);
private readonly Stack<UndoState> m_redo = new Stack<UndoState>(5); private Stack<UndoState> m_redo = new Stack<UndoState>(5);
private bool m_passTouches; private bool m_passTouches;
@ -1711,6 +1711,11 @@ namespace OpenSim.Region.Framework.Scenes
dupe.Category = Category; dupe.Category = Category;
dupe.m_rezzed = m_rezzed; dupe.m_rezzed = m_rezzed;
dupe.m_undo = new Stack<UndoState>(5);
dupe.m_redo = new Stack<UndoState>(5);
dupe.IgnoreUndoUpdate = false;
dupe.Undoing = false;
dupe.m_inventory = new SceneObjectPartInventory(dupe); dupe.m_inventory = new SceneObjectPartInventory(dupe);
dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone();
@ -3661,61 +3666,38 @@ namespace OpenSim.Region.Framework.Scenes
public void StoreUndoState(bool forGroup) 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) // see if we had a change
{
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);
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_undo.Push(nUndo);
m_redo.Clear();
// m_log.DebugFormat( if (m_redo.Count > 0)
// "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", m_redo.Clear();
// Name, LocalId, forGroup, m_undo.Count);
}
} }
} }
} }
// 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);
// }
} }
/// <summary> /// <summary>
@ -3751,7 +3733,7 @@ namespace OpenSim.Region.Framework.Scenes
nUndo = new UndoState(this, goback.ForGroup); nUndo = new UndoState(this, goback.ForGroup);
} }
goback.PlaybackState(this); goback.PlayState(this);
if (nUndo != null) if (nUndo != null)
m_redo.Push(nUndo); m_redo.Push(nUndo);
@ -3785,7 +3767,7 @@ namespace OpenSim.Region.Framework.Scenes
m_undo.Push(nUndo); m_undo.Push(nUndo);
} }
gofwd.PlayfwdState(this); gofwd.PlayState(this);
} }
// m_log.DebugFormat( // m_log.DebugFormat(

View File

@ -66,43 +66,25 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
/// <param name="part"></param> /// <param name="part"></param>
/// <param name="forGroup">True if the undo is for an entire group</param> /// <param name="forGroup">True if the undo is for an entire group</param>
/// only for root parts ????
public UndoState(SceneObjectPart part, bool forGroup) public UndoState(SceneObjectPart part, bool forGroup)
{ {
if (part.ParentID == 0) if (part.ParentID == 0)
{ {
ForGroup = forGroup; ForGroup = forGroup;
// if (ForGroup)
Position = part.ParentGroup.AbsolutePosition; Position = part.ParentGroup.AbsolutePosition;
// else
// Position = part.OffsetPosition;
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo position {0} for root part", Position);
Rotation = part.RotationOffset; Rotation = part.RotationOffset;
if (!forGroup)
// m_log.DebugFormat( Scale = part.Shape.Scale;
// "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); else
Scale = Vector3.Zero; // until we fix it
Scale = part.Shape.Scale;
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo scale {0} for root part", Scale);
} }
else else
{ {
ForGroup = false; // previus code implies only root parts can undo grp
Position = part.OffsetPosition; Position = part.OffsetPosition;
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo position {0} for child part", Position);
Rotation = part.RotationOffset; Rotation = part.RotationOffset;
// m_log.DebugFormat(
// "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation);
Scale = part.Shape.Scale; 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
/// </summary> /// </summary>
/// <param name="part"></param> /// <param name="part"></param>
/// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns> /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns>
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 != null)
{ {
if (part.ParentID == 0) if (part.ParentID == 0)
return {
Position == part.ParentGroup.AbsolutePosition // root part
&& Rotation == part.RotationOffset // grp position is same as part
&& Scale == part.Shape.Scale; 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 else
return {
Position == part.OffsetPosition return (Position == part.OffsetPosition
&& Rotation == part.RotationOffset && Rotation == part.RotationOffset
&& Scale == part.Shape.Scale; && Scale == part.Shape.Scale);
}
} }
return false; return false;
} }
public void PlaybackState(SceneObjectPart part) public void PlayState(SceneObjectPart part)
{ {
part.Undoing = true; part.Undoing = true;
if (part.ParentID == 0) 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 (Position != Vector3.Zero)
{ {
if (ForGroup) if (ForGroup)
@ -148,10 +137,6 @@ namespace OpenSim.Region.Framework.Scenes
part.ParentGroup.UpdateRootPosition(Position); 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) if (ForGroup)
part.UpdateRotation(Rotation); part.UpdateRotation(Rotation);
else else
@ -159,86 +144,30 @@ namespace OpenSim.Region.Framework.Scenes
if (Scale != Vector3.Zero) if (Scale != Vector3.Zero)
{ {
// m_log.DebugFormat( // if (ForGroup)
// "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", // part.ParentGroup.GroupResize(Scale);
// part.Shape.Scale, Scale, part.Name, part.LocalId); // else
if (!ForGroup) // we don't have grp scale for now
if (ForGroup)
part.ParentGroup.GroupResize(Scale);
else
part.Resize(Scale); part.Resize(Scale);
} }
part.ParentGroup.ScheduleGroupForTerseUpdate(); part.ParentGroup.ScheduleGroupForTerseUpdate();
} }
else else
{ {
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 // Note: Updating these properties on sop automatically schedules an update if needed
if (Position != Vector3.Zero) part.OffsetPosition = Position;
{
// 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);
part.UpdateRotation(Rotation); part.UpdateRotation(Rotation);
if (Scale != Vector3.Zero) 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.Resize(Scale);
} }
} }
part.Undoing = false; 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 public class LandUndoState