aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/KeyframeMotion.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/KeyframeMotion.cs128
1 files changed, 10 insertions, 118 deletions
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
index 2b95a4c..c00190a 100644
--- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
+++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
@@ -351,26 +351,7 @@ namespace OpenSim.Region.Framework.Scenes
351 m_group = grp; 351 m_group = grp;
352 m_scene = grp.Scene; 352 m_scene = grp.Scene;
353 353
354<<<<<<< HEAD 354
355 Vector3 grppos = grp.AbsolutePosition;
356 Vector3 offset = grppos - m_serializedPosition;
357 // avoid doing it more than once
358 // current this will happen dragging a prim to other region
359 m_serializedPosition = grppos;
360
361 m_basePosition += offset;
362 m_nextPosition += offset;
363
364 m_currentFrame.StartPosition += offset;
365 m_currentFrame.Position += offset;
366
367 for (int i = 0; i < m_frames.Count; i++)
368 {
369 Keyframe k = m_frames[i];
370 k.StartPosition += offset;
371 k.Position += offset;
372 m_frames[i]=k;
373=======
374 lock (m_frames) 355 lock (m_frames)
375 { 356 {
376 Vector3 grppos = grp.AbsolutePosition; 357 Vector3 grppos = grp.AbsolutePosition;
@@ -390,7 +371,6 @@ namespace OpenSim.Region.Framework.Scenes
390 k.Position += offset; 371 k.Position += offset;
391 m_frames[i] = k; 372 m_frames[i] = k;
392 } 373 }
393>>>>>>> avn/ubitvar
394 } 374 }
395 375
396 if (m_running) 376 if (m_running)
@@ -708,29 +688,6 @@ namespace OpenSim.Region.Framework.Scenes
708 688
709 if (m_frames.Count == 0) 689 if (m_frames.Count == 0)
710 { 690 {
711<<<<<<< HEAD
712 if (!m_running) return;
713
714 GetNextList();
715
716 if (m_frames.Count == 0)
717 {
718 Stop();
719// Scene scene = m_group.Scene;
720//
721// IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>();
722// foreach (IScriptModule m in scriptModules)
723// {
724// if (m == null)
725// continue;
726// m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]);
727// }
728
729 m_group.Scene.EventManager.TriggerMovingEndEvent(m_group.RootPart.LocalId);
730
731 return;
732 }
733=======
734 lock (m_frames) 691 lock (m_frames)
735 { 692 {
736 GetNextList(); 693 GetNextList();
@@ -738,17 +695,7 @@ namespace OpenSim.Region.Framework.Scenes
738 if (m_frames.Count == 0) 695 if (m_frames.Count == 0)
739 { 696 {
740 Done(); 697 Done();
741 Scene scene = m_group.Scene; 698 m_group.Scene.EventManager.TriggerMovingEndEvent(m_group.RootPart.LocalId);
742
743 IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>();
744 foreach (IScriptModule m in scriptModules)
745 {
746 if (m == null)
747 continue;
748 m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]);
749 }
750>>>>>>> avn/ubitvar
751
752 return; 699 return;
753 } 700 }
754 701
@@ -792,21 +739,13 @@ namespace OpenSim.Region.Framework.Scenes
792 float completed = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; 739 float completed = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal;
793 bool lastStep = m_currentFrame.TimeMS <= tickDuration; 740 bool lastStep = m_currentFrame.TimeMS <= tickDuration;
794 741
795 Vector3 positionThisStep = m_currentFrame.StartPosition + (m_currentFrame.Position.Value - m_currentFrame.StartPosition) * completed; 742 Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition;
796 Vector3 motionThisStep = positionThisStep - m_group.AbsolutePosition; 743 Vector3 motionThisFrame = v / (float)remainingSteps;
744 v = v * 1000 / m_currentFrame.TimeMS;
797 745
798<<<<<<< HEAD
799 float mag = Vector3.Mag(motionThisStep);
800
801 if ((mag >= 0.02f) || lastStep)
802 {
803 m_nextPosition = m_group.AbsolutePosition + motionThisStep;
804 m_group.AbsolutePosition = m_nextPosition;
805=======
806 m_nextPosition = m_group.AbsolutePosition + motionThisFrame; 746 m_nextPosition = m_group.AbsolutePosition + motionThisFrame;
807 747
808 if (Vector3.Mag(motionThisFrame) >= 0.05f) 748 if (Vector3.Mag(motionThisFrame) >= 0.05f)
809>>>>>>> avn/ubitvar
810 update = true; 749 update = true;
811 750
812 //int totalSteps = m_currentFrame.TimeTotal / (int)tickDuration; 751 //int totalSteps = m_currentFrame.TimeTotal / (int)tickDuration;
@@ -819,45 +758,6 @@ namespace OpenSim.Region.Framework.Scenes
819 758
820 Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, completed); 759 Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, completed);
821 step.Normalize(); 760 step.Normalize();
822<<<<<<< HEAD
823/* use simpler change detection
824* float angle = 0;
825
826 float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W;
827 float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W;
828 float aa_bb = aa * bb;
829
830 if (aa_bb == 0)
831 {
832 angle = 0;
833 }
834 else
835 {
836 float ab = current.X * step.X +
837 current.Y * step.Y +
838 current.Z * step.Z +
839 current.W * step.W;
840 float q = (ab * ab) / aa_bb;
841
842 if (q > 1.0f)
843 {
844 angle = 0;
845 }
846 else
847 {
848 angle = (float)Math.Acos(2 * q - 1);
849 }
850 }
851
852 if (angle > 0.01f)
853*/
854 if(Math.Abs(step.X - current.X) > 0.001f
855 || Math.Abs(step.Y - current.Y) > 0.001f
856 || Math.Abs(step.Z - current.Z) > 0.001f
857 || lastStep)
858 // assuming w is a dependente var
859
860=======
861 /* use simpler change detection 761 /* use simpler change detection
862 * float angle = 0; 762 * float angle = 0;
863 763
@@ -893,9 +793,8 @@ namespace OpenSim.Region.Framework.Scenes
893 || Math.Abs(step.Y - current.Y) > 0.001f 793 || Math.Abs(step.Y - current.Y) > 0.001f
894 || Math.Abs(step.Z - current.Z) > 0.001f) 794 || Math.Abs(step.Z - current.Z) > 0.001f)
895 // assuming w is a dependente var 795 // assuming w is a dependente var
896>>>>>>> avn/ubitvar
897 { 796 {
898 // m_group.UpdateGroupRotationR(step); 797// m_group.UpdateGroupRotationR(step);
899 m_group.RootPart.RotationOffset = step; 798 m_group.RootPart.RotationOffset = step;
900 799
901 //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); 800 //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
@@ -922,22 +821,15 @@ namespace OpenSim.Region.Framework.Scenes
922 821
923 SceneObjectGroup tmp = m_group; 822 SceneObjectGroup tmp = m_group;
924 m_group = null; 823 m_group = null;
925 if (!m_selected && tmp != null) 824
926 m_serializedPosition = tmp.AbsolutePosition;
927<<<<<<< HEAD
928=======
929 fmt.Serialize(ms, this);
930 m_group = tmp;
931 if (!timerWasStopped && m_running && !m_waitingCrossing)
932 StartTimer();
933>>>>>>> avn/ubitvar
934
935 using (MemoryStream ms = new MemoryStream()) 825 using (MemoryStream ms = new MemoryStream())
936 { 826 {
937 BinaryFormatter fmt = new BinaryFormatter(); 827 BinaryFormatter fmt = new BinaryFormatter();
828 if (!m_selected && tmp != null)
829 m_serializedPosition = tmp.AbsolutePosition;
938 fmt.Serialize(ms, this); 830 fmt.Serialize(ms, this);
939 m_group = tmp; 831 m_group = tmp;
940 if (m_running && !m_waitingCrossing) 832 if (!timerWasStopped && m_running && !m_waitingCrossing)
941 StartTimer(); 833 StartTimer();
942 834
943 return ms.ToArray(); 835 return ms.ToArray();