diff options
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 79 |
1 files changed, 64 insertions, 15 deletions
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 276b61f..f0e639d 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | |||
@@ -245,14 +245,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
245 | 245 | ||
246 | private void StartTimer() | 246 | private void StartTimer() |
247 | { | 247 | { |
248 | KeyframeTimer.Add(this); | 248 | lock (m_frames) |
249 | m_timerStopped = false; | 249 | { |
250 | KeyframeTimer.Add(this); | ||
251 | m_timerStopped = false; | ||
252 | } | ||
250 | } | 253 | } |
251 | 254 | ||
252 | private void StopTimer() | 255 | private void StopTimer() |
253 | { | 256 | { |
254 | m_timerStopped = true; | 257 | lock (m_frames) |
255 | KeyframeTimer.Remove(this); | 258 | m_timerStopped = true; |
256 | } | 259 | } |
257 | 260 | ||
258 | public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) | 261 | public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) |
@@ -407,19 +410,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
407 | } | 410 | } |
408 | else | 411 | else |
409 | { | 412 | { |
410 | m_running = false; | ||
411 | StopTimer(); | 413 | StopTimer(); |
414 | m_running = false; | ||
412 | } | 415 | } |
413 | } | 416 | } |
414 | 417 | ||
415 | public void Stop() | 418 | public void Stop() |
416 | { | 419 | { |
420 | StopTimer(); | ||
417 | m_running = false; | 421 | m_running = false; |
418 | m_isCrossing = false; | 422 | m_isCrossing = false; |
419 | m_waitingCrossing = false; | 423 | m_waitingCrossing = false; |
420 | 424 | ||
421 | StopTimer(); | ||
422 | |||
423 | m_basePosition = m_group.AbsolutePosition; | 425 | m_basePosition = m_group.AbsolutePosition; |
424 | m_baseRotation = m_group.GroupRotation; | 426 | m_baseRotation = m_group.GroupRotation; |
425 | 427 | ||
@@ -432,14 +434,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
432 | 434 | ||
433 | public void Pause() | 435 | public void Pause() |
434 | { | 436 | { |
435 | m_running = false; | ||
436 | StopTimer(); | 437 | StopTimer(); |
438 | m_running = false; | ||
437 | 439 | ||
438 | m_group.RootPart.Velocity = Vector3.Zero; | 440 | m_group.RootPart.Velocity = Vector3.Zero; |
439 | m_group.RootPart.AngularVelocity = Vector3.Zero; | 441 | m_group.RootPart.AngularVelocity = Vector3.Zero; |
440 | m_group.SendGroupRootTerseUpdate(); | 442 | m_group.SendGroupRootTerseUpdate(); |
441 | // m_group.RootPart.ScheduleTerseUpdate(); | 443 | // m_group.RootPart.ScheduleTerseUpdate(); |
444 | } | ||
442 | 445 | ||
446 | public void Suspend() | ||
447 | { | ||
448 | lock (m_frames) | ||
449 | { | ||
450 | if (m_timerStopped) | ||
451 | return; | ||
452 | m_timerStopped = true; | ||
453 | } | ||
454 | } | ||
455 | |||
456 | public void Resume() | ||
457 | { | ||
458 | lock (m_frames) | ||
459 | { | ||
460 | if (!m_timerStopped) | ||
461 | return; | ||
462 | if (m_running && !m_waitingCrossing) | ||
463 | StartTimer(); | ||
464 | } | ||
443 | } | 465 | } |
444 | 466 | ||
445 | private void GetNextList() | 467 | private void GetNextList() |
@@ -529,6 +551,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
529 | 551 | ||
530 | pos = (Vector3)k.Position; | 552 | pos = (Vector3)k.Position; |
531 | rot = (Quaternion)k.Rotation; | 553 | rot = (Quaternion)k.Rotation; |
554 | |||
532 | } | 555 | } |
533 | 556 | ||
534 | m_basePosition = pos; | 557 | m_basePosition = pos; |
@@ -540,14 +563,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
540 | 563 | ||
541 | public void OnTimer(double tickDuration) | 564 | public void OnTimer(double tickDuration) |
542 | { | 565 | { |
566 | if (!Monitor.TryEnter(m_frames)) | ||
567 | return; | ||
568 | if (m_timerStopped) | ||
569 | KeyframeTimer.Remove(this); | ||
570 | else | ||
571 | DoOnTimer(tickDuration); | ||
572 | Monitor.Exit(m_frames); | ||
573 | } | ||
574 | |||
575 | private void Done() | ||
576 | { | ||
577 | KeyframeTimer.Remove(this); | ||
578 | m_timerStopped = true; | ||
579 | m_running = false; | ||
580 | m_isCrossing = false; | ||
581 | m_waitingCrossing = false; | ||
582 | |||
583 | m_basePosition = m_group.AbsolutePosition; | ||
584 | m_baseRotation = m_group.GroupRotation; | ||
585 | |||
586 | m_group.RootPart.Velocity = Vector3.Zero; | ||
587 | m_group.RootPart.AngularVelocity = Vector3.Zero; | ||
588 | m_group.SendGroupRootTerseUpdate(); | ||
589 | // m_group.RootPart.ScheduleTerseUpdate(); | ||
590 | m_frames.Clear(); | ||
591 | } | ||
592 | |||
593 | private void DoOnTimer(double tickDuration) | ||
594 | { | ||
543 | if (m_skipLoops > 0) | 595 | if (m_skipLoops > 0) |
544 | { | 596 | { |
545 | m_skipLoops--; | 597 | m_skipLoops--; |
546 | return; | 598 | return; |
547 | } | 599 | } |
548 | 600 | ||
549 | if (m_timerStopped) // trap events still in air even after a timer.stop | ||
550 | return; | ||
551 | 601 | ||
552 | if (m_group == null) | 602 | if (m_group == null) |
553 | return; | 603 | return; |
@@ -587,7 +637,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
587 | 637 | ||
588 | if (m_frames.Count == 0) | 638 | if (m_frames.Count == 0) |
589 | { | 639 | { |
590 | Stop(); | 640 | Done(); |
591 | Scene scene = m_group.Scene; | 641 | Scene scene = m_group.Scene; |
592 | 642 | ||
593 | IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>(); | 643 | IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>(); |
@@ -686,11 +736,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
686 | 736 | ||
687 | if (angle > 0.01f) | 737 | if (angle > 0.01f) |
688 | */ | 738 | */ |
689 | if(Math.Abs(step.X - current.X) > 0.001f | 739 | if (Math.Abs(step.X - current.X) > 0.001f |
690 | || Math.Abs(step.Y - current.Y) > 0.001f | 740 | || Math.Abs(step.Y - current.Y) > 0.001f |
691 | || Math.Abs(step.Z - current.Z) > 0.001f) | 741 | || Math.Abs(step.Z - current.Z) > 0.001f) |
692 | // assuming w is a dependente var | 742 | // assuming w is a dependente var |
693 | |||
694 | { | 743 | { |
695 | // m_group.UpdateGroupRotationR(step); | 744 | // m_group.UpdateGroupRotationR(step); |
696 | m_group.RootPart.RotationOffset = step; | 745 | m_group.RootPart.RotationOffset = step; |