mantis 8250: make same changes to avatar move to target (still no new OSSL)

master
UbitUmarov 2020-05-19 15:59:53 +01:00
parent 28b22a4fc1
commit aca62392ac
4 changed files with 10 additions and 77 deletions

View File

@ -6285,71 +6285,6 @@ Environment.Exit(1);
}
}
/// This method deals with movement when an avatar is automatically moving (but this is distinct from the
/// autopilot that moves an avatar to a sit target!.
/// </summary>
/// <remarks>
/// This is not intended as a permament location for this method.
/// </remarks>
/// <param name="presence"></param>
/* move to target is now done on presence update
private void HandleOnSignificantClientMovement(ScenePresence presence)
{
if (presence.MovingToTarget)
{
double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget);
// m_log.DebugFormat(
// "[SCENE]: Abs pos of {0} is {1}, target {2}, distance {3}",
// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget);
// Check the error term of the current position in relation to the target position
if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT)
{
// We are close enough to the target
// m_log.DebugFormat("[SCENEE]: Stopping autopilot of {0}", presence.Name);
presence.Velocity = Vector3.Zero;
presence.AbsolutePosition = presence.MoveToPositionTarget;
presence.ResetMoveToTarget();
if (presence.Flying)
{
// A horrible hack to stop the avatar dead in its tracks rather than having them overshoot
// the target if flying.
// We really need to be more subtle (slow the avatar as it approaches the target) or at
// least be able to set collision status once, rather than 5 times to give it enough
// weighting so that that PhysicsActor thinks it really is colliding.
for (int i = 0; i < 5; i++)
presence.IsColliding = true;
if (presence.LandAtTarget)
presence.Flying = false;
// Vector3 targetPos = presence.MoveToPositionTarget;
// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
// if (targetPos.Z - terrainHeight < 0.2)
// {
// presence.Flying = false;
// }
}
// m_log.DebugFormat(
// "[SCENE]: AgentControlFlags {0}, MovementFlag {1} for {2}",
// presence.AgentControlFlags, presence.MovementFlag, presence.Name);
}
else
{
// m_log.DebugFormat(
// "[SCENE]: Updating npc {0} at {1} for next movement to {2}",
// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget);
Vector3 agent_control_v3 = new Vector3();
presence.HandleMoveToTargetUpdate(1, ref agent_control_v3);
presence.AddNewMovement(agent_control_v3);
}
}
}
*/
// manage and select spawn points in sequence
public int SpawnPoint()
{

View File

@ -2680,7 +2680,7 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
if (avatar != null && !avatar.IsSatOnObject)
avatar.MoveToTarget(target, false, false, tau);
avatar.MoveToTarget(target, false, false, false, tau);
}
else
{

View File

@ -3166,8 +3166,9 @@ namespace OpenSim.Region.Framework.Scenes
public void MoveToTargetHandle(Vector3 pos, bool noFly, bool landAtTarget)
{
MoveToTarget(pos, noFly, landAtTarget);
MoveToTarget(pos, noFly, false, landAtTarget);
}
/// <summary>
/// Move to the given target over time.
/// </summary>
@ -3180,7 +3181,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="landAtTarget">
/// If true and the avatar starts flying during the move then land at the target.
/// </param>
public void MoveToTarget(Vector3 pos, bool noFly, bool landAtTarget, float tau = -1f)
public void MoveToTarget(Vector3 pos, bool noFly, bool landAtTarget, bool running, float tau = -1f)
{
m_delayedStop = -1;
@ -3218,19 +3219,14 @@ namespace OpenSim.Region.Framework.Scenes
// "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}",
// Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
terrainHeight += Appearance.AvatarHeight; // so 1.5 * AvatarHeight above ground at target
bool shouldfly = Flying;
if (noFly)
shouldfly = false;
else if (pos.Z > terrainHeight || Flying)
shouldfly = true;
bool shouldfly = noFly ? false : (Flying || (pos.Z > terrainHeight + Appearance.AvatarHeight));
Vector3 localVectorToTarget3D = pos - AbsolutePosition;
// m_log.DebugFormat("[SCENE PRESENCE]: Local vector to target is {0},[1}", localVectorToTarget3D.X,localVectorToTarget3D.Y);
m_movingToTarget = true;
LandAtTarget = landAtTarget;
LandAtTarget = landAtTarget & shouldfly;
m_moveToPositionTarget = pos;
if(tau > 0)
{
@ -3245,7 +3241,10 @@ namespace OpenSim.Region.Framework.Scenes
SetAlwaysRun = false;
}
else
{
m_moveToSpeed = 4.096f * m_speedModifier;
SetAlwaysRun = running;
}
Flying = shouldfly;

View File

@ -259,8 +259,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
// sp.Name, pos, scene.RegionInfo.RegionName,
// noFly, landAtTarget);
sp.MoveToTarget(pos, noFly, landAtTarget);
sp.SetAlwaysRun = running;
sp.MoveToTarget(pos, noFly, landAtTarget, running);
return true;
}