aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/KeyframeMotion.cs174
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs2
4 files changed, 117 insertions, 65 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 3b90c85..4d7c0c9 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -1698,7 +1698,7 @@ namespace OpenSim.Data.MySQL
1698 cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl); 1698 cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl);
1699 1699
1700 if (prim.KeyframeMotion != null) 1700 if (prim.KeyframeMotion != null)
1701 cmd.Parameters.AddWithValue("KeyframeMotion", prim.KeyframeMotion.Serialize(true)); 1701 cmd.Parameters.AddWithValue("KeyframeMotion", prim.KeyframeMotion.Serialize());
1702 else 1702 else
1703 cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]); 1703 cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]);
1704 1704
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
index 5333177..42e3860 100644
--- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
+++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
@@ -81,10 +81,10 @@ namespace OpenSim.Region.Framework.Scenes
81 private bool m_timerStopped; 81 private bool m_timerStopped;
82 82
83 [NonSerialized()] 83 [NonSerialized()]
84 private bool m_crossing; 84 private bool m_isCrossing;
85 85
86 [NonSerialized()] 86 [NonSerialized()]
87 private int m_crossFailcntr; 87 private bool m_waitingCrossing;
88 88
89 // retry position for cross fail 89 // retry position for cross fail
90 [NonSerialized()] 90 [NonSerialized()]
@@ -112,9 +112,7 @@ namespace OpenSim.Region.Framework.Scenes
112 public bool Selected 112 public bool Selected
113 { 113 {
114 set 114 set
115 { 115 {
116 m_crossing = false;
117 m_crossFailcntr = 0;
118 if (!value) 116 if (!value)
119 { 117 {
120 // Once we're let go, recompute positions 118 // Once we're let go, recompute positions
@@ -130,6 +128,8 @@ namespace OpenSim.Region.Framework.Scenes
130 m_serializedPosition = m_group.AbsolutePosition; 128 m_serializedPosition = m_group.AbsolutePosition;
131 } 129 }
132 } 130 }
131 m_isCrossing = false;
132 m_waitingCrossing = false;
133 m_selected = value; 133 m_selected = value;
134 } 134 }
135 } 135 }
@@ -150,6 +150,17 @@ namespace OpenSim.Region.Framework.Scenes
150 m_timer.Stop(); 150 m_timer.Stop();
151 } 151 }
152 152
153 private void RemoveTimer()
154 {
155 if (m_timer == null)
156 return;
157 m_timerStopped = true;
158 m_timer.Stop();
159 m_timer.Elapsed -= OnTimer;
160 m_timer = null;
161 }
162
163
153 public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) 164 public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data)
154 { 165 {
155 KeyframeMotion newMotion = null; 166 KeyframeMotion newMotion = null;
@@ -169,8 +180,8 @@ namespace OpenSim.Region.Framework.Scenes
169 newMotion.m_onTimerLock = new object(); 180 newMotion.m_onTimerLock = new object();
170 newMotion.m_timerStopped = false; 181 newMotion.m_timerStopped = false;
171 newMotion.m_inOnTimer = false; 182 newMotion.m_inOnTimer = false;
172 newMotion.m_crossing = false; 183 newMotion.m_isCrossing = false;
173 newMotion.m_crossFailcntr = 0; 184 newMotion.m_waitingCrossing = false;
174 } 185 }
175 catch 186 catch
176 { 187 {
@@ -184,8 +195,8 @@ namespace OpenSim.Region.Framework.Scenes
184 { 195 {
185// lock (m_onTimerLock) 196// lock (m_onTimerLock)
186 { 197 {
187 m_crossing = false; 198 m_isCrossing = false;
188 m_crossFailcntr = 0; 199 m_waitingCrossing = false;
189 StopTimer(); 200 StopTimer();
190 201
191 m_group = grp; 202 m_group = grp;
@@ -220,10 +231,13 @@ namespace OpenSim.Region.Framework.Scenes
220 m_onTimerLock = new object(); 231 m_onTimerLock = new object();
221 232
222 m_group = grp; 233 m_group = grp;
223 m_basePosition = grp.AbsolutePosition; 234 if (grp != null)
224 m_baseRotation = grp.GroupRotation; 235 {
225 m_crossing = false; 236 m_basePosition = grp.AbsolutePosition;
226 m_crossFailcntr = 0; 237 m_baseRotation = grp.GroupRotation;
238 }
239 m_isCrossing = false;
240 m_waitingCrossing = false;
227 } 241 }
228 242
229 public void SetKeyframes(Keyframe[] frames) 243 public void SetKeyframes(Keyframe[] frames)
@@ -231,34 +245,74 @@ namespace OpenSim.Region.Framework.Scenes
231 m_keyframes = frames; 245 m_keyframes = frames;
232 } 246 }
233 247
248 public KeyframeMotion Copy(SceneObjectGroup newgrp)
249 {
250 StopTimer();
251
252 KeyframeMotion newmotion = new KeyframeMotion(newgrp, m_mode, m_data);
253
254 if (newgrp != null && newgrp.IsSelected)
255 newmotion.m_selected = true;
256
257 if (m_keyframes != null)
258 m_keyframes.CopyTo(newmotion.m_keyframes, 0);
259
260 newmotion.m_frames = new List<Keyframe>(m_frames);
261 newmotion.m_currentFrame = m_currentFrame;
262
263 newmotion.m_nextPosition = m_nextPosition;
264 if (m_selected)
265 newmotion.m_serializedPosition = m_serializedPosition;
266 else
267 {
268 if (m_group != null)
269 newmotion.m_serializedPosition = m_group.AbsolutePosition;
270 else
271 newmotion.m_serializedPosition = m_serializedPosition;
272 }
273
274 newmotion.m_iterations = m_iterations;
275
276 newmotion.m_onTimerLock = new object();
277 newmotion.m_timerStopped = false;
278 newmotion.m_inOnTimer = false;
279 newmotion.m_isCrossing = false;
280 newmotion.m_waitingCrossing = false;
281
282 if (m_running && !m_waitingCrossing)
283 StartTimer();
284
285 return newmotion;
286 }
287
234 public void Delete() 288 public void Delete()
235 { 289 {
236 m_running = false; 290 m_running = false;
237 m_crossing = false; 291 RemoveTimer();
238 m_crossFailcntr = 0; 292 m_isCrossing = false;
239 StopTimer(); 293 m_waitingCrossing = false;
240 m_frames.Clear(); 294 m_frames.Clear();
241 m_keyframes = null; 295 m_keyframes = null;
242
243 if (m_timer == null)
244 return;
245 m_timer.Elapsed -= OnTimer;
246 m_timer = null;
247 } 296 }
248 297
249 public void Start() 298 public void Start()
250 { 299 {
251 m_crossing = false; 300 m_isCrossing = false;
252 m_crossFailcntr = 0; 301 m_waitingCrossing = false;
253 if (m_keyframes.Length > 0) 302 if (m_keyframes.Length > 0)
254 { 303 {
255 if (m_timer == null) 304 if (m_timer == null)
256 { 305 {
257 m_timer = new Timer(); 306 m_timer = new Timer();
258 m_timer.Interval = (int)timerInterval; 307 m_timer.Interval = timerInterval;
259 m_timer.AutoReset = true; 308 m_timer.AutoReset = true;
260 m_timer.Elapsed += OnTimer; 309 m_timer.Elapsed += OnTimer;
261 } 310 }
311 else
312 {
313 StopTimer();
314 m_timer.Interval = timerInterval;
315 }
262 316
263 m_inOnTimer = false; 317 m_inOnTimer = false;
264 StartTimer(); 318 StartTimer();
@@ -267,24 +321,17 @@ namespace OpenSim.Region.Framework.Scenes
267 else 321 else
268 { 322 {
269 m_running = false; 323 m_running = false;
270 if (m_timer != null) 324 RemoveTimer();
271 {
272 StopTimer();
273 m_timer.Elapsed -= OnTimer;
274 m_timer = null;
275 }
276 } 325 }
277 } 326 }
278 327
279 public void Stop() 328 public void Stop()
280 { 329 {
281 m_running = false; 330 m_running = false;
282 m_crossing = false; 331 m_isCrossing = false;
283 m_crossFailcntr = 0; 332 m_waitingCrossing = false;
284 333
285 StopTimer(); 334 RemoveTimer();
286 m_timer.Elapsed -= OnTimer;
287 m_timer = null;
288 335
289 m_basePosition = m_group.AbsolutePosition; 336 m_basePosition = m_group.AbsolutePosition;
290 m_baseRotation = m_group.GroupRotation; 337 m_baseRotation = m_group.GroupRotation;
@@ -299,8 +346,7 @@ namespace OpenSim.Region.Framework.Scenes
299 public void Pause() 346 public void Pause()
300 { 347 {
301 m_running = false; 348 m_running = false;
302 m_crossFailcntr = 0; 349 RemoveTimer();
303 StopTimer();
304 350
305 m_group.RootPart.Velocity = Vector3.Zero; 351 m_group.RootPart.Velocity = Vector3.Zero;
306 m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); 352 m_group.RootPart.UpdateAngularVelocity(Vector3.Zero);
@@ -421,7 +467,7 @@ namespace OpenSim.Region.Framework.Scenes
421 if (m_group == null) 467 if (m_group == null)
422 return; 468 return;
423 469
424// lock (m_onTimerLock) 470 lock (m_onTimerLock)
425 { 471 {
426 472
427 m_inOnTimer = true; 473 m_inOnTimer = true;
@@ -441,15 +487,15 @@ namespace OpenSim.Region.Framework.Scenes
441 return; 487 return;
442 } 488 }
443 489
444 if (m_crossing) 490 if (m_isCrossing)
445 { 491 {
446 // if crossing and timer running then cross failed 492 // if crossing and timer running then cross failed
447 // wait some time then 493 // wait some time then
448 // retry to set the position that evtually caused the outbound 494 // retry to set the position that evtually caused the outbound
449 // if still outside region this will call startCrossing below 495 // if still outside region this will call startCrossing below
450 m_crossing = false; 496 m_isCrossing = false;
451 m_group.AbsolutePosition = m_nextPosition; 497 m_group.AbsolutePosition = m_nextPosition;
452 if (!m_crossing) 498 if (!m_isCrossing)
453 { 499 {
454 StopTimer(); 500 StopTimer();
455 m_timer.Interval = timerInterval; 501 m_timer.Interval = timerInterval;
@@ -552,9 +598,9 @@ namespace OpenSim.Region.Framework.Scenes
552 598
553 if (angle > 0.01f) 599 if (angle > 0.01f)
554 */ 600 */
555 if(Math.Abs(step.X -current.X) > 0.001f 601 if(Math.Abs(step.X - current.X) > 0.001f
556 || Math.Abs(step.Y -current.Y) > 0.001f 602 || Math.Abs(step.Y - current.Y) > 0.001f
557 || Math.Abs(step.Z -current.Z) > 0.001f) 603 || Math.Abs(step.Z - current.Z) > 0.001f)
558 // assuming w is a dependente var 604 // assuming w is a dependente var
559 605
560 { 606 {
@@ -563,7 +609,6 @@ namespace OpenSim.Region.Framework.Scenes
563 update = true; 609 update = true;
564 } 610 }
565 } 611 }
566
567 } 612 }
568 613
569 if (update) 614 if (update)
@@ -573,7 +618,7 @@ namespace OpenSim.Region.Framework.Scenes
573 catch ( Exception ex) 618 catch ( Exception ex)
574 { 619 {
575 // still happening sometimes 620 // still happening sometimes
576 // lets try to see what 621 // lets try to see where
577 m_log.Warn("[KeyFrame]: timer overrun" + ex.Message); 622 m_log.Warn("[KeyFrame]: timer overrun" + ex.Message);
578 } 623 }
579 624
@@ -585,29 +630,34 @@ namespace OpenSim.Region.Framework.Scenes
585 } 630 }
586 } 631 }
587 632
588 public Byte[] Serialize(bool StopMoveTimer) 633 public Byte[] Serialize()
589 { 634 {
635 StopTimer();
590 MemoryStream ms = new MemoryStream(); 636 MemoryStream ms = new MemoryStream();
591 if (StopMoveTimer && m_timer != null)
592 StopTimer();
593 637
594// lock (m_onTimerLock) 638 BinaryFormatter fmt = new BinaryFormatter();
595 { 639 SceneObjectGroup tmp = m_group;
596 BinaryFormatter fmt = new BinaryFormatter(); 640 m_group = null;
597 SceneObjectGroup tmp = m_group; 641 if (!m_selected && tmp != null)
598 m_group = null; 642 m_serializedPosition = tmp.AbsolutePosition;
599 if(!m_selected) 643 fmt.Serialize(ms, this);
600 m_serializedPosition = tmp.AbsolutePosition; 644 m_group = tmp;
601 fmt.Serialize(ms, this); 645 if (m_running && !m_waitingCrossing)
602 m_group = tmp; 646 StartTimer();
603 return ms.ToArray(); 647
604 } 648 return ms.ToArray();
605 } 649 }
606 650
607 public void StartCrossingCheck() 651 public void StartCrossingCheck()
608 { 652 {
653 // timer will be restart by crossingFailure
654 // or never since crossing worked and this
655 // should be deleted
609 StopTimer(); 656 StopTimer();
610 m_crossing = true; 657
658 m_isCrossing = true;
659 m_waitingCrossing = true;
660
611// to remove / retune to smoth crossings 661// to remove / retune to smoth crossings
612 if (m_group.RootPart.Velocity != Vector3.Zero) 662 if (m_group.RootPart.Velocity != Vector3.Zero)
613 { 663 {
@@ -618,6 +668,8 @@ namespace OpenSim.Region.Framework.Scenes
618 668
619 public void CrossingFailure() 669 public void CrossingFailure()
620 { 670 {
671 m_waitingCrossing = false;
672
621 if (m_group != null) 673 if (m_group != null)
622 { 674 {
623 m_group.RootPart.Velocity = Vector3.Zero; 675 m_group.RootPart.Velocity = Vector3.Zero;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 65a1da2..834d27b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2066,7 +2066,7 @@ namespace OpenSim.Region.Framework.Scenes
2066 { 2066 {
2067 if (part.KeyframeMotion != null) 2067 if (part.KeyframeMotion != null)
2068 { 2068 {
2069 part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize(false)); 2069 part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize());
2070// part.KeyframeMotion.UpdateSceneObject(this); 2070// part.KeyframeMotion.UpdateSceneObject(this);
2071 } 2071 }
2072 }); 2072 });
@@ -4419,7 +4419,7 @@ namespace OpenSim.Region.Framework.Scenes
4419 { 4419 {
4420 if (part.KeyframeMotion != null) 4420 if (part.KeyframeMotion != null)
4421 { 4421 {
4422 part.KeyframeMotion = KeyframeMotion.FromData(sog, part.KeyframeMotion.Serialize(true)); 4422 part.KeyframeMotion = KeyframeMotion.FromData(sog, part.KeyframeMotion.Serialize());
4423 // this is called later 4423 // this is called later
4424// part.KeyframeMotion.UpdateSceneObject(this); 4424// part.KeyframeMotion.UpdateSceneObject(this);
4425 } 4425 }
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 1c75607..123c158 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -1241,7 +1241,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1241 1241
1242 if (sog.RootPart.KeyframeMotion != null) 1242 if (sog.RootPart.KeyframeMotion != null)
1243 { 1243 {
1244 Byte[] data = sog.RootPart.KeyframeMotion.Serialize(true); 1244 Byte[] data = sog.RootPart.KeyframeMotion.Serialize();
1245 1245
1246 writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); 1246 writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty);
1247 writer.WriteBase64(data, 0, data.Length); 1247 writer.WriteBase64(data, 0, data.Length);