Improve z axis move to/autopilot so the avatar does alternative crouch/huzzah when walking along the ground
Moving a flying avatar to a ground point doesn't yet land the avatar. This may or may not be the best thingbulletsim
parent
30e816bfa2
commit
68a5fe0431
|
@ -27,6 +27,8 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using log4net;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
@ -40,6 +42,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ScenePresenceAnimator
|
public class ScenePresenceAnimator
|
||||||
{
|
{
|
||||||
|
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
public AnimationSet Animations
|
public AnimationSet Animations
|
||||||
{
|
{
|
||||||
get { return m_animations; }
|
get { return m_animations; }
|
||||||
|
@ -262,7 +266,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||||
|
|
||||||
m_animTickFall = 0;
|
m_animTickFall = 0;
|
||||||
|
|
||||||
if (move.Z > 0f)
|
if (move.Z > 0.2f)
|
||||||
{
|
{
|
||||||
// Jumping
|
// Jumping
|
||||||
if (!jumping)
|
if (!jumping)
|
||||||
|
@ -323,6 +327,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||||
public void UpdateMovementAnimations()
|
public void UpdateMovementAnimations()
|
||||||
{
|
{
|
||||||
m_movementAnimation = GetMovementAnimation();
|
m_movementAnimation = GetMovementAnimation();
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[SCENE PRESENCE ANIMATOR]: Got animation {0} for {1}", m_movementAnimation, m_scenePresence.Name);
|
||||||
TrySetMovementAnimation(m_movementAnimation);
|
TrySetMovementAnimation(m_movementAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1522,7 +1522,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
AddNewMovement(agent_control_v3, q);
|
AddNewMovement(agent_control_v3, q);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update_movementflag && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) && (m_parentID == 0) && !SitGround)
|
if (update_movementflag
|
||||||
|
&& ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0)
|
||||||
|
&& (m_parentID == 0)
|
||||||
|
&& !SitGround
|
||||||
|
&& !m_moveToPositionInProgress)
|
||||||
Animator.UpdateMovementAnimations();
|
Animator.UpdateMovementAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1559,9 +1563,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (allowUpdate && (m_moveToPositionInProgress && !m_autopilotMoving))
|
if (allowUpdate && (m_moveToPositionInProgress && !m_autopilotMoving))
|
||||||
{
|
{
|
||||||
double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget);
|
double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget);
|
||||||
m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
"[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}",
|
// "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}",
|
||||||
Name, AbsolutePosition, m_moveToPositionTarget, distanceToTarget);
|
// Name, AbsolutePosition, m_moveToPositionTarget, distanceToTarget);
|
||||||
|
|
||||||
// Check the error term of the current position in relation to the target position
|
// Check the error term of the current position in relation to the target position
|
||||||
if (distanceToTarget <= 1)
|
if (distanceToTarget <= 1)
|
||||||
|
@ -1637,15 +1641,15 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
if (LocalVectorToTarget3D.Z > 0) //Up
|
if (LocalVectorToTarget3D.Z > 0) //Up
|
||||||
{
|
{
|
||||||
m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP;
|
//m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP;
|
||||||
//AgentControlFlags
|
//AgentControlFlags
|
||||||
AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP;
|
//AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP;
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
else if (LocalVectorToTarget3D.Z < 0) //Down
|
else if (LocalVectorToTarget3D.Z < 0) //Down
|
||||||
{
|
{
|
||||||
m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN;
|
//m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN;
|
||||||
AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN;
|
//AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN;
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1694,16 +1698,24 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="pos"></param>
|
/// <param name="pos"></param>
|
||||||
public void DoMoveToPosition(uint not_used, Vector3 pos, IClientAPI remote_client)
|
public void DoMoveToPosition(uint not_used, Vector3 pos, IClientAPI remote_client)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
"[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}",
|
// "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}",
|
||||||
Name, pos, m_scene.RegionInfo.RegionName);
|
// Name, pos, m_scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
|
if (pos.X < 0 || pos.X >= Constants.RegionSize
|
||||||
|
|| pos.Y < 0 || pos.Y >= Constants.RegionSize
|
||||||
|
|| pos.Z < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
Vector3 heightAdjust = new Vector3(0, 0, Appearance.AvatarHeight / 2);
|
Vector3 heightAdjust = new Vector3(0, 0, Appearance.AvatarHeight / 2);
|
||||||
pos += heightAdjust;
|
pos += heightAdjust;
|
||||||
|
|
||||||
// Anti duck-walking measure
|
// Anti duck-walking measure
|
||||||
if (Math.Abs(pos.Z - AbsolutePosition.Z) < 0.2f)
|
if (Math.Abs(pos.Z - AbsolutePosition.Z) < 0.2f)
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat("[SCENE PRESENCE]: Adjusting MoveToPosition from {0} to {1}", pos, AbsolutePosition);
|
||||||
pos.Z = AbsolutePosition.Z;
|
pos.Z = AbsolutePosition.Z;
|
||||||
|
}
|
||||||
|
|
||||||
m_moveToPositionInProgress = true;
|
m_moveToPositionInProgress = true;
|
||||||
m_moveToPositionTarget = pos;
|
m_moveToPositionTarget = pos;
|
||||||
|
|
Loading…
Reference in New Issue