diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 64 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/UndoState.cs | 219 |
2 files changed, 103 insertions, 180 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 92f2d54..bb554e1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -3498,9 +3498,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3498 | ScheduleGroupForFullUpdate(); | 3498 | ScheduleGroupForFullUpdate(); |
3499 | } | 3499 | } |
3500 | 3500 | ||
3501 | private enum updatetype :int | ||
3502 | { | ||
3503 | none = 0, | ||
3504 | partterse = 1, | ||
3505 | partfull = 2, | ||
3506 | groupterse = 3, | ||
3507 | groupfull = 4 | ||
3508 | } | ||
3509 | |||
3501 | public void doChangeObject(SceneObjectPart part, ObjectChangeData data) | 3510 | public void doChangeObject(SceneObjectPart part, ObjectChangeData data) |
3502 | { | 3511 | { |
3503 | // TODO this still as excessive ScheduleGroupForTerseUpdate()s | 3512 | // TODO this still as excessive *.Schedule*Update()s |
3504 | 3513 | ||
3505 | if (part != null && part.ParentGroup != null) | 3514 | if (part != null && part.ParentGroup != null) |
3506 | { | 3515 | { |
@@ -3511,7 +3520,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3511 | SceneObjectGroup group = part.ParentGroup; | 3520 | SceneObjectGroup group = part.ParentGroup; |
3512 | PhysicsActor pha = group.RootPart.PhysActor; | 3521 | PhysicsActor pha = group.RootPart.PhysActor; |
3513 | 3522 | ||
3514 | bool needgrpUpdate = false; | 3523 | updatetype updateType = updatetype.none; |
3515 | 3524 | ||
3516 | if (togroup) | 3525 | if (togroup) |
3517 | { | 3526 | { |
@@ -3519,15 +3528,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3519 | if ((what & ObjectChangeWhat.Position) != 0) | 3528 | if ((what & ObjectChangeWhat.Position) != 0) |
3520 | { | 3529 | { |
3521 | group.AbsolutePosition = data.position; | 3530 | group.AbsolutePosition = data.position; |
3522 | needgrpUpdate = true; | 3531 | updateType = updatetype.groupterse; |
3523 | } | 3532 | } |
3524 | if ((what & ObjectChangeWhat.Rotation) != 0) | 3533 | if ((what & ObjectChangeWhat.Rotation) != 0) |
3534 | { | ||
3525 | group.RootPart.UpdateRotation(data.rotation); | 3535 | group.RootPart.UpdateRotation(data.rotation); |
3536 | updateType = updatetype.none; | ||
3537 | } | ||
3526 | if ((what & ObjectChangeWhat.Scale) != 0) | 3538 | if ((what & ObjectChangeWhat.Scale) != 0) |
3527 | { | 3539 | { |
3528 | if (pha != null) | 3540 | if (pha != null) |
3529 | pha.Building = true; | 3541 | pha.Building = true; |
3542 | |||
3530 | group.GroupResize(data.scale); | 3543 | group.GroupResize(data.scale); |
3544 | updateType = updatetype.none; | ||
3545 | |||
3531 | if (pha != null) | 3546 | if (pha != null) |
3532 | pha.Building = false; | 3547 | pha.Building = false; |
3533 | } | 3548 | } |
@@ -3538,8 +3553,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3538 | if (pha != null) | 3553 | if (pha != null) |
3539 | pha.Building = true; | 3554 | pha.Building = true; |
3540 | 3555 | ||
3541 | // must deal with root part specially for position and rotation | 3556 | // root part is special |
3542 | // so parts offset positions or rotations are fixed | 3557 | // parts offset positions or rotations need to change also |
3543 | 3558 | ||
3544 | if (part == group.RootPart) | 3559 | if (part == group.RootPart) |
3545 | { | 3560 | { |
@@ -3547,30 +3562,53 @@ namespace OpenSim.Region.Framework.Scenes | |||
3547 | group.UpdateRootPosition(data.position); | 3562 | group.UpdateRootPosition(data.position); |
3548 | if ((what & ObjectChangeWhat.Rotation) != 0) | 3563 | if ((what & ObjectChangeWhat.Rotation) != 0) |
3549 | group.UpdateRootRotation(data.rotation); | 3564 | group.UpdateRootRotation(data.rotation); |
3565 | if ((what & ObjectChangeWhat.Scale) != 0) | ||
3566 | part.Resize(data.scale); | ||
3550 | } | 3567 | } |
3551 | else | 3568 | else |
3552 | { | 3569 | { |
3553 | |||
3554 | if ((what & ObjectChangeWhat.Position) != 0) | 3570 | if ((what & ObjectChangeWhat.Position) != 0) |
3555 | { | 3571 | { |
3556 | part.OffsetPosition = data.position; | 3572 | part.OffsetPosition = data.position; |
3557 | needgrpUpdate = true; | 3573 | updateType = updatetype.partterse; |
3558 | } | 3574 | } |
3559 | if ((what & ObjectChangeWhat.Rotation) != 0) | 3575 | if ((what & ObjectChangeWhat.Rotation) != 0) |
3576 | { | ||
3560 | part.UpdateRotation(data.rotation); | 3577 | part.UpdateRotation(data.rotation); |
3578 | updateType = updatetype.none; | ||
3579 | } | ||
3580 | if ((what & ObjectChangeWhat.Scale) != 0) | ||
3581 | { | ||
3582 | part.Resize(data.scale); | ||
3583 | updateType = updatetype.none; | ||
3584 | } | ||
3561 | } | 3585 | } |
3562 | 3586 | ||
3563 | if ((what & ObjectChangeWhat.Scale) != 0) | ||
3564 | part.Resize(data.scale); | ||
3565 | |||
3566 | if (pha != null) | 3587 | if (pha != null) |
3567 | pha.Building = false; | 3588 | pha.Building = false; |
3568 | } | 3589 | } |
3569 | 3590 | ||
3570 | if (needgrpUpdate) | 3591 | if (updateType != updatetype.none) |
3571 | { | 3592 | { |
3572 | HasGroupChanged = true; | 3593 | group.HasGroupChanged = true; |
3573 | ScheduleGroupForTerseUpdate(); | 3594 | |
3595 | switch (updateType) | ||
3596 | { | ||
3597 | case updatetype.partterse: | ||
3598 | part.ScheduleTerseUpdate(); | ||
3599 | break; | ||
3600 | case updatetype.partfull: | ||
3601 | part.ScheduleFullUpdate(); | ||
3602 | break; | ||
3603 | case updatetype.groupterse: | ||
3604 | group.ScheduleGroupForTerseUpdate(); | ||
3605 | break; | ||
3606 | case updatetype.groupfull: | ||
3607 | group.ScheduleGroupForFullUpdate(); | ||
3608 | break; | ||
3609 | default: | ||
3610 | break; | ||
3611 | } | ||
3574 | } | 3612 | } |
3575 | } | 3613 | } |
3576 | } | 3614 | } |
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; | |||
31 | using log4net; | 31 | using log4net; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Region.Framework.Interfaces; | 33 | using OpenSim.Region.Framework.Interfaces; |
34 | using System; | ||
35 | 34 | ||
36 | namespace OpenSim.Region.Framework.Scenes | 35 | namespace 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 |