aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorUbitUmarov2012-03-11 03:14:15 +0000
committerUbitUmarov2012-03-11 03:14:15 +0000
commit53bda83cc292786e5ee7e1914bbc0c959f065b75 (patch)
tree7b029ca4ffcd282837fef03ddd2bbd46be6483ae /OpenSim
parentcoments change.. (diff)
downloadopensim-SC-53bda83cc292786e5ee7e1914bbc0c959f065b75.zip
opensim-SC-53bda83cc292786e5ee7e1914bbc0c959f065b75.tar.gz
opensim-SC-53bda83cc292786e5ee7e1914bbc0c959f065b75.tar.bz2
opensim-SC-53bda83cc292786e5ee7e1914bbc0c959f065b75.tar.xz
cleanup + comments
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/UndoState.cs219
1 files changed, 52 insertions, 167 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 668b53b..fd90714 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -31,170 +31,9 @@ using System.Collections.Generic;
31using log4net; 31using log4net;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using System;
35 34
36namespace OpenSim.Region.Framework.Scenes 35namespace OpenSim.Region.Framework.Scenes
37{ 36{
38
39/*
40 [Flags]
41 public enum UndoType
42 {
43 STATE_PRIM_POSITION = 1,
44 STATE_PRIM_ROTATION = 2,
45 STATE_PRIM_SCALE = 4,
46 STATE_PRIM_ALL = 7,
47 STATE_GROUP_POSITION = 8,
48 STATE_GROUP_ROTATION = 16,
49 STATE_GROUP_SCALE = 32,
50 STATE_GROUP_ALL = 56,
51 STATE_ALL = 63
52 }
53
54
55 public class UndoState
56 {
57 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58
59 public Vector3 Position = Vector3.Zero;
60 public Vector3 Scale = Vector3.Zero;
61 public Quaternion Rotation = Quaternion.Identity;
62
63 /// <summary>
64 /// Is this undo state for an entire group?
65 /// </summary>
66 public bool ForGroup;
67
68 /// <summary>
69 /// Constructor.
70 /// </summary>
71 /// <param name="part"></param>
72 /// <param name="forGroup">True if the undo is for an entire group</param>
73 /// only for root parts ????
74 public UndoState(SceneObjectPart part, bool forGroup)
75 {
76 if (part.ParentID == 0)
77 {
78 ForGroup = forGroup;
79 Position = part.ParentGroup.AbsolutePosition;
80 Rotation = part.RotationOffset;
81 Scale = part.Shape.Scale;
82 }
83 else
84 {
85 ForGroup = false; // only root parts can undo grp
86 Position = part.OffsetPosition;
87 Rotation = part.RotationOffset;
88 Scale = part.Shape.Scale;
89 }
90 }
91
92 /// <summary>
93 /// Compare the relevant state in the given part to this state.
94 /// </summary>
95 /// <param name="part"></param>
96 /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns>
97 public bool Compare(SceneObjectPart part, bool forgrp)
98 {
99 if (ForGroup != forgrp) // if diferent targets, then they are diferent
100 return false;
101
102 if (part != null)
103 {
104 if (part.ParentID == 0)
105 {
106 // root part
107 // grp position is same as part
108 if (Position != part.ParentGroup.AbsolutePosition)
109 return false;
110 if (Rotation != part.RotationOffset)
111 return false;
112 return Scale == part.Shape.Scale;
113 }
114 else
115 {
116 return (Position == part.OffsetPosition
117 && Rotation == part.RotationOffset
118 && Scale == part.Shape.Scale);
119 }
120 }
121
122 return false;
123 }
124
125 public void PlayState(SceneObjectPart part)
126 {
127 part.Undoing = true;
128 bool physbuilding = false;
129
130 if (part.ParentID == 0)
131 {
132 if (!ForGroup && part.PhysActor != null)
133 {
134 part.PhysActor.Building = true;
135 physbuilding = true;
136 }
137
138 if (Position != Vector3.Zero)
139 {
140 if (ForGroup)
141 part.ParentGroup.AbsolutePosition = Position;
142 else
143 part.ParentGroup.UpdateRootPosition(Position);
144 }
145
146 if (ForGroup)
147 part.UpdateRotation(Rotation);
148 else
149 part.ParentGroup.UpdateRootRotation(Rotation);
150
151 if (Scale != Vector3.Zero)
152 {
153 if (!physbuilding && part.PhysActor != null)
154 {
155 part.PhysActor.Building = true;
156 physbuilding = true;
157 }
158
159 if (ForGroup)
160 part.ParentGroup.GroupResize(Scale);
161 else
162 part.Resize(Scale);
163 }
164
165 if (physbuilding)
166 part.PhysActor.Building = false;
167
168 part.ParentGroup.ScheduleGroupForTerseUpdate();
169 }
170 else
171 {
172 if (ForGroup) // trap for group since seems parts can't do it
173 return;
174
175 // changing a part invalidates entire object physical rep
176 if (part.ParentGroup != null && part.ParentGroup.RootPart != null && part.ParentGroup.RootPart.PhysActor != null)
177 {
178 part.ParentGroup.RootPart.PhysActor.Building = true;
179 physbuilding = true;
180 }
181
182 // Note: Updating these properties on sop automatically schedules an update if needed
183 part.OffsetPosition = Position;
184 part.UpdateRotation(Rotation);
185 if (Scale != Vector3.Zero)
186 {
187 part.Resize(Scale);
188 }
189
190 if (physbuilding)
191 part.ParentGroup.RootPart.PhysActor.Building = false;
192 }
193
194 part.Undoing = false;
195 }
196 }
197*/
198 public class UndoState 37 public class UndoState
199 { 38 {
200 const int UNDOEXPIRESECONDS = 300; // undo expire time (nice to have it came from a ini later) 39 const int UNDOEXPIRESECONDS = 300; // undo expire time (nice to have it came from a ini later)
@@ -205,8 +44,8 @@ namespace OpenSim.Region.Framework.Scenes
205 /// Constructor. 44 /// Constructor.
206 /// </summary> 45 /// </summary>
207 /// <param name="part"></param> 46 /// <param name="part"></param>
208 /// <param name="forGroup">True if the undo is for an entire group</param> 47 /// <param name="what">bit field with what is changed</param>
209 /// only for root parts ???? 48 ///
210 public UndoState(SceneObjectPart part, ObjectChangeWhat what) 49 public UndoState(SceneObjectPart part, ObjectChangeWhat what)
211 { 50 {
212 data = new ObjectChangeData(); 51 data = new ObjectChangeData();
@@ -232,6 +71,9 @@ namespace OpenSim.Region.Framework.Scenes
232 data.scale = part.Shape.Scale; 71 data.scale = part.Shape.Scale;
233 } 72 }
234 } 73 }
74 /// <summary>
75 /// check if undo or redo is too old
76 /// </summary>
235 77
236 public bool checkExpire() 78 public bool checkExpire()
237 { 79 {
@@ -241,6 +83,9 @@ namespace OpenSim.Region.Framework.Scenes
241 return false; 83 return false;
242 } 84 }
243 85
86 /// <summary>
87 /// updates undo or redo creation time to now
88 /// </summary>
244 public void updateExpire() 89 public void updateExpire()
245 { 90 {
246 creationtime = DateTime.UtcNow; 91 creationtime = DateTime.UtcNow;
@@ -250,7 +95,8 @@ namespace OpenSim.Region.Framework.Scenes
250 /// Compare the relevant state in the given part to this state. 95 /// Compare the relevant state in the given part to this state.
251 /// </summary> 96 /// </summary>
252 /// <param name="part"></param> 97 /// <param name="part"></param>
253 /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns> 98 /// <returns>true what fiels and related data are equal, False otherwise.</returns>
99 ///
254 public bool Compare(SceneObjectPart part, ObjectChangeWhat what) 100 public bool Compare(SceneObjectPart part, ObjectChangeWhat what)
255 { 101 {
256 if (data.what != what) // if diferent targets, then they are diferent 102 if (data.what != what) // if diferent targets, then they are diferent
@@ -279,6 +125,12 @@ namespace OpenSim.Region.Framework.Scenes
279 return false; 125 return false;
280 } 126 }
281 127
128 /// <summary>
129 /// executes the undo or redo to a part or its group
130 /// </summary>
131 /// <param name="part"></param>
132 ///
133
282 public void PlayState(SceneObjectPart part) 134 public void PlayState(SceneObjectPart part)
283 { 135 {
284 part.Undoing = true; 136 part.Undoing = true;
@@ -298,12 +150,21 @@ namespace OpenSim.Region.Framework.Scenes
298 int size; 150 int size;
299 public LinkedList<UndoState> m_redo = new LinkedList<UndoState>(); 151 public LinkedList<UndoState> m_redo = new LinkedList<UndoState>();
300 public LinkedList<UndoState> m_undo = new LinkedList<UndoState>(); 152 public LinkedList<UndoState> m_undo = new LinkedList<UndoState>();
301 153
154 /// <summary>
155 /// creates a new UndoRedoState with default states memory size
156 /// </summary>
157
302 public UndoRedoState() 158 public UndoRedoState()
303 { 159 {
304 size = 5; 160 size = 5;
305 } 161 }
306 162
163 /// <summary>
164 /// creates a new UndoRedoState with states memory having indicated size
165 /// </summary>
166 /// <param name="size"></param>
167
307 public UndoRedoState(int _size) 168 public UndoRedoState(int _size)
308 { 169 {
309 if (_size < 3) 170 if (_size < 3)
@@ -312,17 +173,31 @@ namespace OpenSim.Region.Framework.Scenes
312 size = _size; 173 size = _size;
313 } 174 }
314 175
176 /// <summary>
177 /// returns number of undo entries in memory
178 /// </summary>
179
315 public int Count 180 public int Count
316 { 181 {
317 get { return m_undo.Count; } 182 get { return m_undo.Count; }
318 } 183 }
319 184
185 /// <summary>
186 /// clears all undo and redo entries
187 /// </summary>
188
320 public void Clear() 189 public void Clear()
321 { 190 {
322 m_undo.Clear(); 191 m_undo.Clear();
323 m_redo.Clear(); 192 m_redo.Clear();
324 } 193 }
325 194
195 /// <summary>
196 /// adds a new state undo to part or its group, with changes indicated by what bits
197 /// </summary>
198 /// <param name="part"></param>
199 /// <param name="what">bit field with what is changed</param>
200
326 public void StoreUndo(SceneObjectPart part, ObjectChangeWhat what) 201 public void StoreUndo(SceneObjectPart part, ObjectChangeWhat what)
327 { 202 {
328 lock (m_undo) 203 lock (m_undo)
@@ -360,6 +235,12 @@ namespace OpenSim.Region.Framework.Scenes
360 } 235 }
361 } 236 }
362 237
238 /// <summary>
239 /// executes last state undo to part or its group
240 /// current state is pushed into redo
241 /// </summary>
242 /// <param name="part"></param>
243
363 public void Undo(SceneObjectPart part) 244 public void Undo(SceneObjectPart part)
364 { 245 {
365 lock (m_undo) 246 lock (m_undo)
@@ -401,6 +282,12 @@ namespace OpenSim.Region.Framework.Scenes
401 } 282 }
402 } 283 }
403 284
285 /// <summary>
286 /// executes last state redo to part or its group
287 /// current state is pushed into undo
288 /// </summary>
289 /// <param name="part"></param>
290
404 public void Redo(SceneObjectPart part) 291 public void Redo(SceneObjectPart part)
405 { 292 {
406 lock (m_undo) 293 lock (m_undo)
@@ -441,8 +328,6 @@ namespace OpenSim.Region.Framework.Scenes
441 } 328 }
442 } 329 }
443 } 330 }
444
445
446 } 331 }
447 332
448 public class LandUndoState 333 public class LandUndoState