Refactor, move OjectChangeData into it's own file and rename

ObjectChnageWhat what into ObjectChangeType change. What is
no name for a variable or type!
avinationmerge
Melanie 2012-03-13 13:08:32 +01:00
parent edc8a15487
commit ebcd4910a2
6 changed files with 133 additions and 165 deletions

View File

@ -0,0 +1,80 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using OpenMetaverse;
namespace OpenSim.Framework
{
public enum ObjectChangeType : uint
{
// bits definitions
Position = 0x01,
Rotation = 0x02,
Scale = 0x04,
Group = 0x08,
UniformScale = 0x10,
// macros from above
// single prim
primP = 0x01,
primR = 0x02,
primPR = 0x03,
primS = 0x04,
primPS = 0x05,
primRS = 0x06,
primPSR = 0x07,
primUS = 0x14,
primPUS = 0x15,
primRUS = 0x16,
primPUSR = 0x17,
// group
groupP = 0x09,
groupR = 0x0A,
groupPR = 0x0B,
groupS = 0x0C,
groupPS = 0x0D,
groupRS = 0x0E,
groupPSR = 0x0F,
groupUS = 0x1C,
groupPUS = 0x1D,
groupRUS = 0x1E,
groupPUSR = 0x1F,
PRSmask = 0x07
}
public struct ObjectChangeData
{
public Quaternion rotation;
public Vector3 position;
public Vector3 scale;
public ObjectChangeType change;
}
}

View File

@ -11504,14 +11504,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
case 1: //change position sp case 1: //change position sp
udata.position = new Vector3(block.Data, 0); udata.position = new Vector3(block.Data, 0);
udata.what = ObjectChangeWhat.primP; udata.change = ObjectChangeType.primP;
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
case 2: // rotation sp case 2: // rotation sp
udata.rotation = new Quaternion(block.Data, 0, true); udata.rotation = new Quaternion(block.Data, 0, true);
udata.what = ObjectChangeWhat.primR; udata.change = ObjectChangeType.primR;
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
@ -11519,13 +11519,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
udata.position = new Vector3(block.Data, 0); udata.position = new Vector3(block.Data, 0);
udata.rotation = new Quaternion(block.Data, 12, true); udata.rotation = new Quaternion(block.Data, 12, true);
udata.what = ObjectChangeWhat.primPR; udata.change = ObjectChangeType.primPR;
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
case 4: // scale sp case 4: // scale sp
udata.scale = new Vector3(block.Data, 0); udata.scale = new Vector3(block.Data, 0);
udata.what = ObjectChangeWhat.primS; udata.change = ObjectChangeType.primS;
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
@ -11533,7 +11533,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
case 0x14: // uniform scale sp case 0x14: // uniform scale sp
udata.scale = new Vector3(block.Data, 0); udata.scale = new Vector3(block.Data, 0);
udata.what = ObjectChangeWhat.primUS; udata.change = ObjectChangeType.primUS;
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
@ -11541,7 +11541,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
udata.position = new Vector3(block.Data, 0); udata.position = new Vector3(block.Data, 0);
udata.scale = new Vector3(block.Data, 12); udata.scale = new Vector3(block.Data, 12);
udata.what = ObjectChangeWhat.primPS; udata.change = ObjectChangeType.primPS;
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
@ -11549,7 +11549,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
udata.position = new Vector3(block.Data, 0); udata.position = new Vector3(block.Data, 0);
udata.scale = new Vector3(block.Data, 12); udata.scale = new Vector3(block.Data, 12);
udata.what = ObjectChangeWhat.primPUS; udata.change = ObjectChangeType.primPUS;
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
@ -11557,14 +11557,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
case 9: //( 8 + 1 )group position case 9: //( 8 + 1 )group position
udata.position = new Vector3(block.Data, 0); udata.position = new Vector3(block.Data, 0);
udata.what = ObjectChangeWhat.groupP; udata.change = ObjectChangeType.groupP;
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
case 0x0A: // (8 + 2) group rotation case 0x0A: // (8 + 2) group rotation
udata.rotation = new Quaternion(block.Data, 0, true); udata.rotation = new Quaternion(block.Data, 0, true);
udata.what = ObjectChangeWhat.groupR; udata.change = ObjectChangeType.groupR;
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
@ -11572,7 +11572,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
udata.position = new Vector3(block.Data, 0); udata.position = new Vector3(block.Data, 0);
udata.rotation = new Quaternion(block.Data, 12, true); udata.rotation = new Quaternion(block.Data, 12, true);
udata.what = ObjectChangeWhat.groupPR; udata.change = ObjectChangeType.groupPR;
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
@ -11583,8 +11583,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
udata.scale = new Vector3(block.Data, 0); udata.scale = new Vector3(block.Data, 0);
// udata.what = ObjectChangeWhat.groupS; // udata.change = ObjectChangeType.groupS;
udata.what = ObjectChangeWhat.primS; // to conform to current SL udata.change = ObjectChangeType.primS; // to conform to current SL
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
@ -11595,15 +11595,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
udata.position = new Vector3(block.Data, 0); udata.position = new Vector3(block.Data, 0);
udata.scale = new Vector3(block.Data, 12); udata.scale = new Vector3(block.Data, 12);
// udata.what = ObjectChangeWhat.groupPS; // udata.change = ObjectChangeType.groupPS;
udata.what = ObjectChangeWhat.primPS; // to conform to current SL udata.change = ObjectChangeType.primPS; // to conform to current SL
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
case 0x1C: // (0x10 + 8 + 4 ) group scale UNIFORM case 0x1C: // (0x10 + 8 + 4 ) group scale UNIFORM
udata.scale = new Vector3(block.Data, 0); udata.scale = new Vector3(block.Data, 0);
udata.what = ObjectChangeWhat.groupUS; udata.change = ObjectChangeType.groupUS;
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;
@ -11611,7 +11611,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
udata.position = new Vector3(block.Data, 0); udata.position = new Vector3(block.Data, 0);
udata.scale = new Vector3(block.Data, 12); udata.scale = new Vector3(block.Data, 12);
udata.what = ObjectChangeWhat.groupPUS; udata.change = ObjectChangeType.groupPUS;
updatehandler(localId, udata, this); updatehandler(localId, udata, this);
break; break;

View File

@ -47,57 +47,6 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void ChangedBackupDelegate(SceneObjectGroup sog); public delegate void ChangedBackupDelegate(SceneObjectGroup sog);
public enum ObjectChangeWhat : uint
{
// bits definitions
Position = 0x01,
Rotation = 0x02,
Scale = 0x04,
Group = 0x08,
UniformScale = 0x10,
// macros from above
// single prim
primP = 0x01,
primR = 0x02,
primPR = 0x03,
primS = 0x04,
primPS = 0x05,
primRS = 0x06,
primPSR = 0x07,
primUS = 0x14,
primPUS = 0x15,
primRUS = 0x16,
primPUSR = 0x17,
// group
groupP = 0x09,
groupR = 0x0A,
groupPR = 0x0B,
groupS = 0x0C,
groupPS = 0x0D,
groupRS = 0x0E,
groupPSR = 0x0F,
groupUS = 0x1C,
groupPUS = 0x1D,
groupRUS = 0x1E,
groupPUSR = 0x1F,
PRSmask = 0x07
}
public struct ObjectChangeData
{
public Quaternion rotation;
public Vector3 position;
public Vector3 scale;
public ObjectChangeWhat what;
}
/// <summary> /// <summary>
/// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components
/// should be migrated out over time. /// should be migrated out over time.
@ -1352,75 +1301,13 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId)) if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId))
{ {
// part.StoreUndoState(data.what | ObjectChangeWhat.PRSmask); // for now save all to keep previus behavour ??? part.StoreUndoState(data.change); // lets test only saving what we changed
part.StoreUndoState(data.what); // lets test only saving what we changed
grp.doChangeObject(part, (ObjectChangeData)data); grp.doChangeObject(part, (ObjectChangeData)data);
} }
} }
} }
} }
/* moved to SOG
protected internal void doChangeObject(SceneObjectPart part, ObjectChangeData data)
{
if (part != null && part.ParentGroup != null)
{
ObjectChangeWhat what = data.what;
bool togroup = ((what & ObjectChangeWhat.Group) != 0);
// bool uniform = ((what & ObjectChangeWhat.UniformScale) != 0); not in use
SceneObjectGroup group = part.ParentGroup;
PhysicsActor pha = group.RootPart.PhysActor;
if (togroup)
{
// related to group
if ((what & ObjectChangeWhat.Position) != 0)
group.AbsolutePosition = data.position;
if ((what & ObjectChangeWhat.Rotation) != 0)
group.RootPart.UpdateRotation(data.rotation);
if ((what & ObjectChangeWhat.Scale) != 0)
{
if (pha != null)
pha.Building = true;
group.GroupResize(data.scale);
if (pha != null)
pha.Building = false;
}
}
else
{
// related to single prim in a link-set ( ie group)
if (pha != null)
pha.Building = true;
// must deal with root part specially for position and rotation
// so parts offset positions or rotations are fixed
if (part == group.RootPart)
{
if ((what & ObjectChangeWhat.Position) != 0)
group.UpdateRootPosition(data.position);
if ((what & ObjectChangeWhat.Rotation) != 0)
group.UpdateRootRotation(data.rotation);
}
else
{
if ((what & ObjectChangeWhat.Position) != 0)
part.OffsetPosition = data.position;
if ((what & ObjectChangeWhat.Rotation) != 0)
part.UpdateRotation(data.rotation);
}
if ((what & ObjectChangeWhat.Scale) != 0)
part.Resize(data.scale);
if (pha != null)
pha.Building = false;
}
}
}
*/
/// <summary> /// <summary>
/// Update the scale of an individual prim. /// Update the scale of an individual prim.
/// </summary> /// </summary>

View File

@ -3521,9 +3521,9 @@ namespace OpenSim.Region.Framework.Scenes
if (part != null && part.ParentGroup != null) if (part != null && part.ParentGroup != null)
{ {
ObjectChangeWhat what = data.what; ObjectChangeType change = data.change;
bool togroup = ((what & ObjectChangeWhat.Group) != 0); bool togroup = ((change & ObjectChangeType.Group) != 0);
// bool uniform = ((what & ObjectChangeWhat.UniformScale) != 0); not in use // bool uniform = ((what & ObjectChangeType.UniformScale) != 0); not in use
SceneObjectGroup group = part.ParentGroup; SceneObjectGroup group = part.ParentGroup;
PhysicsActor pha = group.RootPart.PhysActor; PhysicsActor pha = group.RootPart.PhysActor;
@ -3533,17 +3533,17 @@ namespace OpenSim.Region.Framework.Scenes
if (togroup) if (togroup)
{ {
// related to group // related to group
if ((what & ObjectChangeWhat.Position) != 0) if ((change & ObjectChangeType.Position) != 0)
{ {
group.AbsolutePosition = data.position; group.AbsolutePosition = data.position;
updateType = updatetype.groupterse; updateType = updatetype.groupterse;
} }
if ((what & ObjectChangeWhat.Rotation) != 0) if ((change & ObjectChangeType.Rotation) != 0)
{ {
group.RootPart.UpdateRotation(data.rotation); group.RootPart.UpdateRotation(data.rotation);
updateType = updatetype.none; updateType = updatetype.none;
} }
if ((what & ObjectChangeWhat.Scale) != 0) if ((change & ObjectChangeType.Scale) != 0)
{ {
if (pha != null) if (pha != null)
pha.Building = true; pha.Building = true;
@ -3566,26 +3566,26 @@ namespace OpenSim.Region.Framework.Scenes
if (part == group.RootPart) if (part == group.RootPart)
{ {
if ((what & ObjectChangeWhat.Position) != 0) if ((change & ObjectChangeType.Position) != 0)
group.UpdateRootPosition(data.position); group.UpdateRootPosition(data.position);
if ((what & ObjectChangeWhat.Rotation) != 0) if ((change & ObjectChangeType.Rotation) != 0)
group.UpdateRootRotation(data.rotation); group.UpdateRootRotation(data.rotation);
if ((what & ObjectChangeWhat.Scale) != 0) if ((change & ObjectChangeType.Scale) != 0)
part.Resize(data.scale); part.Resize(data.scale);
} }
else else
{ {
if ((what & ObjectChangeWhat.Position) != 0) if ((change & ObjectChangeType.Position) != 0)
{ {
part.OffsetPosition = data.position; part.OffsetPosition = data.position;
updateType = updatetype.partterse; updateType = updatetype.partterse;
} }
if ((what & ObjectChangeWhat.Rotation) != 0) if ((change & ObjectChangeType.Rotation) != 0)
{ {
part.UpdateRotation(data.rotation); part.UpdateRotation(data.rotation);
updateType = updatetype.none; updateType = updatetype.none;
} }
if ((what & ObjectChangeWhat.Scale) != 0) if ((change & ObjectChangeType.Scale) != 0)
{ {
part.Resize(data.scale); part.Resize(data.scale);
updateType = updatetype.none; updateType = updatetype.none;

View File

@ -3644,7 +3644,7 @@ namespace OpenSim.Region.Framework.Scenes
//ParentGroup.ScheduleGroupForFullUpdate(); //ParentGroup.ScheduleGroupForFullUpdate();
} }
public void StoreUndoState(ObjectChangeWhat what) public void StoreUndoState(ObjectChangeType change)
{ {
if (m_UndoRedo == null) if (m_UndoRedo == null)
m_UndoRedo = new UndoRedoState(5); m_UndoRedo = new UndoRedoState(5);
@ -3653,7 +3653,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended
{ {
m_UndoRedo.StoreUndo(this, what); m_UndoRedo.StoreUndo(this, change);
} }
} }
} }

View File

@ -30,6 +30,7 @@ using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using log4net; using log4net;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
namespace OpenSim.Region.Framework.Scenes namespace OpenSim.Region.Framework.Scenes
@ -44,30 +45,30 @@ namespace OpenSim.Region.Framework.Scenes
/// Constructor. /// Constructor.
/// </summary> /// </summary>
/// <param name="part"></param> /// <param name="part"></param>
/// <param name="what">bit field with what is changed</param> /// <param name="change">bit field with what is changed</param>
/// ///
public UndoState(SceneObjectPart part, ObjectChangeWhat what) public UndoState(SceneObjectPart part, ObjectChangeType change)
{ {
data = new ObjectChangeData(); data = new ObjectChangeData();
data.what = what; data.change = change;
creationtime = DateTime.UtcNow; creationtime = DateTime.UtcNow;
if (part.ParentGroup.RootPart == part) if (part.ParentGroup.RootPart == part)
{ {
if ((what & ObjectChangeWhat.Position) != 0) if ((change & ObjectChangeType.Position) != 0)
data.position = part.ParentGroup.AbsolutePosition; data.position = part.ParentGroup.AbsolutePosition;
if ((what & ObjectChangeWhat.Rotation) != 0) if ((change & ObjectChangeType.Rotation) != 0)
data.rotation = part.RotationOffset; data.rotation = part.RotationOffset;
if ((what & ObjectChangeWhat.Scale) != 0) if ((change & ObjectChangeType.Scale) != 0)
data.scale = part.Shape.Scale; data.scale = part.Shape.Scale;
} }
else else
{ {
if ((what & ObjectChangeWhat.Position) != 0) if ((change & ObjectChangeType.Position) != 0)
data.position = part.OffsetPosition; data.position = part.OffsetPosition;
if ((what & ObjectChangeWhat.Rotation) != 0) if ((change & ObjectChangeType.Rotation) != 0)
data.rotation = part.RotationOffset; data.rotation = part.RotationOffset;
if ((what & ObjectChangeWhat.Scale) != 0) if ((change & ObjectChangeType.Scale) != 0)
data.scale = part.Shape.Scale; data.scale = part.Shape.Scale;
} }
} }
@ -97,27 +98,27 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="part"></param> /// <param name="part"></param>
/// <returns>true what fiels and related data are equal, False otherwise.</returns> /// <returns>true what fiels and related data are equal, False otherwise.</returns>
/// ///
public bool Compare(SceneObjectPart part, ObjectChangeWhat what) public bool Compare(SceneObjectPart part, ObjectChangeType change)
{ {
if (data.what != what) // if diferent targets, then they are diferent if (data.change != change) // if diferent targets, then they are diferent
return false; return false;
if (part != null) if (part != null)
{ {
if (part.ParentID == 0) if (part.ParentID == 0)
{ {
if ((what & ObjectChangeWhat.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition) if ((change & ObjectChangeType.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition)
return false; return false;
} }
else else
{ {
if ((what & ObjectChangeWhat.Position) != 0 && data.position != part.OffsetPosition) if ((change & ObjectChangeType.Position) != 0 && data.position != part.OffsetPosition)
return false; return false;
} }
if ((what & ObjectChangeWhat.Rotation) != 0 && data.rotation != part.RotationOffset) if ((change & ObjectChangeType.Rotation) != 0 && data.rotation != part.RotationOffset)
return false; return false;
if ((what & ObjectChangeWhat.Rotation) != 0 && data.scale == part.Shape.Scale) if ((change & ObjectChangeType.Rotation) != 0 && data.scale == part.Shape.Scale)
return false; return false;
return true; return true;
@ -196,9 +197,9 @@ namespace OpenSim.Region.Framework.Scenes
/// adds a new state undo to part or its group, with changes indicated by what bits /// adds a new state undo to part or its group, with changes indicated by what bits
/// </summary> /// </summary>
/// <param name="part"></param> /// <param name="part"></param>
/// <param name="what">bit field with what is changed</param> /// <param name="change">bit field with what is changed</param>
public void StoreUndo(SceneObjectPart part, ObjectChangeWhat what) public void StoreUndo(SceneObjectPart part, ObjectChangeType change)
{ {
lock (m_undo) lock (m_undo)
{ {
@ -220,7 +221,7 @@ namespace OpenSim.Region.Framework.Scenes
// see if we actually have a change // see if we actually have a change
if (last != null) if (last != null)
{ {
if (last.Compare(part, what)) if (last.Compare(part, change))
return; return;
} }
} }
@ -230,7 +231,7 @@ namespace OpenSim.Region.Framework.Scenes
while (m_undo.Count >= size) while (m_undo.Count >= size)
m_undo.RemoveLast(); m_undo.RemoveLast();
UndoState nUndo = new UndoState(part, what); UndoState nUndo = new UndoState(part, change);
m_undo.AddFirst(nUndo); m_undo.AddFirst(nUndo);
} }
} }
@ -273,7 +274,7 @@ namespace OpenSim.Region.Framework.Scenes
while (m_redo.Count >= size) while (m_redo.Count >= size)
m_redo.RemoveLast(); m_redo.RemoveLast();
nUndo = new UndoState(part, goback.data.what); // new value in part should it be full goback copy? nUndo = new UndoState(part, goback.data.change); // new value in part should it be full goback copy?
m_redo.AddFirst(nUndo); m_redo.AddFirst(nUndo);
goback.PlayState(part); goback.PlayState(part);
@ -320,7 +321,7 @@ namespace OpenSim.Region.Framework.Scenes
while (m_undo.Count >= size) while (m_undo.Count >= size)
m_undo.RemoveLast(); m_undo.RemoveLast();
nUndo = new UndoState(part, gofwd.data.what); // new value in part should it be full gofwd copy? nUndo = new UndoState(part, gofwd.data.change); // new value in part should it be full gofwd copy?
m_undo.AddFirst(nUndo); m_undo.AddFirst(nUndo);
gofwd.PlayState(part); gofwd.PlayState(part);