aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/UndoState.cs
diff options
context:
space:
mode:
authorUbitUmarov2012-03-10 20:32:19 +0000
committerUbitUmarov2012-03-10 20:32:19 +0000
commit908abb1c3dded307e769abac71f660b835875975 (patch)
tree755d4e532a94346fe1960e3870f07767fbcfdd4a /OpenSim/Region/Framework/Scenes/UndoState.cs
parentubitOde bug (diff)
downloadopensim-SC-908abb1c3dded307e769abac71f660b835875975.zip
opensim-SC-908abb1c3dded307e769abac71f660b835875975.tar.gz
opensim-SC-908abb1c3dded307e769abac71f660b835875975.tar.bz2
opensim-SC-908abb1c3dded307e769abac71f660b835875975.tar.xz
BIG MESS. changed Iclient interface so only one event is used to inform scene about position scale or rotation change by client (others can be added). Its served at SceneGraph that does permition checks, undostore and sends down to SOG. changed values are stored in a class (ObjectChangeData) and what is changed as a enum (ObjectChangeWhat) with bit fields and 'macros' of this for better readability (at top of scenegraph.cs lasy to find better place for now) this can be extended for other things clients changes and need undo/redo. SOG process acording to what is changed. Changed UNDO/redo to use this also (warning is only storing what is changed, previus stored all, this must be checked for side efects. to save all PRS change commented line in scenegraph). Still have excessive calls to ScheduleGroupForTerseUpdate. **** UNTESTED ****
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/UndoState.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/UndoState.cs113
1 files changed, 112 insertions, 1 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 38474de..eb76ca5 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -48,6 +48,7 @@ namespace OpenSim.Region.Framework.Scenes
48 STATE_ALL = 63 48 STATE_ALL = 63
49 } 49 }
50 50
51/*
51 public class UndoState 52 public class UndoState
52 { 53 {
53 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -121,9 +122,16 @@ namespace OpenSim.Region.Framework.Scenes
121 public void PlayState(SceneObjectPart part) 122 public void PlayState(SceneObjectPart part)
122 { 123 {
123 part.Undoing = true; 124 part.Undoing = true;
124 125 bool physbuilding = false;
126
125 if (part.ParentID == 0) 127 if (part.ParentID == 0)
126 { 128 {
129 if (!ForGroup && part.PhysActor != null)
130 {
131 part.PhysActor.Building = true;
132 physbuilding = true;
133 }
134
127 if (Position != Vector3.Zero) 135 if (Position != Vector3.Zero)
128 { 136 {
129 if (ForGroup) 137 if (ForGroup)
@@ -139,17 +147,34 @@ namespace OpenSim.Region.Framework.Scenes
139 147
140 if (Scale != Vector3.Zero) 148 if (Scale != Vector3.Zero)
141 { 149 {
150 if (!physbuilding && part.PhysActor != null)
151 {
152 part.PhysActor.Building = true;
153 physbuilding = true;
154 }
155
142 if (ForGroup) 156 if (ForGroup)
143 part.ParentGroup.GroupResize(Scale); 157 part.ParentGroup.GroupResize(Scale);
144 else 158 else
145 part.Resize(Scale); 159 part.Resize(Scale);
146 } 160 }
161
162 if (physbuilding)
163 part.PhysActor.Building = false;
164
147 part.ParentGroup.ScheduleGroupForTerseUpdate(); 165 part.ParentGroup.ScheduleGroupForTerseUpdate();
148 } 166 }
149 else 167 else
150 { 168 {
151 if (ForGroup) // trap for group since seems parts can't do it 169 if (ForGroup) // trap for group since seems parts can't do it
152 return; 170 return;
171
172 // changing a part invalidates entire object physical rep
173 if (part.ParentGroup != null && part.ParentGroup.RootPart != null && part.ParentGroup.RootPart.PhysActor != null)
174 {
175 part.ParentGroup.RootPart.PhysActor.Building = true;
176 physbuilding = true;
177 }
153 178
154 // Note: Updating these properties on sop automatically schedules an update if needed 179 // Note: Updating these properties on sop automatically schedules an update if needed
155 part.OffsetPosition = Position; 180 part.OffsetPosition = Position;
@@ -158,12 +183,98 @@ namespace OpenSim.Region.Framework.Scenes
158 { 183 {
159 part.Resize(Scale); 184 part.Resize(Scale);
160 } 185 }
186
187 if (physbuilding)
188 part.ParentGroup.RootPart.PhysActor.Building = false;
189 }
190
191 part.Undoing = false;
192 }
193 }
194*/
195 public class UndoState
196 {
197 public ObjectChangeData data;
198 /// <summary>
199 /// Constructor.
200 /// </summary>
201 /// <param name="part"></param>
202 /// <param name="forGroup">True if the undo is for an entire group</param>
203 /// only for root parts ????
204 public UndoState(SceneObjectPart part, ObjectChangeWhat what)
205 {
206 data = new ObjectChangeData();
207
208 data.what = what;
209
210 if (part.ParentGroup.RootPart == part)
211 {
212 if ((what & ObjectChangeWhat.Position) != 0)
213 data.position = part.ParentGroup.AbsolutePosition;
214 if ((what & ObjectChangeWhat.Rotation) != 0)
215 data.rotation = part.RotationOffset;
216 if ((what & ObjectChangeWhat.Scale) != 0)
217 data.scale = part.Shape.Scale;
218 }
219 else
220 {
221 if ((what & ObjectChangeWhat.Position) != 0)
222 data.position = part.OffsetPosition;
223 if ((what & ObjectChangeWhat.Rotation) != 0)
224 data.rotation = part.RotationOffset;
225 if ((what & ObjectChangeWhat.Scale) != 0)
226 data.scale = part.Shape.Scale;
227 }
228 }
229
230 /// <summary>
231 /// Compare the relevant state in the given part to this state.
232 /// </summary>
233 /// <param name="part"></param>
234 /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns>
235 public bool Compare(SceneObjectPart part, ObjectChangeWhat what)
236 {
237 if (data.what != what) // if diferent targets, then they are diferent
238 return false;
239
240 if (part != null)
241 {
242 if (part.ParentID == 0)
243 {
244 if ((what & ObjectChangeWhat.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition)
245 return false;
246 }
247 else
248 {
249 if ((what & ObjectChangeWhat.Position) != 0 && data.position != part.OffsetPosition)
250 return false;
251 }
252
253 if ((what & ObjectChangeWhat.Rotation) != 0 && data.rotation != part.RotationOffset)
254 return false;
255 if ((what & ObjectChangeWhat.Rotation) != 0 && data.scale == part.Shape.Scale)
256 return false;
257 return true;
258
161 } 259 }
260 return false;
261 }
162 262
263 public void PlayState(SceneObjectPart part)
264 {
265 part.Undoing = true;
266
267 SceneObjectGroup grp = part.ParentGroup;
268
269 if (grp != null)
270 {
271 grp.doChangeObject(part, data);
272 }
163 part.Undoing = false; 273 part.Undoing = false;
164 } 274 }
165 } 275 }
166 276
277
167 public class LandUndoState 278 public class LandUndoState
168 { 279 {
169 public ITerrainModule m_terrainModule; 280 public ITerrainModule m_terrainModule;