diff options
author | Justin Clark-Casey (justincc) | 2011-08-03 02:04:38 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-03 02:04:38 +0100 |
commit | 30e816bfa2fe3145a43723dfea6c4765551f5e04 (patch) | |
tree | 7d07cc16a16eeda8dd59fb5036e84c40ca90e7d4 /OpenSim/Region/Framework/Scenes | |
parent | get autopilot/go here to work immediately. (diff) | |
download | opensim-SC_OLD-30e816bfa2fe3145a43723dfea6c4765551f5e04.zip opensim-SC_OLD-30e816bfa2fe3145a43723dfea6c4765551f5e04.tar.gz opensim-SC_OLD-30e816bfa2fe3145a43723dfea6c4765551f5e04.tar.bz2 opensim-SC_OLD-30e816bfa2fe3145a43723dfea6c4765551f5e04.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 53 |
2 files changed, 40 insertions, 17 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 4865481..1334230 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -295,7 +295,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
295 | if (move.X != 0f || move.Y != 0f) | 295 | if (move.X != 0f || move.Y != 0f) |
296 | { | 296 | { |
297 | // Walking / crouchwalking / running | 297 | // Walking / crouchwalking / running |
298 | if (move.Z < 0f) | 298 | if (move.Z < 0) |
299 | return "CROUCHWALK"; | 299 | return "CROUCHWALK"; |
300 | else if (m_scenePresence.SetAlwaysRun) | 300 | else if (m_scenePresence.SetAlwaysRun) |
301 | return "RUN"; | 301 | return "RUN"; |
@@ -305,7 +305,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
305 | else | 305 | else |
306 | { | 306 | { |
307 | // Not walking | 307 | // Not walking |
308 | if (move.Z < 0f) | 308 | if (move.Z < 0) |
309 | return "CROUCH"; | 309 | return "CROUCH"; |
310 | else | 310 | else |
311 | return "STAND"; | 311 | return "STAND"; |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9c71492..7b228c6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1559,9 +1559,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1559 | if (allowUpdate && (m_moveToPositionInProgress && !m_autopilotMoving)) | 1559 | if (allowUpdate && (m_moveToPositionInProgress && !m_autopilotMoving)) |
1560 | { | 1560 | { |
1561 | double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget); | 1561 | double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget); |
1562 | // m_log.DebugFormat( | 1562 | m_log.DebugFormat( |
1563 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", | 1563 | "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", |
1564 | // Name, AbsolutePosition, m_moveToPositionTarget, distanceToTarget); | 1564 | Name, AbsolutePosition, m_moveToPositionTarget, distanceToTarget); |
1565 | 1565 | ||
1566 | // Check the error term of the current position in relation to the target position | 1566 | // Check the error term of the current position in relation to the target position |
1567 | if (distanceToTarget <= 1) | 1567 | if (distanceToTarget <= 1) |
@@ -1575,7 +1575,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1575 | { | 1575 | { |
1576 | try | 1576 | try |
1577 | { | 1577 | { |
1578 | // move avatar in 2D at one meter/second towards target, in avatar coordinate frame. | 1578 | // move avatar in 3D at one meter/second towards target, in avatar coordinate frame. |
1579 | // This movement vector gets added to the velocity through AddNewMovement(). | 1579 | // This movement vector gets added to the velocity through AddNewMovement(). |
1580 | // Theoretically we might need a more complex PID approach here if other | 1580 | // Theoretically we might need a more complex PID approach here if other |
1581 | // unknown forces are acting on the avatar and we need to adaptively respond | 1581 | // unknown forces are acting on the avatar and we need to adaptively respond |
@@ -1584,9 +1584,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1584 | (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords | 1584 | (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords |
1585 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords | 1585 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords |
1586 | // Ignore z component of vector | 1586 | // Ignore z component of vector |
1587 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1587 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
1588 | LocalVectorToTarget2D.Normalize(); | 1588 | LocalVectorToTarget3D.Normalize(); |
1589 | agent_control_v3 += LocalVectorToTarget2D; | ||
1590 | 1589 | ||
1591 | // update avatar movement flags. the avatar coordinate system is as follows: | 1590 | // update avatar movement flags. the avatar coordinate system is as follows: |
1592 | // | 1591 | // |
@@ -1609,31 +1608,48 @@ namespace OpenSim.Region.Framework.Scenes | |||
1609 | 1608 | ||
1610 | // based on the above avatar coordinate system, classify the movement into | 1609 | // based on the above avatar coordinate system, classify the movement into |
1611 | // one of left/right/back/forward. | 1610 | // one of left/right/back/forward. |
1612 | if (LocalVectorToTarget2D.Y > 0)//MoveLeft | 1611 | if (LocalVectorToTarget3D.X < 0) //MoveBack |
1612 | { | ||
1613 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | ||
1614 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | ||
1615 | updated = true; | ||
1616 | } | ||
1617 | else if (LocalVectorToTarget3D.X > 0) //Move Forward | ||
1618 | { | ||
1619 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | ||
1620 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | ||
1621 | updated = true; | ||
1622 | } | ||
1623 | |||
1624 | if (LocalVectorToTarget3D.Y > 0) //MoveLeft | ||
1613 | { | 1625 | { |
1614 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | 1626 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; |
1615 | //AgentControlFlags | 1627 | //AgentControlFlags |
1616 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | 1628 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; |
1617 | updated = true; | 1629 | updated = true; |
1618 | } | 1630 | } |
1619 | else if (LocalVectorToTarget2D.Y < 0) //MoveRight | 1631 | else if (LocalVectorToTarget3D.Y < 0) //MoveRight |
1620 | { | 1632 | { |
1621 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | 1633 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; |
1622 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | 1634 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; |
1623 | updated = true; | 1635 | updated = true; |
1624 | } | 1636 | } |
1625 | if (LocalVectorToTarget2D.X < 0) //MoveBack | 1637 | |
1638 | if (LocalVectorToTarget3D.Z > 0) //Up | ||
1626 | { | 1639 | { |
1627 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | 1640 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; |
1628 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | 1641 | //AgentControlFlags |
1642 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; | ||
1629 | updated = true; | 1643 | updated = true; |
1630 | } | 1644 | } |
1631 | else if (LocalVectorToTarget2D.X > 0) //Move Forward | 1645 | else if (LocalVectorToTarget3D.Z < 0) //Down |
1632 | { | 1646 | { |
1633 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | 1647 | m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; |
1634 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | 1648 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; |
1635 | updated = true; | 1649 | updated = true; |
1636 | } | 1650 | } |
1651 | |||
1652 | agent_control_v3 += LocalVectorToTarget3D; | ||
1637 | } | 1653 | } |
1638 | catch (Exception e) | 1654 | catch (Exception e) |
1639 | { | 1655 | { |
@@ -1682,6 +1698,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1682 | "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", | 1698 | "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", |
1683 | Name, pos, m_scene.RegionInfo.RegionName); | 1699 | Name, pos, m_scene.RegionInfo.RegionName); |
1684 | 1700 | ||
1701 | Vector3 heightAdjust = new Vector3(0, 0, Appearance.AvatarHeight / 2); | ||
1702 | pos += heightAdjust; | ||
1703 | |||
1704 | // Anti duck-walking measure | ||
1705 | if (Math.Abs(pos.Z - AbsolutePosition.Z) < 0.2f) | ||
1706 | pos.Z = AbsolutePosition.Z; | ||
1707 | |||
1685 | m_moveToPositionInProgress = true; | 1708 | m_moveToPositionInProgress = true; |
1686 | m_moveToPositionTarget = pos; | 1709 | m_moveToPositionTarget = pos; |
1687 | 1710 | ||