diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/UndoState.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/UndoState.cs | 127 |
1 files changed, 37 insertions, 90 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 81f41db..0a30f4b 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs | |||
@@ -50,16 +50,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
50 | 50 | ||
51 | public class UndoState | 51 | public class UndoState |
52 | { | 52 | { |
53 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
54 | 54 | ||
55 | public Vector3 Position = Vector3.Zero; | 55 | public Vector3 Position = Vector3.Zero; |
56 | public Vector3 Scale = Vector3.Zero; | 56 | public Vector3 Scale = Vector3.Zero; |
57 | public Quaternion Rotation = Quaternion.Identity; | 57 | public Quaternion Rotation = Quaternion.Identity; |
58 | public Vector3 GroupPosition = Vector3.Zero; | ||
59 | public Quaternion GroupRotation = Quaternion.Identity; | ||
60 | public Vector3 GroupScale = Vector3.Zero; | ||
61 | public DateTime LastUpdated = DateTime.Now; | ||
62 | public UndoType Type; | ||
63 | 58 | ||
64 | /// <summary> | 59 | /// <summary> |
65 | /// Is this undo state for an entire group? | 60 | /// Is this undo state for an entire group? |
@@ -77,88 +72,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
77 | { | 72 | { |
78 | ForGroup = forGroup; | 73 | ForGroup = forGroup; |
79 | 74 | ||
80 | // if (ForGroup) | 75 | // if (ForGroup) |
81 | GroupScale = part.ParentGroup.RootPart.Shape.Scale; | 76 | Position = part.ParentGroup.AbsolutePosition; |
77 | // else | ||
78 | // Position = part.OffsetPosition; | ||
82 | 79 | ||
83 | //FUBAR WARNING: Do NOT get the group's absoluteposition here | 80 | // m_log.DebugFormat( |
84 | //or you'll experience a loop and/or a stack issue | 81 | // "[UNDO STATE]: Storing undo position {0} for root part", Position); |
85 | GroupPosition = part.ParentGroup.RootPart.AbsolutePosition; | ||
86 | GroupRotation = part.ParentGroup.GroupRotation; | ||
87 | Position = part.ParentGroup.RootPart.AbsolutePosition; | ||
88 | // else | ||
89 | // Position = part.OffsetPosition; | ||
90 | |||
91 | // m_log.DebugFormat( | ||
92 | // "[UNDO STATE]: Storing undo position {0} for root part", Position); | ||
93 | 82 | ||
94 | Rotation = part.RotationOffset; | 83 | Rotation = part.RotationOffset; |
95 | 84 | ||
96 | // m_log.DebugFormat( | 85 | // m_log.DebugFormat( |
97 | // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); | 86 | // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); |
98 | 87 | ||
99 | Scale = part.Shape.Scale; | 88 | Scale = part.Shape.Scale; |
100 | 89 | ||
101 | // m_log.DebugFormat( | 90 | // m_log.DebugFormat( |
102 | // "[UNDO STATE]: Storing undo scale {0} for root part", Scale); | 91 | // "[UNDO STATE]: Storing undo scale {0} for root part", Scale); |
103 | } | 92 | } |
104 | else | 93 | else |
105 | { | 94 | { |
106 | Position = part.OffsetPosition; | 95 | Position = part.OffsetPosition; |
107 | // m_log.DebugFormat( | 96 | // m_log.DebugFormat( |
108 | // "[UNDO STATE]: Storing undo position {0} for child part", Position); | 97 | // "[UNDO STATE]: Storing undo position {0} for child part", Position); |
109 | 98 | ||
110 | Rotation = part.RotationOffset; | 99 | Rotation = part.RotationOffset; |
111 | // m_log.DebugFormat( | 100 | // m_log.DebugFormat( |
112 | // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); | 101 | // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); |
113 | 102 | ||
114 | Scale = part.Shape.Scale; | 103 | Scale = part.Shape.Scale; |
115 | // m_log.DebugFormat( | 104 | // m_log.DebugFormat( |
116 | // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); | 105 | // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); |
117 | } | ||
118 | } | ||
119 | public void Merge(UndoState last) | ||
120 | { | ||
121 | if ((Type & UndoType.STATE_GROUP_POSITION) == 0 || ((last.Type & UndoType.STATE_GROUP_POSITION) >= (Type & UndoType.STATE_GROUP_POSITION))) | ||
122 | { | ||
123 | GroupPosition = last.GroupPosition; | ||
124 | Position = last.Position; | ||
125 | } | ||
126 | if ((Type & UndoType.STATE_GROUP_SCALE) == 0 || ((last.Type & UndoType.STATE_GROUP_SCALE) >= (Type & UndoType.STATE_GROUP_SCALE))) | ||
127 | { | ||
128 | GroupScale = last.GroupScale; | ||
129 | Scale = last.Scale; | ||
130 | } | ||
131 | if ((Type & UndoType.STATE_GROUP_ROTATION) == 0 || ((last.Type & UndoType.STATE_GROUP_ROTATION) >= (Type & UndoType.STATE_GROUP_ROTATION))) | ||
132 | { | ||
133 | GroupRotation = last.GroupRotation; | ||
134 | Rotation = last.Rotation; | ||
135 | } | ||
136 | if ((Type & UndoType.STATE_PRIM_POSITION) == 0 || ((last.Type & UndoType.STATE_PRIM_POSITION) >= (Type & UndoType.STATE_PRIM_POSITION))) | ||
137 | { | ||
138 | Position = last.Position; | ||
139 | } | ||
140 | if ((Type & UndoType.STATE_PRIM_SCALE) == 0 || ((last.Type & UndoType.STATE_PRIM_SCALE) >= (Type & UndoType.STATE_PRIM_SCALE))) | ||
141 | { | ||
142 | Scale = last.Scale; | ||
143 | } | ||
144 | if ((Type & UndoType.STATE_PRIM_ROTATION) == 0 || ((last.Type & UndoType.STATE_PRIM_ROTATION) >= (Type & UndoType.STATE_PRIM_ROTATION))) | ||
145 | { | ||
146 | Rotation = last.Rotation; | ||
147 | } | ||
148 | Type = Type | last.Type; | ||
149 | } | ||
150 | public bool Compare(UndoState undo) | ||
151 | { | ||
152 | if (undo == null || Position == null) return false; | ||
153 | if (undo.Position == Position && undo.Rotation == Rotation && undo.Scale == Scale && undo.GroupPosition == GroupPosition && undo.GroupScale == GroupScale && undo.GroupRotation == GroupRotation) | ||
154 | { | ||
155 | return true; | ||
156 | } | ||
157 | else | ||
158 | { | ||
159 | return false; | ||
160 | } | 106 | } |
161 | } | 107 | } |
108 | |||
162 | /// <summary> | 109 | /// <summary> |
163 | /// Compare the relevant state in the given part to this state. | 110 | /// Compare the relevant state in the given part to this state. |
164 | /// </summary> | 111 | /// </summary> |
@@ -183,15 +130,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
183 | return false; | 130 | return false; |
184 | } | 131 | } |
185 | 132 | ||
186 | private void RestoreState(SceneObjectPart part) | 133 | public void PlaybackState(SceneObjectPart part) |
187 | { | 134 | { |
188 | part.Undoing = true; | 135 | part.Undoing = true; |
189 | 136 | ||
190 | if (part.ParentID == 0) | 137 | if (part.ParentID == 0) |
191 | { | 138 | { |
192 | // m_log.DebugFormat( | 139 | // m_log.DebugFormat( |
193 | // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", | 140 | // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", |
194 | // Position, part.Name, part.LocalId); | 141 | // Position, part.Name, part.LocalId); |
195 | 142 | ||
196 | if (Position != Vector3.Zero) | 143 | if (Position != Vector3.Zero) |
197 | { | 144 | { |
@@ -201,9 +148,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
201 | part.ParentGroup.UpdateRootPosition(Position); | 148 | part.ParentGroup.UpdateRootPosition(Position); |
202 | } | 149 | } |
203 | 150 | ||
204 | // m_log.DebugFormat( | 151 | // m_log.DebugFormat( |
205 | // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", | 152 | // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", |
206 | // part.RotationOffset, Rotation, part.Name, part.LocalId); | 153 | // part.RotationOffset, Rotation, part.Name, part.LocalId); |
207 | 154 | ||
208 | if (ForGroup) | 155 | if (ForGroup) |
209 | part.UpdateRotation(Rotation); | 156 | part.UpdateRotation(Rotation); |
@@ -212,9 +159,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
212 | 159 | ||
213 | if (Scale != Vector3.Zero) | 160 | if (Scale != Vector3.Zero) |
214 | { | 161 | { |
215 | // m_log.DebugFormat( | 162 | // m_log.DebugFormat( |
216 | // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", | 163 | // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", |
217 | // part.Shape.Scale, Scale, part.Name, part.LocalId); | 164 | // part.Shape.Scale, Scale, part.Name, part.LocalId); |
218 | 165 | ||
219 | if (ForGroup) | 166 | if (ForGroup) |
220 | part.ParentGroup.GroupResize(Scale); | 167 | part.ParentGroup.GroupResize(Scale); |
@@ -228,24 +175,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
228 | { | 175 | { |
229 | if (Position != Vector3.Zero) | 176 | if (Position != Vector3.Zero) |
230 | { | 177 | { |
231 | // m_log.DebugFormat( | 178 | // m_log.DebugFormat( |
232 | // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", | 179 | // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", |
233 | // part.OffsetPosition, Position, part.Name, part.LocalId); | 180 | // part.OffsetPosition, Position, part.Name, part.LocalId); |
234 | 181 | ||
235 | part.OffsetPosition = Position; | 182 | part.OffsetPosition = Position; |
236 | } | 183 | } |
237 | 184 | ||
238 | // m_log.DebugFormat( | 185 | // m_log.DebugFormat( |
239 | // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", | 186 | // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", |
240 | // part.RotationOffset, Rotation, part.Name, part.LocalId); | 187 | // part.RotationOffset, Rotation, part.Name, part.LocalId); |
241 | 188 | ||
242 | part.UpdateRotation(Rotation); | 189 | part.UpdateRotation(Rotation); |
243 | 190 | ||
244 | if (Scale != Vector3.Zero) | 191 | if (Scale != Vector3.Zero) |
245 | { | 192 | { |
246 | // m_log.DebugFormat( | 193 | // m_log.DebugFormat( |
247 | // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", | 194 | // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", |
248 | // part.Shape.Scale, Scale, part.Name, part.LocalId); | 195 | // part.Shape.Scale, Scale, part.Name, part.LocalId); |
249 | 196 | ||
250 | part.Resize(Scale); | 197 | part.Resize(Scale); |
251 | } | 198 | } |