aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/UndoState.cs
diff options
context:
space:
mode:
authorTom2011-09-04 07:06:36 -0700
committerTom2011-09-04 07:06:36 -0700
commit66dec3b8742eff04fbbcc6e3249fe4ba87986500 (patch)
tree76cc708a821d35fac5cdbbce2de304b47064e732 /OpenSim/Region/Framework/Scenes/UndoState.cs
parentGuard another nullref (diff)
parentFixed BulletSim config files for Linux *.so libraries. (diff)
downloadopensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.zip
opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.gz
opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.bz2
opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.xz
Resolve merge commits, stage 1
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/UndoState.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/UndoState.cs245
1 files changed, 158 insertions, 87 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index f71b507..81f41db 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;
30using System; 33using System;
@@ -47,6 +50,8 @@ namespace OpenSim.Region.Framework.Scenes
47 50
48 public class UndoState 51 public class UndoState
49 { 52 {
53// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54
50 public Vector3 Position = Vector3.Zero; 55 public Vector3 Position = Vector3.Zero;
51 public Vector3 Scale = Vector3.Zero; 56 public Vector3 Scale = Vector3.Zero;
52 public Quaternion Rotation = Quaternion.Identity; 57 public Quaternion Rotation = Quaternion.Identity;
@@ -56,13 +61,23 @@ namespace OpenSim.Region.Framework.Scenes
56 public DateTime LastUpdated = DateTime.Now; 61 public DateTime LastUpdated = DateTime.Now;
57 public UndoType Type; 62 public UndoType Type;
58 63
59 public UndoState(SceneObjectPart part, UndoType type) 64 /// <summary>
65 /// Is this undo state for an entire group?
66 /// </summary>
67 public bool ForGroup;
68
69 /// <summary>
70 /// Constructor.
71 /// </summary>
72 /// <param name="part"></param>
73 /// <param name="forGroup">True if the undo is for an entire group</param>
74 public UndoState(SceneObjectPart part, bool forGroup)
60 { 75 {
61 Type = type; 76 if (part.ParentID == 0)
62 if (part != null)
63 { 77 {
64 if (part.ParentID == 0) 78 ForGroup = forGroup;
65 { 79
80// if (ForGroup)
66 GroupScale = part.ParentGroup.RootPart.Shape.Scale; 81 GroupScale = part.ParentGroup.RootPart.Shape.Scale;
67 82
68 //FUBAR WARNING: Do NOT get the group's absoluteposition here 83 //FUBAR WARNING: Do NOT get the group's absoluteposition here
@@ -70,23 +85,35 @@ namespace OpenSim.Region.Framework.Scenes
70 GroupPosition = part.ParentGroup.RootPart.AbsolutePosition; 85 GroupPosition = part.ParentGroup.RootPart.AbsolutePosition;
71 GroupRotation = part.ParentGroup.GroupRotation; 86 GroupRotation = part.ParentGroup.GroupRotation;
72 Position = part.ParentGroup.RootPart.AbsolutePosition; 87 Position = part.ParentGroup.RootPart.AbsolutePosition;
73 Rotation = part.RotationOffset; 88// else
74 Scale = part.Shape.Scale; 89// Position = part.OffsetPosition;
75 LastUpdated = DateTime.Now;
76 }
77 else
78 {
79 GroupScale = part.Shape.Scale;
80 90
81 //FUBAR WARNING: Do NOT get the group's absoluteposition here 91// m_log.DebugFormat(
82 //or you'll experience a loop and/or a stack issue 92// "[UNDO STATE]: Storing undo position {0} for root part", Position);
83 GroupPosition = part.ParentGroup.RootPart.AbsolutePosition; 93
84 GroupRotation = part.ParentGroup.Rotation; 94 Rotation = part.RotationOffset;
85 Position = part.OffsetPosition; 95
86 Rotation = part.RotationOffset; 96// m_log.DebugFormat(
87 Scale = part.Shape.Scale; 97// "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation);
88 LastUpdated = DateTime.Now; 98
89 } 99 Scale = part.Shape.Scale;
100
101// m_log.DebugFormat(
102// "[UNDO STATE]: Storing undo scale {0} for root part", Scale);
103 }
104 else
105 {
106 Position = part.OffsetPosition;
107// m_log.DebugFormat(
108// "[UNDO STATE]: Storing undo position {0} for child part", Position);
109
110 Rotation = part.RotationOffset;
111// m_log.DebugFormat(
112// "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation);
113
114 Scale = part.Shape.Scale;
115// m_log.DebugFormat(
116// "[UNDO STATE]: Storing undo scale {0} for child part", Scale);
90 } 117 }
91 } 118 }
92 public void Merge(UndoState last) 119 public void Merge(UndoState last)
@@ -132,95 +159,143 @@ namespace OpenSim.Region.Framework.Scenes
132 return false; 159 return false;
133 } 160 }
134 } 161 }
162 /// <summary>
163 /// Compare the relevant state in the given part to this state.
164 /// </summary>
165 /// <param name="part"></param>
166 /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns>
135 public bool Compare(SceneObjectPart part) 167 public bool Compare(SceneObjectPart part)
136 { 168 {
137 if (part != null) 169 if (part != null)
138 { 170 {
139 if (part.ParentID == 0) 171 if (part.ParentID == 0)
140 { 172 return
141 if (Position == part.ParentGroup.RootPart.AbsolutePosition && Rotation == part.ParentGroup.Rotation && GroupPosition == part.ParentGroup.RootPart.AbsolutePosition && part.ParentGroup.Rotation == GroupRotation && part.Shape.Scale == GroupScale) 173 Position == part.ParentGroup.AbsolutePosition
142 return true; 174 && Rotation == part.RotationOffset
143 else 175 && Scale == part.Shape.Scale;
144 return false;
145 }
146 else 176 else
147 { 177 return
148 if (Position == part.OffsetPosition && Rotation == part.RotationOffset && Scale == part.Shape.Scale && GroupPosition == part.ParentGroup.RootPart.AbsolutePosition && part.ParentGroup.Rotation == GroupRotation && part.Shape.Scale == GroupScale) 178 Position == part.OffsetPosition
149 return true; 179 && Rotation == part.RotationOffset
150 else 180 && Scale == part.Shape.Scale;
151 return false;
152
153 }
154 } 181 }
182
155 return false; 183 return false;
156 } 184 }
157 185
158 private void RestoreState(SceneObjectPart part) 186 private void RestoreState(SceneObjectPart part)
159 { 187 {
160 bool GroupChange = false; 188 part.Undoing = true;
161 if ((Type & UndoType.STATE_GROUP_POSITION) != 0
162 || (Type & UndoType.STATE_GROUP_ROTATION) != 0
163 || (Type & UndoType.STATE_GROUP_SCALE) != 0)
164 {
165 GroupChange = true;
166 }
167 189
168 if (part != null) 190 if (part.ParentID == 0)
169 { 191 {
170 part.Undoing = true; 192// m_log.DebugFormat(
193// "[UNDO STATE]: Undoing position to {0} for root part {1} {2}",
194// Position, part.Name, part.LocalId);
171 195
172 if (part.ParentID == 0 && GroupChange == false) 196 if (Position != Vector3.Zero)
173 { 197 {
174 if (Position != Vector3.Zero) 198 if (ForGroup)
175 199 part.ParentGroup.AbsolutePosition = Position;
176 part.ParentGroup.UpdateSinglePosition(Position, part.LocalId); 200 else
177 part.ParentGroup.UpdateSingleRotation(Rotation, part.LocalId); 201 part.ParentGroup.UpdateRootPosition(Position);
178 if (Scale != Vector3.Zero)
179 part.Resize(Scale);
180 part.ParentGroup.ScheduleGroupForTerseUpdate();
181 } 202 }
203
204// m_log.DebugFormat(
205// "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}",
206// part.RotationOffset, Rotation, part.Name, part.LocalId);
207
208 if (ForGroup)
209 part.UpdateRotation(Rotation);
182 else 210 else
211 part.ParentGroup.UpdateRootRotation(Rotation);
212
213 if (Scale != Vector3.Zero)
183 { 214 {
184 if (GroupChange) 215// m_log.DebugFormat(
185 { 216// "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}",
186 part.ParentGroup.RootPart.Undoing = true; 217// part.Shape.Scale, Scale, part.Name, part.LocalId);
187 if (GroupPosition != Vector3.Zero) 218
188 { 219 if (ForGroup)
189 //Calculate the scale... 220 part.ParentGroup.GroupResize(Scale);
190 Vector3 gs = part.Shape.Scale;
191 float scale = GroupScale.Z / gs.Z;
192
193 //Scale first since it can affect our position
194 part.ParentGroup.GroupResize(gs * scale, part.LocalId);
195 part.ParentGroup.AbsolutePosition = GroupPosition;
196 part.ParentGroup.UpdateGroupRotationR(GroupRotation);
197
198 }
199 part.ParentGroup.RootPart.Undoing = false;
200 }
201 else 221 else
202 { 222 part.Resize(Scale);
203 if (Position != Vector3.Zero) //We can use this for all the updates since all are set
204 {
205 part.OffsetPosition = Position;
206 part.UpdateRotation(Rotation);
207 part.Resize(Scale); part.ScheduleTerseUpdate();
208 }
209 }
210 } 223 }
211 part.Undoing = false;
212 224
225 part.ParentGroup.ScheduleGroupForTerseUpdate();
213 } 226 }
227 else
228 {
229 if (Position != Vector3.Zero)
230 {
231// m_log.DebugFormat(
232// "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}",
233// part.OffsetPosition, Position, part.Name, part.LocalId);
234
235 part.OffsetPosition = Position;
236 }
237
238// m_log.DebugFormat(
239// "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}",
240// part.RotationOffset, Rotation, part.Name, part.LocalId);
241
242 part.UpdateRotation(Rotation);
243
244 if (Scale != Vector3.Zero)
245 {
246// m_log.DebugFormat(
247// "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}",
248// part.Shape.Scale, Scale, part.Name, part.LocalId);
249
250 part.Resize(Scale);
251 }
252
253 part.ScheduleTerseUpdate();
254 }
255
256 part.Undoing = false;
214 } 257 }
215 public void PlaybackState(SceneObjectPart part) 258
216 {
217 RestoreState(part);
218 }
219 public void PlayfwdState(SceneObjectPart part) 259 public void PlayfwdState(SceneObjectPart part)
220 { 260 {
221 RestoreState(part); 261 part.Undoing = true;
262
263 if (part.ParentID == 0)
264 {
265 if (Position != Vector3.Zero)
266 part.ParentGroup.AbsolutePosition = Position;
267
268 if (Rotation != Quaternion.Identity)
269 part.UpdateRotation(Rotation);
270
271 if (Scale != Vector3.Zero)
272 {
273 if (ForGroup)
274 part.ParentGroup.GroupResize(Scale);
275 else
276 part.Resize(Scale);
277 }
278
279 part.ParentGroup.ScheduleGroupForTerseUpdate();
280 }
281 else
282 {
283 if (Position != Vector3.Zero)
284 part.OffsetPosition = Position;
285
286 if (Rotation != Quaternion.Identity)
287 part.UpdateRotation(Rotation);
288
289 if (Scale != Vector3.Zero)
290 part.Resize(Scale);
291
292 part.ScheduleTerseUpdate();
293 }
294
295 part.Undoing = false;
222 } 296 }
223 } 297 }
298
224 public class LandUndoState 299 public class LandUndoState
225 { 300 {
226 public ITerrainModule m_terrainModule; 301 public ITerrainModule m_terrainModule;
@@ -234,10 +309,7 @@ namespace OpenSim.Region.Framework.Scenes
234 309
235 public bool Compare(ITerrainChannel terrainChannel) 310 public bool Compare(ITerrainChannel terrainChannel)
236 { 311 {
237 if (m_terrainChannel != terrainChannel) 312 return m_terrainChannel == terrainChannel;
238 return false;
239 else
240 return false;
241 } 313 }
242 314
243 public void PlaybackState() 315 public void PlaybackState()
@@ -246,4 +318,3 @@ namespace OpenSim.Region.Framework.Scenes
246 } 318 }
247 } 319 }
248} 320}
249