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()
ghosts
Justin Clark-Casey (justincc) 2014-09-02 23:35:03 +01:00
parent cd6f73392a
commit 3c7eacf39b
2 changed files with 28 additions and 18 deletions

View File

@ -608,8 +608,11 @@ namespace OpenSim.Region.Framework.Scenes
} }
/// <summary> /// <summary>
/// Current velocity of the avatar. /// Velocity of the avatar with respect to its local reference frame.
/// </summary> /// </summary>
/// <remarks>
/// So when sat on a vehicle this will be 0. To get velocity with respect to the world use GetWorldVelocity()
/// </remarks>
public override Vector3 Velocity public override Vector3 Velocity
{ {
get get
@ -622,10 +625,10 @@ namespace OpenSim.Region.Framework.Scenes
// "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!",
// m_velocity, Name, Scene.RegionInfo.RegionName); // m_velocity, Name, Scene.RegionInfo.RegionName);
} }
else if (ParentPart != null) // else if (ParentPart != null)
{ // {
return ParentPart.ParentGroup.Velocity; // return ParentPart.ParentGroup.Velocity;
} // }
return m_velocity; return m_velocity;
} }
@ -749,25 +752,32 @@ namespace OpenSim.Region.Framework.Scenes
} }
/// <summary> /// <summary>
/// Gets the world rotation of this presence. /// Get rotation relative to the world.
/// </summary> /// </summary>
/// <remarks>
/// Unlike Rotation, this returns the world rotation no matter whether the avatar is sitting on a prim or not.
/// </remarks>
/// <returns></returns> /// <returns></returns>
public Quaternion GetWorldRotation() public Quaternion GetWorldRotation()
{
if (IsSatOnObject)
{ {
SceneObjectPart sitPart = ParentPart; SceneObjectPart sitPart = ParentPart;
if (sitPart != null) if (sitPart != null)
return sitPart.GetWorldRotation() * Rotation; return sitPart.GetWorldRotation() * Rotation;
}
return Rotation; return Rotation;
} }
/// <summary>
/// Get velocity relative to the world.
/// </summary>
public Vector3 GetWorldVelocity()
{
SceneObjectPart sitPart = ParentPart;
if (sitPart != null)
return sitPart.ParentGroup.Velocity;
return Velocity;
}
public void AdjustKnownSeeds() public void AdjustKnownSeeds()
{ {
Dictionary<ulong, string> seeds; Dictionary<ulong, string> seeds;

View File

@ -2560,7 +2560,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (m_host.ParentGroup.IsAttachment) if (m_host.ParentGroup.IsAttachment)
{ {
ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar);
vel = avatar.Velocity; vel = avatar.GetWorldVelocity();
} }
else else
{ {
@ -11221,7 +11221,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ret.Add(new LSL_Rotation(av.GetWorldRotation())); ret.Add(new LSL_Rotation(av.GetWorldRotation()));
break; break;
case ScriptBaseClass.OBJECT_VELOCITY: case ScriptBaseClass.OBJECT_VELOCITY:
ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z)); ret.Add(new LSL_Vector(av.GetWorldVelocity()));
break; break;
case ScriptBaseClass.OBJECT_OWNER: case ScriptBaseClass.OBJECT_OWNER:
ret.Add(new LSL_String(id)); ret.Add(new LSL_String(id));
@ -11342,7 +11342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence sp = World.GetScenePresence(obj.ParentGroup.AttachedAvatar); ScenePresence sp = World.GetScenePresence(obj.ParentGroup.AttachedAvatar);
if (sp != null) if (sp != null)
vel = sp.Velocity; vel = sp.GetWorldVelocity();
} }
else else
{ {