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