aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-09-02 23:35:03 +0100
committerJustin Clark-Casey (justincc)2014-09-02 23:39:52 +0100
commitd582db6132ef7bea8b15e7a9f0dd64400d43b517 (patch)
treea277f69574ae09020245e4fa3a3f58cb59dceacf /OpenSim/Region
parentAs per the LL grid, if an avatar is sitting then return it's velocity relativ... (diff)
downloadopensim-SC_OLD-d582db6132ef7bea8b15e7a9f0dd64400d43b517.zip
opensim-SC_OLD-d582db6132ef7bea8b15e7a9f0dd64400d43b517.tar.gz
opensim-SC_OLD-d582db6132ef7bea8b15e7a9f0dd64400d43b517.tar.bz2
opensim-SC_OLD-d582db6132ef7bea8b15e7a9f0dd64400d43b517.tar.xz
Fix recent regression from 473c5594 where camera started to judder on moving vehicles.
Other parts of OpenSimulator are relying on SP.Velocity == 0 for vehicles. So add and use SP.GetWorldVelocity() instead when we need vehicle velocity, along the same lines as existing SP.GetWorldRotation()
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs40
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs6
2 files changed, 28 insertions, 18 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index e0b7640..f2a636a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -608,8 +608,11 @@ namespace OpenSim.Region.Framework.Scenes
608 } 608 }
609 609
610 /// <summary> 610 /// <summary>
611 /// Current velocity of the avatar. 611 /// Velocity of the avatar with respect to its local reference frame.
612 /// </summary> 612 /// </summary>
613 /// <remarks>
614 /// So when sat on a vehicle this will be 0. To get velocity with respect to the world use GetWorldVelocity()
615 /// </remarks>
613 public override Vector3 Velocity 616 public override Vector3 Velocity
614 { 617 {
615 get 618 get
@@ -622,10 +625,10 @@ namespace OpenSim.Region.Framework.Scenes
622// "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", 625// "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!",
623// m_velocity, Name, Scene.RegionInfo.RegionName); 626// m_velocity, Name, Scene.RegionInfo.RegionName);
624 } 627 }
625 else if (ParentPart != null) 628// else if (ParentPart != null)
626 { 629// {
627 return ParentPart.ParentGroup.Velocity; 630// return ParentPart.ParentGroup.Velocity;
628 } 631// }
629 632
630 return m_velocity; 633 return m_velocity;
631 } 634 }
@@ -749,25 +752,32 @@ namespace OpenSim.Region.Framework.Scenes
749 } 752 }
750 753
751 /// <summary> 754 /// <summary>
752 /// Gets the world rotation of this presence. 755 /// Get rotation relative to the world.
753 /// </summary> 756 /// </summary>
754 /// <remarks>
755 /// Unlike Rotation, this returns the world rotation no matter whether the avatar is sitting on a prim or not.
756 /// </remarks>
757 /// <returns></returns> 757 /// <returns></returns>
758 public Quaternion GetWorldRotation() 758 public Quaternion GetWorldRotation()
759 { 759 {
760 if (IsSatOnObject) 760 SceneObjectPart sitPart = ParentPart;
761 {
762 SceneObjectPart sitPart = ParentPart;
763 761
764 if (sitPart != null) 762 if (sitPart != null)
765 return sitPart.GetWorldRotation() * Rotation; 763 return sitPart.GetWorldRotation() * Rotation;
766 }
767 764
768 return Rotation; 765 return Rotation;
769 } 766 }
770 767
768 /// <summary>
769 /// Get velocity relative to the world.
770 /// </summary>
771 public Vector3 GetWorldVelocity()
772 {
773 SceneObjectPart sitPart = ParentPart;
774
775 if (sitPart != null)
776 return sitPart.ParentGroup.Velocity;
777
778 return Velocity;
779 }
780
771 public void AdjustKnownSeeds() 781 public void AdjustKnownSeeds()
772 { 782 {
773 Dictionary<ulong, string> seeds; 783 Dictionary<ulong, string> seeds;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 5d7fc9d..7c384b2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2560,7 +2560,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2560 if (m_host.ParentGroup.IsAttachment) 2560 if (m_host.ParentGroup.IsAttachment)
2561 { 2561 {
2562 ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); 2562 ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar);
2563 vel = avatar.Velocity; 2563 vel = avatar.GetWorldVelocity();
2564 } 2564 }
2565 else 2565 else
2566 { 2566 {
@@ -11221,7 +11221,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11221 ret.Add(new LSL_Rotation(av.GetWorldRotation())); 11221 ret.Add(new LSL_Rotation(av.GetWorldRotation()));
11222 break; 11222 break;
11223 case ScriptBaseClass.OBJECT_VELOCITY: 11223 case ScriptBaseClass.OBJECT_VELOCITY:
11224 ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z)); 11224 ret.Add(new LSL_Vector(av.GetWorldVelocity()));
11225 break; 11225 break;
11226 case ScriptBaseClass.OBJECT_OWNER: 11226 case ScriptBaseClass.OBJECT_OWNER:
11227 ret.Add(new LSL_String(id)); 11227 ret.Add(new LSL_String(id));
@@ -11342,7 +11342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11342 ScenePresence sp = World.GetScenePresence(obj.ParentGroup.AttachedAvatar); 11342 ScenePresence sp = World.GetScenePresence(obj.ParentGroup.AttachedAvatar);
11343 11343
11344 if (sp != null) 11344 if (sp != null)
11345 vel = sp.Velocity; 11345 vel = sp.GetWorldVelocity();
11346 } 11346 }
11347 else 11347 else
11348 { 11348 {