refactor: group all the undo/redo code in SOP into one place for easier code reading

bulletsim
Justin Clark-Casey (justincc) 2011-07-18 01:33:57 +01:00
parent f5ddf37112
commit e9a739f45f
1 changed files with 62 additions and 59 deletions

View File

@ -414,7 +414,6 @@ namespace OpenSim.Region.Framework.Scenes
CreateSelected = true; CreateSelected = true;
TrimPermissions(); TrimPermissions();
//m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo());
m_inventory = new SceneObjectPartInventory(this); m_inventory = new SceneObjectPartInventory(this);
} }
@ -1621,19 +1620,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void ClearUndoState()
{
lock (m_undo)
{
m_undo.Clear();
}
lock (m_redo)
{
m_redo.Clear();
}
StoreUndoState();
}
public byte ConvertScriptUintToByte(uint indata) public byte ConvertScriptUintToByte(uint indata)
{ {
byte outdata = (byte)TextureAnimFlags.NONE; byte outdata = (byte)TextureAnimFlags.NONE;
@ -3721,6 +3707,68 @@ namespace OpenSim.Region.Framework.Scenes
// } // }
} }
public void Undo()
{
// m_log.DebugFormat("[SCENE OBJECT PART]: Handling undo request for {0} {1}", Name, LocalId);
lock (m_undo)
{
if (m_undo.Count > 0)
{
UndoState nUndo = null;
if (m_parentGroup.GetSceneMaxUndo() > 0)
{
nUndo = new UndoState(this);
}
UndoState goback = m_undo.Pop();
if (goback != null)
{
goback.PlaybackState(this);
if (nUndo != null)
m_redo.Push(nUndo);
}
}
}
}
public void Redo()
{
// m_log.DebugFormat("[SCENE OBJECT PART]: Handling redo request for {0} {1}", Name, LocalId);
lock (m_redo)
{
if (m_parentGroup.GetSceneMaxUndo() > 0)
{
UndoState nUndo = new UndoState(this);
m_undo.Push(nUndo);
}
UndoState gofwd = m_redo.Pop();
if (gofwd != null)
gofwd.PlayfwdState(this);
}
}
public void ClearUndoState()
{
lock (m_undo)
{
m_undo.Clear();
}
lock (m_redo)
{
m_redo.Clear();
}
StoreUndoState();
}
public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot) public EntityIntersection TestIntersection(Ray iray, Quaternion parentrot)
{ {
// In this case we're using a sphere with a radius of the largest dimension of the prim // In this case we're using a sphere with a radius of the largest dimension of the prim
@ -4181,51 +4229,6 @@ namespace OpenSim.Region.Framework.Scenes
_nextOwnerMask &= (uint)PermissionMask.All; _nextOwnerMask &= (uint)PermissionMask.All;
} }
public void Undo()
{
lock (m_undo)
{
if (m_undo.Count > 0)
{
UndoState nUndo = null;
if (m_parentGroup.GetSceneMaxUndo() > 0)
{
nUndo = new UndoState(this);
}
UndoState goback = m_undo.Pop();
if (goback != null)
{
goback.PlaybackState(this);
if (nUndo != null)
m_redo.Push(nUndo);
}
}
}
}
public void Redo()
{
// m_log.DebugFormat("[SCENE OBJECT PART]: Handling redo request for {0} {1}", Name, LocalId);
lock (m_redo)
{
if (m_parentGroup.GetSceneMaxUndo() > 0)
{
UndoState nUndo = new UndoState(this);
m_undo.Push(nUndo);
}
UndoState gofwd = m_redo.Pop();
if (gofwd != null)
gofwd.PlayfwdState(this);
}
}
public void UpdateExtraParam(ushort type, bool inUse, byte[] data) public void UpdateExtraParam(ushort type, bool inUse, byte[] data)
{ {
m_shape.ReadInUpdateExtraParam(type, inUse, data); m_shape.ReadInUpdateExtraParam(type, inUse, data);