Implement move to/autopilot for z axis movement as well.
This is jerky (an artifact of the way it's being done, I think), but it's better than on implementation.bulletsim
parent
0c23764ce2
commit
30e816bfa2
|
@ -295,7 +295,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||||
if (move.X != 0f || move.Y != 0f)
|
if (move.X != 0f || move.Y != 0f)
|
||||||
{
|
{
|
||||||
// Walking / crouchwalking / running
|
// Walking / crouchwalking / running
|
||||||
if (move.Z < 0f)
|
if (move.Z < 0)
|
||||||
return "CROUCHWALK";
|
return "CROUCHWALK";
|
||||||
else if (m_scenePresence.SetAlwaysRun)
|
else if (m_scenePresence.SetAlwaysRun)
|
||||||
return "RUN";
|
return "RUN";
|
||||||
|
@ -305,7 +305,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Not walking
|
// Not walking
|
||||||
if (move.Z < 0f)
|
if (move.Z < 0)
|
||||||
return "CROUCH";
|
return "CROUCH";
|
||||||
else
|
else
|
||||||
return "STAND";
|
return "STAND";
|
||||||
|
|
|
@ -1559,9 +1559,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)
|
||||||
|
@ -1575,7 +1575,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// move avatar in 2D at one meter/second towards target, in avatar coordinate frame.
|
// move avatar in 3D at one meter/second towards target, in avatar coordinate frame.
|
||||||
// This movement vector gets added to the velocity through AddNewMovement().
|
// This movement vector gets added to the velocity through AddNewMovement().
|
||||||
// Theoretically we might need a more complex PID approach here if other
|
// Theoretically we might need a more complex PID approach here if other
|
||||||
// unknown forces are acting on the avatar and we need to adaptively respond
|
// unknown forces are acting on the avatar and we need to adaptively respond
|
||||||
|
@ -1584,9 +1584,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
(m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords
|
(m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords
|
||||||
* Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords
|
* Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords
|
||||||
// Ignore z component of vector
|
// Ignore z component of vector
|
||||||
Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f);
|
// Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f);
|
||||||
LocalVectorToTarget2D.Normalize();
|
LocalVectorToTarget3D.Normalize();
|
||||||
agent_control_v3 += LocalVectorToTarget2D;
|
|
||||||
|
|
||||||
// update avatar movement flags. the avatar coordinate system is as follows:
|
// update avatar movement flags. the avatar coordinate system is as follows:
|
||||||
//
|
//
|
||||||
|
@ -1609,31 +1608,48 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
// based on the above avatar coordinate system, classify the movement into
|
// based on the above avatar coordinate system, classify the movement into
|
||||||
// one of left/right/back/forward.
|
// one of left/right/back/forward.
|
||||||
if (LocalVectorToTarget2D.Y > 0)//MoveLeft
|
if (LocalVectorToTarget3D.X < 0) //MoveBack
|
||||||
|
{
|
||||||
|
m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK;
|
||||||
|
AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK;
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
else if (LocalVectorToTarget3D.X > 0) //Move Forward
|
||||||
|
{
|
||||||
|
m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD;
|
||||||
|
AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD;
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LocalVectorToTarget3D.Y > 0) //MoveLeft
|
||||||
{
|
{
|
||||||
m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT;
|
m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT;
|
||||||
//AgentControlFlags
|
//AgentControlFlags
|
||||||
AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT;
|
AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT;
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
else if (LocalVectorToTarget2D.Y < 0) //MoveRight
|
else if (LocalVectorToTarget3D.Y < 0) //MoveRight
|
||||||
{
|
{
|
||||||
m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT;
|
m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT;
|
||||||
AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT;
|
AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT;
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
if (LocalVectorToTarget2D.X < 0) //MoveBack
|
|
||||||
|
if (LocalVectorToTarget3D.Z > 0) //Up
|
||||||
{
|
{
|
||||||
m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK;
|
m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP;
|
||||||
AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK;
|
//AgentControlFlags
|
||||||
|
AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP;
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
else if (LocalVectorToTarget2D.X > 0) //Move Forward
|
else if (LocalVectorToTarget3D.Z < 0) //Down
|
||||||
{
|
{
|
||||||
m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD;
|
m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN;
|
||||||
AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD;
|
AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN;
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
agent_control_v3 += LocalVectorToTarget3D;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1682,6 +1698,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
"[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);
|
||||||
|
|
||||||
|
Vector3 heightAdjust = new Vector3(0, 0, Appearance.AvatarHeight / 2);
|
||||||
|
pos += heightAdjust;
|
||||||
|
|
||||||
|
// Anti duck-walking measure
|
||||||
|
if (Math.Abs(pos.Z - AbsolutePosition.Z) < 0.2f)
|
||||||
|
pos.Z = AbsolutePosition.Z;
|
||||||
|
|
||||||
m_moveToPositionInProgress = true;
|
m_moveToPositionInProgress = true;
|
||||||
m_moveToPositionTarget = pos;
|
m_moveToPositionTarget = pos;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue