diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/UndoState.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/UndoState.cs | 146 |
1 files changed, 42 insertions, 104 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 860172c..38474de 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs | |||
@@ -30,12 +30,27 @@ 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); |
39 | 54 | ||
40 | public Vector3 Position = Vector3.Zero; | 55 | public Vector3 Position = Vector3.Zero; |
41 | public Vector3 Scale = Vector3.Zero; | 56 | public Vector3 Scale = Vector3.Zero; |
@@ -51,43 +66,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
51 | /// </summary> | 66 | /// </summary> |
52 | /// <param name="part"></param> | 67 | /// <param name="part"></param> |
53 | /// <param name="forGroup">True if the undo is for an entire group</param> | 68 | /// <param name="forGroup">True if the undo is for an entire group</param> |
69 | /// only for root parts ???? | ||
54 | public UndoState(SceneObjectPart part, bool forGroup) | 70 | public UndoState(SceneObjectPart part, bool forGroup) |
55 | { | 71 | { |
56 | if (part.ParentID == 0) | 72 | if (part.ParentID == 0) |
57 | { | 73 | { |
58 | ForGroup = forGroup; | 74 | ForGroup = forGroup; |
59 | 75 | Position = part.ParentGroup.AbsolutePosition; | |
60 | // if (ForGroup) | ||
61 | Position = part.ParentGroup.AbsolutePosition; | ||
62 | // else | ||
63 | // Position = part.OffsetPosition; | ||
64 | |||
65 | // m_log.DebugFormat( | ||
66 | // "[UNDO STATE]: Storing undo position {0} for root part", Position); | ||
67 | |||
68 | Rotation = part.RotationOffset; | 76 | Rotation = part.RotationOffset; |
69 | |||
70 | // m_log.DebugFormat( | ||
71 | // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); | ||
72 | |||
73 | Scale = part.Shape.Scale; | 77 | Scale = part.Shape.Scale; |
74 | |||
75 | // m_log.DebugFormat( | ||
76 | // "[UNDO STATE]: Storing undo scale {0} for root part", Scale); | ||
77 | } | 78 | } |
78 | else | 79 | else |
79 | { | 80 | { |
81 | ForGroup = false; // only root parts can undo grp | ||
80 | Position = part.OffsetPosition; | 82 | Position = part.OffsetPosition; |
81 | // m_log.DebugFormat( | ||
82 | // "[UNDO STATE]: Storing undo position {0} for child part", Position); | ||
83 | |||
84 | Rotation = part.RotationOffset; | 83 | Rotation = part.RotationOffset; |
85 | // m_log.DebugFormat( | ||
86 | // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); | ||
87 | |||
88 | Scale = part.Shape.Scale; | 84 | Scale = part.Shape.Scale; |
89 | // m_log.DebugFormat( | ||
90 | // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); | ||
91 | } | 85 | } |
92 | } | 86 | } |
93 | 87 | ||
@@ -96,35 +90,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
96 | /// </summary> | 90 | /// </summary> |
97 | /// <param name="part"></param> | 91 | /// <param name="part"></param> |
98 | /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns> | 92 | /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns> |
99 | public bool Compare(SceneObjectPart part) | 93 | public bool Compare(SceneObjectPart part, bool forgrp) |
100 | { | 94 | { |
95 | if (ForGroup != forgrp) // if diferent targets, then they are diferent | ||
96 | return false; | ||
97 | |||
101 | if (part != null) | 98 | if (part != null) |
102 | { | 99 | { |
103 | if (part.ParentID == 0) | 100 | if (part.ParentID == 0) |
104 | return | 101 | { |
105 | Position == part.ParentGroup.AbsolutePosition | 102 | // root part |
106 | && Rotation == part.RotationOffset | 103 | // grp position is same as part |
107 | && Scale == part.Shape.Scale; | 104 | if (Position != part.ParentGroup.AbsolutePosition) |
105 | return false; | ||
106 | if (Rotation != part.RotationOffset) | ||
107 | return false; | ||
108 | return Scale == part.Shape.Scale; | ||
109 | } | ||
108 | else | 110 | else |
109 | return | 111 | { |
110 | Position == part.OffsetPosition | 112 | return (Position == part.OffsetPosition |
111 | && Rotation == part.RotationOffset | 113 | && Rotation == part.RotationOffset |
112 | && Scale == part.Shape.Scale; | 114 | && Scale == part.Shape.Scale); |
115 | } | ||
113 | } | 116 | } |
114 | 117 | ||
115 | return false; | 118 | return false; |
116 | } | 119 | } |
117 | 120 | ||
118 | public void PlaybackState(SceneObjectPart part) | 121 | public void PlayState(SceneObjectPart part) |
119 | { | 122 | { |
120 | part.Undoing = true; | 123 | part.Undoing = true; |
121 | 124 | ||
122 | if (part.ParentID == 0) | 125 | if (part.ParentID == 0) |
123 | { | 126 | { |
124 | // m_log.DebugFormat( | ||
125 | // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", | ||
126 | // Position, part.Name, part.LocalId); | ||
127 | |||
128 | if (Position != Vector3.Zero) | 127 | if (Position != Vector3.Zero) |
129 | { | 128 | { |
130 | if (ForGroup) | 129 | if (ForGroup) |
@@ -133,10 +132,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
133 | part.ParentGroup.UpdateRootPosition(Position); | 132 | part.ParentGroup.UpdateRootPosition(Position); |
134 | } | 133 | } |
135 | 134 | ||
136 | // m_log.DebugFormat( | ||
137 | // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", | ||
138 | // part.RotationOffset, Rotation, part.Name, part.LocalId); | ||
139 | |||
140 | if (ForGroup) | 135 | if (ForGroup) |
141 | part.UpdateRotation(Rotation); | 136 | part.UpdateRotation(Rotation); |
142 | else | 137 | else |
@@ -144,86 +139,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
144 | 139 | ||
145 | if (Scale != Vector3.Zero) | 140 | if (Scale != Vector3.Zero) |
146 | { | 141 | { |
147 | // m_log.DebugFormat( | ||
148 | // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", | ||
149 | // part.Shape.Scale, Scale, part.Name, part.LocalId); | ||
150 | |||
151 | if (ForGroup) | 142 | if (ForGroup) |
152 | part.ParentGroup.GroupResize(Scale); | 143 | part.ParentGroup.GroupResize(Scale); |
153 | else | 144 | else |
154 | part.Resize(Scale); | 145 | part.Resize(Scale); |
155 | } | 146 | } |
156 | |||
157 | part.ParentGroup.ScheduleGroupForTerseUpdate(); | 147 | part.ParentGroup.ScheduleGroupForTerseUpdate(); |
158 | } | 148 | } |
159 | else | 149 | else |
160 | { | 150 | { |
161 | // Note: Updating these properties on sop automatically schedules an update if needed | 151 | if (ForGroup) // trap for group since seems parts can't do it |
162 | if (Position != Vector3.Zero) | 152 | return; |
163 | { | ||
164 | // m_log.DebugFormat( | ||
165 | // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", | ||
166 | // part.OffsetPosition, Position, part.Name, part.LocalId); | ||
167 | |||
168 | part.OffsetPosition = Position; | ||
169 | } | ||
170 | |||
171 | // m_log.DebugFormat( | ||
172 | // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", | ||
173 | // part.RotationOffset, Rotation, part.Name, part.LocalId); | ||
174 | 153 | ||
154 | // Note: Updating these properties on sop automatically schedules an update if needed | ||
155 | part.OffsetPosition = Position; | ||
175 | part.UpdateRotation(Rotation); | 156 | part.UpdateRotation(Rotation); |
176 | |||
177 | if (Scale != Vector3.Zero) | 157 | if (Scale != Vector3.Zero) |
178 | { | 158 | { |
179 | // m_log.DebugFormat( | ||
180 | // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", | ||
181 | // part.Shape.Scale, Scale, part.Name, part.LocalId); | ||
182 | |||
183 | part.Resize(Scale); | 159 | part.Resize(Scale); |
184 | } | 160 | } |
185 | } | 161 | } |
186 | 162 | ||
187 | part.Undoing = false; | 163 | part.Undoing = false; |
188 | } | 164 | } |
189 | |||
190 | public void PlayfwdState(SceneObjectPart part) | ||
191 | { | ||
192 | part.Undoing = true; | ||
193 | |||
194 | if (part.ParentID == 0) | ||
195 | { | ||
196 | if (Position != Vector3.Zero) | ||
197 | part.ParentGroup.AbsolutePosition = Position; | ||
198 | |||
199 | if (Rotation != Quaternion.Identity) | ||
200 | part.UpdateRotation(Rotation); | ||
201 | |||
202 | if (Scale != Vector3.Zero) | ||
203 | { | ||
204 | if (ForGroup) | ||
205 | part.ParentGroup.GroupResize(Scale); | ||
206 | else | ||
207 | part.Resize(Scale); | ||
208 | } | ||
209 | |||
210 | part.ParentGroup.ScheduleGroupForTerseUpdate(); | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | // Note: Updating these properties on sop automatically schedules an update if needed | ||
215 | if (Position != Vector3.Zero) | ||
216 | part.OffsetPosition = Position; | ||
217 | |||
218 | if (Rotation != Quaternion.Identity) | ||
219 | part.UpdateRotation(Rotation); | ||
220 | |||
221 | if (Scale != Vector3.Zero) | ||
222 | part.Resize(Scale); | ||
223 | } | ||
224 | |||
225 | part.Undoing = false; | ||
226 | } | ||
227 | } | 165 | } |
228 | 166 | ||
229 | public class LandUndoState | 167 | public class LandUndoState |
@@ -247,4 +185,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
247 | m_terrainModule.UndoTerrain(m_terrainChannel); | 185 | m_terrainModule.UndoTerrain(m_terrainChannel); |
248 | } | 186 | } |
249 | } | 187 | } |
250 | } \ No newline at end of file | 188 | } |