aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/UndoState.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-07-18 04:54:21 +0100
committerJustin Clark-Casey (justincc)2011-07-18 04:54:21 +0100
commit6fc74b36d1d0f7dcd6f013893c3189a3f989431c (patch)
treea82bdd3fe6f15298624a142a3705f2739a8ee031 /OpenSim/Region/Framework/Scenes/UndoState.cs
parentuse standard sdk stack in terrain model rather than OpenSim.Framework.UndoStack. (diff)
downloadopensim-SC-6fc74b36d1d0f7dcd6f013893c3189a3f989431c.zip
opensim-SC-6fc74b36d1d0f7dcd6f013893c3189a3f989431c.tar.gz
opensim-SC-6fc74b36d1d0f7dcd6f013893c3189a3f989431c.tar.bz2
opensim-SC-6fc74b36d1d0f7dcd6f013893c3189a3f989431c.tar.xz
Make various tweaks to undo code in an effort to get things working better.
Undo rotation and position appear to be working. Resizing a single prim appears to be working, though the undo has to be done twice. Resizing a group of prims still does not work properly - possibly because in the UndoState we don't store a knowledge of when we're resizing a whole group rather than individual prims. This needs to be addressed.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/UndoState.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/UndoState.cs93
1 files changed, 87 insertions, 6 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 55e407e..38bbeb0 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -25,6 +25,9 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
29using System.Reflection;
30using log4net;
28using OpenMetaverse; 31using OpenMetaverse;
29using OpenSim.Region.Framework.Interfaces; 32using OpenSim.Region.Framework.Interfaces;
30 33
@@ -32,49 +35,80 @@ namespace OpenSim.Region.Framework.Scenes
32{ 35{
33 public class UndoState 36 public class UndoState
34 { 37 {
38// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39
35 public Vector3 Position = Vector3.Zero; 40 public Vector3 Position = Vector3.Zero;
36 public Vector3 Scale = Vector3.Zero; 41 public Vector3 Scale = Vector3.Zero;
37 public Quaternion Rotation = Quaternion.Identity; 42 public Quaternion Rotation = Quaternion.Identity;
38 43
44 /// <summary>
45 /// Constructor.
46 /// </summary>
47 /// <param name="part"></param>
39 public UndoState(SceneObjectPart part) 48 public UndoState(SceneObjectPart part)
40 { 49 {
41 if (part != null) 50 if (part != null)
42 { 51 {
43 if (part.ParentID == 0) 52 if (part.ParentID == 0)
44 { 53 {
54// m_log.DebugFormat(
55// "[UNDO STATE]: Storing undo position {0} for root part", part.ParentGroup.AbsolutePosition);
45 Position = part.ParentGroup.AbsolutePosition; 56 Position = part.ParentGroup.AbsolutePosition;
57
58// m_log.DebugFormat(
59// "[UNDO STATE]: Storing undo rotation {0} for root part", part.RotationOffset);
46 Rotation = part.RotationOffset; 60 Rotation = part.RotationOffset;
61
62// m_log.DebugFormat(
63// "[UNDO STATE]: Storing undo scale {0} for root part", part.Shape.Scale);
47 Scale = part.Shape.Scale; 64 Scale = part.Shape.Scale;
48 } 65 }
49 else 66 else
50 { 67 {
68// m_log.DebugFormat(
69// "[UNDO STATE]: Storing undo position {0} for child part", part.OffsetPosition);
51 Position = part.OffsetPosition; 70 Position = part.OffsetPosition;
71
72// m_log.DebugFormat(
73// "[UNDO STATE]: Storing undo rotation {0} for child part", part.RotationOffset);
52 Rotation = part.RotationOffset; 74 Rotation = part.RotationOffset;
75
76// m_log.DebugFormat(
77// "[UNDO STATE]: Storing undo scale {0} for child part", part.Shape.Scale);
53 Scale = part.Shape.Scale; 78 Scale = part.Shape.Scale;
54 } 79 }
55 } 80 }
56 } 81 }
57 82
83 /// <summary>
84 /// Compare the relevant state in the given part to this state.
85 /// </summary>
86 /// <param name="part"></param>
87 /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns>
58 public bool Compare(SceneObjectPart part) 88 public bool Compare(SceneObjectPart part)
59 { 89 {
60 if (part != null) 90 if (part != null)
61 { 91 {
62 if (part.ParentID == 0) 92 if (part.ParentID == 0)
63 { 93 {
64 if (Position == part.ParentGroup.AbsolutePosition && Rotation == part.ParentGroup.Rotation) 94 if (Position == part.ParentGroup.AbsolutePosition
95 && Rotation == part.RotationOffset
96 && Scale == part.Shape.Scale)
65 return true; 97 return true;
66 else 98 else
67 return false; 99 return false;
68 } 100 }
69 else 101 else
70 { 102 {
71 if (Position == part.OffsetPosition && Rotation == part.RotationOffset && Scale == part.Shape.Scale) 103 if (Position == part.OffsetPosition
104 && Rotation == part.RotationOffset
105 && Scale == part.Shape.Scale)
72 return true; 106 return true;
73 else 107 else
74 return false; 108 return false;
75
76 } 109 }
77 } 110 }
111
78 return false; 112 return false;
79 } 113 }
80 114
@@ -87,24 +121,64 @@ namespace OpenSim.Region.Framework.Scenes
87 if (part.ParentID == 0) 121 if (part.ParentID == 0)
88 { 122 {
89 if (Position != Vector3.Zero) 123 if (Position != Vector3.Zero)
124 {
125// m_log.DebugFormat(
126// "[UNDO STATE]: Undoing position {0} to {1} for root part {2} {3}",
127// part.ParentGroup.AbsolutePosition, Position, part.Name, part.LocalId);
128
90 part.ParentGroup.AbsolutePosition = Position; 129 part.ParentGroup.AbsolutePosition = Position;
130 }
131
132// m_log.DebugFormat(
133// "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}",
134// part.RotationOffset, Rotation, part.Name, part.LocalId);
135
91 part.RotationOffset = Rotation; 136 part.RotationOffset = Rotation;
137
92 if (Scale != Vector3.Zero) 138 if (Scale != Vector3.Zero)
139 {
140// m_log.DebugFormat(
141// "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}",
142// part.Shape.Scale, Scale, part.Name, part.LocalId);
143
93 part.Resize(Scale); 144 part.Resize(Scale);
145 }
146
94 part.ParentGroup.ScheduleGroupForTerseUpdate(); 147 part.ParentGroup.ScheduleGroupForTerseUpdate();
95 } 148 }
96 else 149 else
97 { 150 {
98 if (Position != Vector3.Zero) 151 if (Position != Vector3.Zero)
152 {
153// m_log.DebugFormat(
154// "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}",
155// part.OffsetPosition, Position, part.Name, part.LocalId);
156
99 part.OffsetPosition = Position; 157 part.OffsetPosition = Position;
158 }
159
160// m_log.DebugFormat(
161// "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}",
162// part.RotationOffset, Rotation, part.Name, part.LocalId);
163
100 part.UpdateRotation(Rotation); 164 part.UpdateRotation(Rotation);
165
101 if (Scale != Vector3.Zero) 166 if (Scale != Vector3.Zero)
102 part.Resize(Scale); part.ScheduleTerseUpdate(); 167 {
168// m_log.DebugFormat(
169// "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}",
170// part.Shape.Scale, Scale, part.Name, part.LocalId);
171
172 part.Resize(Scale);
173 }
174
175 part.ScheduleTerseUpdate();
103 } 176 }
104 part.Undoing = false;
105 177
178 part.Undoing = false;
106 } 179 }
107 } 180 }
181
108 public void PlayfwdState(SceneObjectPart part) 182 public void PlayfwdState(SceneObjectPart part)
109 { 183 {
110 if (part != null) 184 if (part != null)
@@ -115,27 +189,34 @@ namespace OpenSim.Region.Framework.Scenes
115 { 189 {
116 if (Position != Vector3.Zero) 190 if (Position != Vector3.Zero)
117 part.ParentGroup.AbsolutePosition = Position; 191 part.ParentGroup.AbsolutePosition = Position;
192
118 if (Rotation != Quaternion.Identity) 193 if (Rotation != Quaternion.Identity)
119 part.UpdateRotation(Rotation); 194 part.UpdateRotation(Rotation);
195
120 if (Scale != Vector3.Zero) 196 if (Scale != Vector3.Zero)
121 part.Resize(Scale); 197 part.Resize(Scale);
198
122 part.ParentGroup.ScheduleGroupForTerseUpdate(); 199 part.ParentGroup.ScheduleGroupForTerseUpdate();
123 } 200 }
124 else 201 else
125 { 202 {
126 if (Position != Vector3.Zero) 203 if (Position != Vector3.Zero)
127 part.OffsetPosition = Position; 204 part.OffsetPosition = Position;
205
128 if (Rotation != Quaternion.Identity) 206 if (Rotation != Quaternion.Identity)
129 part.UpdateRotation(Rotation); 207 part.UpdateRotation(Rotation);
208
130 if (Scale != Vector3.Zero) 209 if (Scale != Vector3.Zero)
131 part.Resize(Scale); 210 part.Resize(Scale);
211
132 part.ScheduleTerseUpdate(); 212 part.ScheduleTerseUpdate();
133 } 213 }
134 part.Undoing = false;
135 214
215 part.Undoing = false;
136 } 216 }
137 } 217 }
138 } 218 }
219
139 public class LandUndoState 220 public class LandUndoState
140 { 221 {
141 public ITerrainModule m_terrainModule; 222 public ITerrainModule m_terrainModule;