diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/UndoState.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/UndoState.cs | 76 |
1 files changed, 72 insertions, 4 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index d34d8e5..81f41db 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs | |||
@@ -30,9 +30,24 @@ using System.Reflection; | |||
30 | using log4net; | 30 | using log4net; |
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenSim.Region.Framework.Interfaces; | 32 | using OpenSim.Region.Framework.Interfaces; |
33 | using System; | ||
33 | 34 | ||
34 | namespace OpenSim.Region.Framework.Scenes | 35 | namespace OpenSim.Region.Framework.Scenes |
35 | { | 36 | { |
37 | [Flags] | ||
38 | public enum UndoType | ||
39 | { | ||
40 | STATE_PRIM_POSITION = 1, | ||
41 | STATE_PRIM_ROTATION = 2, | ||
42 | STATE_PRIM_SCALE = 4, | ||
43 | STATE_PRIM_ALL = 7, | ||
44 | STATE_GROUP_POSITION = 8, | ||
45 | STATE_GROUP_ROTATION = 16, | ||
46 | STATE_GROUP_SCALE = 32, | ||
47 | STATE_GROUP_ALL = 56, | ||
48 | STATE_ALL = 63 | ||
49 | } | ||
50 | |||
36 | public class UndoState | 51 | public class UndoState |
37 | { | 52 | { |
38 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -40,6 +55,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
40 | public Vector3 Position = Vector3.Zero; | 55 | public Vector3 Position = Vector3.Zero; |
41 | public Vector3 Scale = Vector3.Zero; | 56 | public Vector3 Scale = Vector3.Zero; |
42 | public Quaternion Rotation = Quaternion.Identity; | 57 | public Quaternion Rotation = Quaternion.Identity; |
58 | public Vector3 GroupPosition = Vector3.Zero; | ||
59 | public Quaternion GroupRotation = Quaternion.Identity; | ||
60 | public Vector3 GroupScale = Vector3.Zero; | ||
61 | public DateTime LastUpdated = DateTime.Now; | ||
62 | public UndoType Type; | ||
43 | 63 | ||
44 | /// <summary> | 64 | /// <summary> |
45 | /// Is this undo state for an entire group? | 65 | /// Is this undo state for an entire group? |
@@ -58,7 +78,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
58 | ForGroup = forGroup; | 78 | ForGroup = forGroup; |
59 | 79 | ||
60 | // if (ForGroup) | 80 | // if (ForGroup) |
61 | Position = part.ParentGroup.AbsolutePosition; | 81 | GroupScale = part.ParentGroup.RootPart.Shape.Scale; |
82 | |||
83 | //FUBAR WARNING: Do NOT get the group's absoluteposition here | ||
84 | //or you'll experience a loop and/or a stack issue | ||
85 | GroupPosition = part.ParentGroup.RootPart.AbsolutePosition; | ||
86 | GroupRotation = part.ParentGroup.GroupRotation; | ||
87 | Position = part.ParentGroup.RootPart.AbsolutePosition; | ||
62 | // else | 88 | // else |
63 | // Position = part.OffsetPosition; | 89 | // Position = part.OffsetPosition; |
64 | 90 | ||
@@ -90,7 +116,49 @@ namespace OpenSim.Region.Framework.Scenes | |||
90 | // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); | 116 | // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); |
91 | } | 117 | } |
92 | } | 118 | } |
93 | 119 | public void Merge(UndoState last) | |
120 | { | ||
121 | if ((Type & UndoType.STATE_GROUP_POSITION) == 0 || ((last.Type & UndoType.STATE_GROUP_POSITION) >= (Type & UndoType.STATE_GROUP_POSITION))) | ||
122 | { | ||
123 | GroupPosition = last.GroupPosition; | ||
124 | Position = last.Position; | ||
125 | } | ||
126 | if ((Type & UndoType.STATE_GROUP_SCALE) == 0 || ((last.Type & UndoType.STATE_GROUP_SCALE) >= (Type & UndoType.STATE_GROUP_SCALE))) | ||
127 | { | ||
128 | GroupScale = last.GroupScale; | ||
129 | Scale = last.Scale; | ||
130 | } | ||
131 | if ((Type & UndoType.STATE_GROUP_ROTATION) == 0 || ((last.Type & UndoType.STATE_GROUP_ROTATION) >= (Type & UndoType.STATE_GROUP_ROTATION))) | ||
132 | { | ||
133 | GroupRotation = last.GroupRotation; | ||
134 | Rotation = last.Rotation; | ||
135 | } | ||
136 | if ((Type & UndoType.STATE_PRIM_POSITION) == 0 || ((last.Type & UndoType.STATE_PRIM_POSITION) >= (Type & UndoType.STATE_PRIM_POSITION))) | ||
137 | { | ||
138 | Position = last.Position; | ||
139 | } | ||
140 | if ((Type & UndoType.STATE_PRIM_SCALE) == 0 || ((last.Type & UndoType.STATE_PRIM_SCALE) >= (Type & UndoType.STATE_PRIM_SCALE))) | ||
141 | { | ||
142 | Scale = last.Scale; | ||
143 | } | ||
144 | if ((Type & UndoType.STATE_PRIM_ROTATION) == 0 || ((last.Type & UndoType.STATE_PRIM_ROTATION) >= (Type & UndoType.STATE_PRIM_ROTATION))) | ||
145 | { | ||
146 | Rotation = last.Rotation; | ||
147 | } | ||
148 | Type = Type | last.Type; | ||
149 | } | ||
150 | public bool Compare(UndoState undo) | ||
151 | { | ||
152 | if (undo == null || Position == null) return false; | ||
153 | if (undo.Position == Position && undo.Rotation == Rotation && undo.Scale == Scale && undo.GroupPosition == GroupPosition && undo.GroupScale == GroupScale && undo.GroupRotation == GroupRotation) | ||
154 | { | ||
155 | return true; | ||
156 | } | ||
157 | else | ||
158 | { | ||
159 | return false; | ||
160 | } | ||
161 | } | ||
94 | /// <summary> | 162 | /// <summary> |
95 | /// Compare the relevant state in the given part to this state. | 163 | /// Compare the relevant state in the given part to this state. |
96 | /// </summary> | 164 | /// </summary> |
@@ -115,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
115 | return false; | 183 | return false; |
116 | } | 184 | } |
117 | 185 | ||
118 | public void PlaybackState(SceneObjectPart part) | 186 | private void RestoreState(SceneObjectPart part) |
119 | { | 187 | { |
120 | part.Undoing = true; | 188 | part.Undoing = true; |
121 | 189 | ||
@@ -249,4 +317,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
249 | m_terrainModule.UndoTerrain(m_terrainChannel); | 317 | m_terrainModule.UndoTerrain(m_terrainChannel); |
250 | } | 318 | } |
251 | } | 319 | } |
252 | } \ No newline at end of file | 320 | } |