diff options
author | Justin Clark-Casey (justincc) | 2011-08-03 04:19:19 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-03 04:19:19 +0100 |
commit | 6e4ec2972266ae250337867fe1ba1944131f212d (patch) | |
tree | db0d334a9d0cc871bbdd83b86d703260befa25b5 /OpenSim/Region/Framework | |
parent | Improve z axis move to/autopilot so the avatar does alternative crouch/huzzah... (diff) | |
download | opensim-SC_OLD-6e4ec2972266ae250337867fe1ba1944131f212d.zip opensim-SC_OLD-6e4ec2972266ae250337867fe1ba1944131f212d.tar.gz opensim-SC_OLD-6e4ec2972266ae250337867fe1ba1944131f212d.tar.bz2 opensim-SC_OLD-6e4ec2972266ae250337867fe1ba1944131f212d.tar.xz |
Do a partial fix/implementation of OSSL osNpcMoveTo()
Avatar moves and stops. However, will stop in mid stride.
And if the move to position is in the air, avatar will continue to make vain and quite hilarious attempts to take off (but never doing so).
Clearly more work is needed.
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/EventManager.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 37 |
2 files changed, 29 insertions, 19 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index b67937d..96da2c3 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -165,8 +165,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
165 | public delegate void AvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID); | 165 | public delegate void AvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID); |
166 | public event AvatarEnteringNewParcel OnAvatarEnteringNewParcel; | 166 | public event AvatarEnteringNewParcel OnAvatarEnteringNewParcel; |
167 | 167 | ||
168 | public delegate void SignificantClientMovement(IClientAPI remote_client); | 168 | public event Action<ScenePresence> OnSignificantClientMovement; |
169 | public event SignificantClientMovement OnSignificantClientMovement; | ||
170 | 169 | ||
171 | public delegate void IncomingInstantMessage(GridInstantMessage message); | 170 | public delegate void IncomingInstantMessage(GridInstantMessage message); |
172 | public event IncomingInstantMessage OnIncomingInstantMessage; | 171 | public event IncomingInstantMessage OnIncomingInstantMessage; |
@@ -1592,16 +1591,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1592 | } | 1591 | } |
1593 | } | 1592 | } |
1594 | 1593 | ||
1595 | public void TriggerSignificantClientMovement(IClientAPI client) | 1594 | public void TriggerSignificantClientMovement(ScenePresence presence) |
1596 | { | 1595 | { |
1597 | SignificantClientMovement handlerSignificantClientMovement = OnSignificantClientMovement; | 1596 | Action<ScenePresence> handlerSignificantClientMovement = OnSignificantClientMovement; |
1598 | if (handlerSignificantClientMovement != null) | 1597 | if (handlerSignificantClientMovement != null) |
1599 | { | 1598 | { |
1600 | foreach (SignificantClientMovement d in handlerSignificantClientMovement.GetInvocationList()) | 1599 | foreach (Action<ScenePresence> d in handlerSignificantClientMovement.GetInvocationList()) |
1601 | { | 1600 | { |
1602 | try | 1601 | try |
1603 | { | 1602 | { |
1604 | d(client); | 1603 | d(presence); |
1605 | } | 1604 | } |
1606 | catch (Exception e) | 1605 | catch (Exception e) |
1607 | { | 1606 | { |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a610b6b..9558258 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -211,7 +211,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
211 | 211 | ||
212 | //PauPaw:Proper PID Controler for autopilot************ | 212 | //PauPaw:Proper PID Controler for autopilot************ |
213 | private bool m_moveToPositionInProgress; | 213 | private bool m_moveToPositionInProgress; |
214 | private Vector3 m_moveToPositionTarget; | 214 | |
215 | public Vector3 MoveToPositionTarget { get; private set; } | ||
215 | 216 | ||
216 | private bool m_followCamAuto; | 217 | private bool m_followCamAuto; |
217 | 218 | ||
@@ -1385,7 +1386,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1385 | if (agentData.UseClientAgentPosition) | 1386 | if (agentData.UseClientAgentPosition) |
1386 | { | 1387 | { |
1387 | m_moveToPositionInProgress = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; | 1388 | m_moveToPositionInProgress = (agentData.ClientAgentPosition - AbsolutePosition).Length() > 0.2f; |
1388 | m_moveToPositionTarget = agentData.ClientAgentPosition; | 1389 | MoveToPositionTarget = agentData.ClientAgentPosition; |
1389 | } | 1390 | } |
1390 | 1391 | ||
1391 | int i = 0; | 1392 | int i = 0; |
@@ -1543,16 +1544,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1543 | /// <param value="reset">If true, clear the move to position</param> | 1544 | /// <param value="reset">If true, clear the move to position</param> |
1544 | /// <param value="allowUpdate">If true, allow the update in principle.</param> | 1545 | /// <param value="allowUpdate">If true, allow the update in principle.</param> |
1545 | /// <returns>True if movement has been updated in some way. False otherwise.</returns> | 1546 | /// <returns>True if movement has been updated in some way. False otherwise.</returns> |
1546 | protected bool DoMoveToPositionUpdate( | 1547 | public bool DoMoveToPositionUpdate( |
1547 | ref Vector3 agent_control_v3, Quaternion bodyRotation, bool reset, bool allowUpdate) | 1548 | ref Vector3 agent_control_v3, Quaternion bodyRotation, bool reset, bool allowUpdate) |
1548 | { | 1549 | { |
1550 | // m_log.DebugFormat("[SCENE PRESENCE]: Called DoMoveToPositionUpdate() for {0}", Name); | ||
1551 | |||
1549 | bool updated = false; | 1552 | bool updated = false; |
1550 | 1553 | ||
1551 | //Paupaw:Do Proper PID for Autopilot here | 1554 | //Paupaw:Do Proper PID for Autopilot here |
1552 | if (reset) | 1555 | if (reset) |
1553 | { | 1556 | { |
1554 | m_moveToPositionTarget = Vector3.Zero; | 1557 | ResetMoveToPosition(); |
1555 | m_moveToPositionInProgress = false; | ||
1556 | updated = true; | 1558 | updated = true; |
1557 | } | 1559 | } |
1558 | 1560 | ||
@@ -1562,16 +1564,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1562 | 1564 | ||
1563 | if (allowUpdate && (m_moveToPositionInProgress && !m_autopilotMoving)) | 1565 | if (allowUpdate && (m_moveToPositionInProgress && !m_autopilotMoving)) |
1564 | { | 1566 | { |
1565 | double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget); | 1567 | double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); |
1566 | // m_log.DebugFormat( | 1568 | m_log.DebugFormat( |
1567 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", | 1569 | "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", |
1568 | // Name, AbsolutePosition, m_moveToPositionTarget, distanceToTarget); | 1570 | Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); |
1569 | 1571 | ||
1570 | // Check the error term of the current position in relation to the target position | 1572 | // Check the error term of the current position in relation to the target position |
1571 | if (distanceToTarget <= 1) | 1573 | if (distanceToTarget <= 1) |
1572 | { | 1574 | { |
1573 | // We are close enough to the target | 1575 | // We are close enough to the target |
1574 | m_moveToPositionTarget = Vector3.Zero; | 1576 | MoveToPositionTarget = Vector3.Zero; |
1575 | m_moveToPositionInProgress = false; | 1577 | m_moveToPositionInProgress = false; |
1576 | updated = true; | 1578 | updated = true; |
1577 | } | 1579 | } |
@@ -1585,7 +1587,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1585 | // unknown forces are acting on the avatar and we need to adaptively respond | 1587 | // unknown forces are acting on the avatar and we need to adaptively respond |
1586 | // to such forces, but the following simple approach seems to works fine. | 1588 | // to such forces, but the following simple approach seems to works fine. |
1587 | Vector3 LocalVectorToTarget3D = | 1589 | Vector3 LocalVectorToTarget3D = |
1588 | (m_moveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords | 1590 | (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords |
1589 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords | 1591 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(bodyRotation)); // change to avatar coords |
1590 | // Ignore z component of vector | 1592 | // Ignore z component of vector |
1591 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1593 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
@@ -1718,13 +1720,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1718 | } | 1720 | } |
1719 | 1721 | ||
1720 | m_moveToPositionInProgress = true; | 1722 | m_moveToPositionInProgress = true; |
1721 | m_moveToPositionTarget = pos; | 1723 | MoveToPositionTarget = pos; |
1722 | 1724 | ||
1723 | Vector3 agent_control_v3 = new Vector3(); | 1725 | Vector3 agent_control_v3 = new Vector3(); |
1724 | DoMoveToPositionUpdate(ref agent_control_v3, Rotation, false, true); | 1726 | DoMoveToPositionUpdate(ref agent_control_v3, Rotation, false, true); |
1725 | AddNewMovement(agent_control_v3, Rotation); | 1727 | AddNewMovement(agent_control_v3, Rotation); |
1726 | } | 1728 | } |
1727 | 1729 | ||
1730 | /// <summary> | ||
1731 | /// Reset the move to position. | ||
1732 | /// </summary> | ||
1733 | public void ResetMoveToPosition() | ||
1734 | { | ||
1735 | MoveToPositionTarget = Vector3.Zero; | ||
1736 | m_moveToPositionInProgress = false; | ||
1737 | } | ||
1738 | |||
1728 | private void CheckAtSitTarget() | 1739 | private void CheckAtSitTarget() |
1729 | { | 1740 | { |
1730 | //m_log.Debug("[AUTOPILOT]: " + Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget).ToString()); | 1741 | //m_log.Debug("[AUTOPILOT]: " + Util.GetDistanceTo(AbsolutePosition, m_autoPilotTarget).ToString()); |
@@ -2731,7 +2742,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2731 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) | 2742 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) |
2732 | { | 2743 | { |
2733 | posLastSignificantMove = AbsolutePosition; | 2744 | posLastSignificantMove = AbsolutePosition; |
2734 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); | 2745 | m_scene.EventManager.TriggerSignificantClientMovement(this); |
2735 | } | 2746 | } |
2736 | 2747 | ||
2737 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m | 2748 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m |