From f26ad07ce122c43465b9503e36ce3191316a3777 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 3 Jun 2017 07:01:07 +0100 Subject: [PATCH] add a delayed stop so fast tap on move keys does not stop the avatar in some cases --- .../Region/Framework/Scenes/ScenePresence.cs | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cec21d8337..ed9cf53535 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -364,6 +364,7 @@ namespace OpenSim.Region.Framework.Scenes //PauPaw:Proper PID Controler for autopilot************ public bool MovingToTarget { get; private set; } public Vector3 MoveToPositionTarget { get; private set; } + private double m_delayedStop = -1.0; /// /// Controls whether an avatar automatically moving to a target will land when it gets there (if flying). @@ -2732,7 +2733,6 @@ namespace OpenSim.Region.Framework.Scenes agent_control_v3.Z = 0; // else if(AgentControlStopActive %% Velocity.Z <0.01f) - // m_log.DebugFormat("[SCENE PRESENCE]: MovementFlag {0} for {1}", MovementFlag, Name); // If the agent update does move the avatar, then calculate the force ready for the velocity update, @@ -2741,6 +2741,7 @@ namespace OpenSim.Region.Framework.Scenes // held down AGENT_CONTROL_STOP whilst normal walking/running). However, we do not want to update // if the user rotated whilst holding down AGENT_CONTROL_STOP when already still (which locks the // avatar location in place). + if (update_movementflag || (update_rotation && DCFlagKeyPressed && (!AgentControlStopActive || MovementFlag != 0))) { @@ -2757,12 +2758,22 @@ namespace OpenSim.Region.Framework.Scenes } else { - AddNewMovement(agent_control_v3); + if(MovingToTarget || + (Animator.currentControlState != ScenePresenceAnimator.motionControlStates.flying && + Animator.currentControlState != ScenePresenceAnimator.motionControlStates.onsurface) + ) + AddNewMovement(agent_control_v3); + else + { + if (MovementFlag != 0) + AddNewMovement(agent_control_v3); + else + m_delayedStop = Util.GetTimeStampMS() + 200.0; + } } - } - if (update_movementflag && ParentID == 0) + if (update_movementflag && ParentID == 0 && m_delayedStop < 0) { // m_log.DebugFormat("[SCENE PRESENCE]: Updating movement animations for {0}", Name); Animator.UpdateMovementAnimations(); @@ -3016,6 +3027,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void MoveToTarget(Vector3 pos, bool noFly, bool landAtTarget) { + m_delayedStop = -1; + if (SitGround) StandUp(); @@ -3671,7 +3684,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat( // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", // vec, Rotation, thisAddSpeedModifier, Name); - + m_delayedStop = -1; // rotate from avatar coord space to world Quaternion rot = Rotation; if (!Flying && PresenceType != PresenceType.Npc) @@ -3689,7 +3702,7 @@ namespace OpenSim.Region.Framework.Scenes direc.Z = 0f; // Prevent camera WASD up. // odd rescalings - direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier; + direc *= 0.032f * 128f * SpeedModifier * thisAddSpeedModifier; // m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); @@ -3754,10 +3767,19 @@ namespace OpenSim.Region.Framework.Scenes if(MovingToTarget) { + m_delayedStop = -1; Vector3 control = Vector3.Zero; if(HandleMoveToTargetUpdate(1f, ref control)) AddNewMovement(control); } + else if(m_delayedStop > 0) + { + if(IsSatOnObject) + m_delayedStop = -1; + else + if(Util.GetTimeStampMS() > m_delayedStop) + AddNewMovement(Vector3.Zero); + } if (Appearance.AvatarSize != m_lastSize) SendAvatarDataToAllAgents();