aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorUbitUmarov2014-08-13 18:52:13 +0100
committerUbitUmarov2014-08-13 18:52:13 +0100
commit483afe68679b7c4b5a36917e5fa41d4b0a0e0db4 (patch)
tree4e663be030bf4bf4ae1f51f5c029cec6529a46eb /OpenSim
parentMerge branch 'master' into ubitworkmaster (diff)
downloadopensim-SC_OLD-483afe68679b7c4b5a36917e5fa41d4b0a0e0db4.zip
opensim-SC_OLD-483afe68679b7c4b5a36917e5fa41d4b0a0e0db4.tar.gz
opensim-SC_OLD-483afe68679b7c4b5a36917e5fa41d4b0a0e0db4.tar.bz2
opensim-SC_OLD-483afe68679b7c4b5a36917e5fa41d4b0a0e0db4.tar.xz
remove creative hack and try to fix
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/KeyframeMotion.cs192
1 files changed, 92 insertions, 100 deletions
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
index 49b71e5..902e60b 100644
--- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
+++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
@@ -323,22 +323,25 @@ namespace OpenSim.Region.Framework.Scenes
323 m_group = grp; 323 m_group = grp;
324 m_scene = grp.Scene; 324 m_scene = grp.Scene;
325 325
326 Vector3 grppos = grp.AbsolutePosition; 326 lock (m_frames)
327 Vector3 offset = grppos - m_serializedPosition; 327 {
328 // avoid doing it more than once 328 Vector3 grppos = grp.AbsolutePosition;
329 // current this will happen draging a prim to other region 329 Vector3 offset = grppos - m_serializedPosition;
330 m_serializedPosition = grppos; 330 // avoid doing it more than once
331 // current this will happen draging a prim to other region
332 m_serializedPosition = grppos;
331 333
332 m_basePosition += offset; 334 m_basePosition += offset;
333 m_currentFrame.Position += offset; 335 m_currentFrame.Position += offset;
334 336
335 m_nextPosition += offset; 337 m_nextPosition += offset;
336 338
337 for (int i = 0; i < m_frames.Count; i++) 339 for (int i = 0; i < m_frames.Count; i++)
338 { 340 {
339 Keyframe k = m_frames[i]; 341 Keyframe k = m_frames[i];
340 k.Position += offset; 342 k.Position += offset;
341 m_frames[i]=k; 343 m_frames[i] = k;
344 }
342 } 345 }
343 346
344 if (m_running) 347 if (m_running)
@@ -383,25 +386,28 @@ namespace OpenSim.Region.Framework.Scenes
383 m_keyframes.CopyTo(newmotion.m_keyframes, 0); 386 m_keyframes.CopyTo(newmotion.m_keyframes, 0);
384 } 387 }
385 388
386 newmotion.m_frames = new List<Keyframe>(m_frames); 389 lock (m_frames)
390 {
391 newmotion.m_frames = new List<Keyframe>(m_frames);
387 392
388 newmotion.m_basePosition = m_basePosition; 393 newmotion.m_basePosition = m_basePosition;
389 newmotion.m_baseRotation = m_baseRotation; 394 newmotion.m_baseRotation = m_baseRotation;
390 395
391 if (m_selected) 396 if (m_selected)
392 newmotion.m_serializedPosition = m_serializedPosition;
393 else
394 {
395 if (m_group != null)
396 newmotion.m_serializedPosition = m_group.AbsolutePosition;
397 else
398 newmotion.m_serializedPosition = m_serializedPosition; 397 newmotion.m_serializedPosition = m_serializedPosition;
399 } 398 else
399 {
400 if (m_group != null)
401 newmotion.m_serializedPosition = m_group.AbsolutePosition;
402 else
403 newmotion.m_serializedPosition = m_serializedPosition;
404 }
400 405
401 newmotion.m_currentFrame = m_currentFrame; 406 newmotion.m_currentFrame = m_currentFrame;
402 407
403 newmotion.m_iterations = m_iterations; 408 newmotion.m_iterations = m_iterations;
404 newmotion.m_running = m_running; 409 newmotion.m_running = m_running;
410 }
405 411
406 if (m_running && !m_waitingCrossing) 412 if (m_running && !m_waitingCrossing)
407 StartTimer(); 413 StartTimer();
@@ -520,7 +526,6 @@ namespace OpenSim.Region.Framework.Scenes
520 k.Position = pos; 526 k.Position = pos;
521// k.Velocity = Vector3.Zero; 527// k.Velocity = Vector3.Zero;
522 } 528 }
523 k.AngularVelocity = (Vector3)k.Position;
524 529
525 k.StartRotation = rot; 530 k.StartRotation = rot;
526 if (k.Rotation.HasValue) 531 if (k.Rotation.HasValue)
@@ -654,27 +659,29 @@ namespace OpenSim.Region.Framework.Scenes
654 659
655 if (m_frames.Count == 0) 660 if (m_frames.Count == 0)
656 { 661 {
657 GetNextList(); 662 lock (m_frames)
658
659 if (m_frames.Count == 0)
660 { 663 {
661 Done(); 664 GetNextList();
662 Scene scene = m_group.Scene;
663 665
664 IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>(); 666 if (m_frames.Count == 0)
665 foreach (IScriptModule m in scriptModules)
666 { 667 {
667 if (m == null) 668 Done();
668 continue; 669 Scene scene = m_group.Scene;
669 m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]);
670 }
671 670
672 return; 671 IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>();
673 } 672 foreach (IScriptModule m in scriptModules)
673 {
674 if (m == null)
675 continue;
676 m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]);
677 }
674 678
675 m_currentFrame = m_frames[0]; 679 return;
676 m_currentFrame.TimeMS += (int)tickDuration; 680 }
677 681
682 m_currentFrame = m_frames[0];
683 m_currentFrame.TimeMS += (int)tickDuration;
684 }
678 //force a update on a keyframe transition 685 //force a update on a keyframe transition
679 update = true; 686 update = true;
680 } 687 }
@@ -683,22 +690,26 @@ namespace OpenSim.Region.Framework.Scenes
683 690
684 // Do the frame processing 691 // Do the frame processing
685 double steps = (double)m_currentFrame.TimeMS / tickDuration; 692 double steps = (double)m_currentFrame.TimeMS / tickDuration;
686 693
687 if (steps <= 0.0) 694 if (steps <= 0.0)
688 { 695 {
689 m_group.RootPart.Velocity = Vector3.Zero; 696 m_group.RootPart.Velocity = Vector3.Zero;
690 m_group.RootPart.AngularVelocity = Vector3.Zero; 697 m_group.RootPart.AngularVelocity = Vector3.Zero;
691 698
692 m_nextPosition = NormalizeVector(m_currentFrame.AngularVelocity); 699 m_nextPosition = (Vector3)m_currentFrame.Position;
693 m_group.AbsolutePosition = m_nextPosition; 700 m_group.AbsolutePosition = m_nextPosition;
694 701
695 // we are sending imediate updates, no doing force a extra terseUpdate 702 // we are sending imediate updates, no doing force a extra terseUpdate
696 // m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); 703 // m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation);
697 704
698 m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation; 705 m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation;
699 m_frames.RemoveAt(0); 706
700 if (m_frames.Count > 0) 707 lock (m_frames)
701 m_currentFrame = m_frames[0]; 708 {
709 m_frames.RemoveAt(0);
710 if (m_frames.Count > 0)
711 m_currentFrame = m_frames[0];
712 }
702 713
703 update = true; 714 update = true;
704 } 715 }
@@ -714,7 +725,6 @@ namespace OpenSim.Region.Framework.Scenes
714 { 725 {
715 // m_group.AbsolutePosition += motionThisFrame; 726 // m_group.AbsolutePosition += motionThisFrame;
716 m_nextPosition = m_group.AbsolutePosition + motionThisFrame; 727 m_nextPosition = m_group.AbsolutePosition + motionThisFrame;
717 m_group.AbsolutePosition = m_nextPosition;
718 728
719 //m_group.RootPart.Velocity = v; 729 //m_group.RootPart.Velocity = v;
720 update = true; 730 update = true;
@@ -726,43 +736,43 @@ namespace OpenSim.Region.Framework.Scenes
726 736
727 Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); 737 Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete);
728 step.Normalize(); 738 step.Normalize();
729/* use simpler change detection 739 /* use simpler change detection
730* float angle = 0; 740 * float angle = 0;
731 741
732 float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; 742 float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W;
733 float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; 743 float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W;
734 float aa_bb = aa * bb; 744 float aa_bb = aa * bb;
735 745
736 if (aa_bb == 0) 746 if (aa_bb == 0)
737 { 747 {
738 angle = 0; 748 angle = 0;
739 } 749 }
740 else 750 else
741 { 751 {
742 float ab = current.X * step.X + 752 float ab = current.X * step.X +
743 current.Y * step.Y + 753 current.Y * step.Y +
744 current.Z * step.Z + 754 current.Z * step.Z +
745 current.W * step.W; 755 current.W * step.W;
746 float q = (ab * ab) / aa_bb; 756 float q = (ab * ab) / aa_bb;
747 757
748 if (q > 1.0f) 758 if (q > 1.0f)
749 { 759 {
750 angle = 0; 760 angle = 0;
751 } 761 }
752 else 762 else
753 { 763 {
754 angle = (float)Math.Acos(2 * q - 1); 764 angle = (float)Math.Acos(2 * q - 1);
755 } 765 }
756 } 766 }
757 767
758 if (angle > 0.01f) 768 if (angle > 0.01f)
759*/ 769 */
760 if (Math.Abs(step.X - current.X) > 0.001f 770 if (Math.Abs(step.X - current.X) > 0.001f
761 || Math.Abs(step.Y - current.Y) > 0.001f 771 || Math.Abs(step.Y - current.Y) > 0.001f
762 || Math.Abs(step.Z - current.Z) > 0.001f) 772 || Math.Abs(step.Z - current.Z) > 0.001f)
763 // assuming w is a dependente var 773 // assuming w is a dependente var
764 { 774 {
765// m_group.UpdateGroupRotationR(step); 775 // m_group.UpdateGroupRotationR(step);
766 m_group.RootPart.RotationOffset = step; 776 m_group.RootPart.RotationOffset = step;
767 777
768 //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); 778 //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
@@ -773,29 +783,11 @@ namespace OpenSim.Region.Framework.Scenes
773 783
774 if (update) 784 if (update)
775 { 785 {
786 m_group.AbsolutePosition = m_nextPosition;
776 m_group.SendGroupRootTerseUpdate(); 787 m_group.SendGroupRootTerseUpdate();
777 } 788 }
778 } 789 }
779 private Vector3 NormalizeVector(Vector3? pPosition)
780 {
781 if (pPosition == null)
782 return Vector3.Zero;
783
784 Vector3 tmp = (Vector3) pPosition;
785 790
786 while (tmp.X > Constants.RegionSize)
787 tmp.X -= Constants.RegionSize;
788 while (tmp.X < 0)
789 tmp.X += Constants.RegionSize;
790 while (tmp.Y > Constants.RegionSize)
791 tmp.Y -= Constants.RegionSize;
792 while (tmp.Y < 0)
793 tmp.Y += Constants.RegionSize;
794
795 return tmp;
796
797
798 }
799 public Byte[] Serialize() 791 public Byte[] Serialize()
800 { 792 {
801 StopTimer(); 793 StopTimer();