aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-03 02:59:49 +0100
committerJustin Clark-Casey (justincc)2011-08-03 02:59:49 +0100
commit68a5fe04318fed4b306e8405861203c19a313a2f (patch)
tree866cda5d1890ddf5758c146d3756be9480ee053e
parentImplement move to/autopilot for z axis movement as well. (diff)
downloadopensim-SC_OLD-68a5fe04318fed4b306e8405861203c19a313a2f.zip
opensim-SC_OLD-68a5fe04318fed4b306e8405861203c19a313a2f.tar.gz
opensim-SC_OLD-68a5fe04318fed4b306e8405861203c19a313a2f.tar.bz2
opensim-SC_OLD-68a5fe04318fed4b306e8405861203c19a313a2f.tar.xz
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 thing
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs34
2 files changed, 30 insertions, 12 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index 1334230..4ab818f 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -27,6 +27,8 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
30using OpenMetaverse; 32using OpenMetaverse;
31using OpenSim.Framework; 33using OpenSim.Framework;
32using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
@@ -40,6 +42,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
40 /// </summary> 42 /// </summary>
41 public class ScenePresenceAnimator 43 public class ScenePresenceAnimator
42 { 44 {
45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
43 public AnimationSet Animations 47 public AnimationSet Animations
44 { 48 {
45 get { return m_animations; } 49 get { return m_animations; }
@@ -262,7 +266,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
262 266
263 m_animTickFall = 0; 267 m_animTickFall = 0;
264 268
265 if (move.Z > 0f) 269 if (move.Z > 0.2f)
266 { 270 {
267 // Jumping 271 // Jumping
268 if (!jumping) 272 if (!jumping)
@@ -323,6 +327,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
323 public void UpdateMovementAnimations() 327 public void UpdateMovementAnimations()
324 { 328 {
325 m_movementAnimation = GetMovementAnimation(); 329 m_movementAnimation = GetMovementAnimation();
330// m_log.DebugFormat(
331// "[SCENE PRESENCE ANIMATOR]: Got animation {0} for {1}", m_movementAnimation, m_scenePresence.Name);
326 TrySetMovementAnimation(m_movementAnimation); 332 TrySetMovementAnimation(m_movementAnimation);
327 } 333 }
328 334
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 7b228c6..a610b6b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1522,7 +1522,11 @@ namespace OpenSim.Region.Framework.Scenes
1522 AddNewMovement(agent_control_v3, q); 1522 AddNewMovement(agent_control_v3, q);
1523 } 1523 }
1524 1524
1525 if (update_movementflag && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) && (m_parentID == 0) && !SitGround) 1525 if (update_movementflag
1526 && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0)
1527 && (m_parentID == 0)
1528 && !SitGround
1529 && !m_moveToPositionInProgress)
1526 Animator.UpdateMovementAnimations(); 1530 Animator.UpdateMovementAnimations();
1527 } 1531 }
1528 1532
@@ -1559,9 +1563,9 @@ namespace OpenSim.Region.Framework.Scenes
1559 if (allowUpdate && (m_moveToPositionInProgress && !m_autopilotMoving)) 1563 if (allowUpdate && (m_moveToPositionInProgress && !m_autopilotMoving))
1560 { 1564 {
1561 double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget); 1565 double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget);
1562 m_log.DebugFormat( 1566// m_log.DebugFormat(
1563 "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", 1567// "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}",
1564 Name, AbsolutePosition, m_moveToPositionTarget, distanceToTarget); 1568// Name, AbsolutePosition, m_moveToPositionTarget, distanceToTarget);
1565 1569
1566 // Check the error term of the current position in relation to the target position 1570 // Check the error term of the current position in relation to the target position
1567 if (distanceToTarget <= 1) 1571 if (distanceToTarget <= 1)
@@ -1637,15 +1641,15 @@ namespace OpenSim.Region.Framework.Scenes
1637 1641
1638 if (LocalVectorToTarget3D.Z > 0) //Up 1642 if (LocalVectorToTarget3D.Z > 0) //Up
1639 { 1643 {
1640 m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; 1644 //m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP;
1641 //AgentControlFlags 1645 //AgentControlFlags
1642 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP; 1646 //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_UP;
1643 updated = true; 1647 updated = true;
1644 } 1648 }
1645 else if (LocalVectorToTarget3D.Z < 0) //Down 1649 else if (LocalVectorToTarget3D.Z < 0) //Down
1646 { 1650 {
1647 m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; 1651 //m_movementflag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN;
1648 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN; 1652 //AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN;
1649 updated = true; 1653 updated = true;
1650 } 1654 }
1651 1655
@@ -1694,16 +1698,24 @@ namespace OpenSim.Region.Framework.Scenes
1694 /// <param name="pos"></param> 1698 /// <param name="pos"></param>
1695 public void DoMoveToPosition(uint not_used, Vector3 pos, IClientAPI remote_client) 1699 public void DoMoveToPosition(uint not_used, Vector3 pos, IClientAPI remote_client)
1696 { 1700 {
1697 m_log.DebugFormat( 1701// m_log.DebugFormat(
1698 "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", 1702// "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}",
1699 Name, pos, m_scene.RegionInfo.RegionName); 1703// Name, pos, m_scene.RegionInfo.RegionName);
1704
1705 if (pos.X < 0 || pos.X >= Constants.RegionSize
1706 || pos.Y < 0 || pos.Y >= Constants.RegionSize
1707 || pos.Z < 0)
1708 return;
1700 1709
1701 Vector3 heightAdjust = new Vector3(0, 0, Appearance.AvatarHeight / 2); 1710 Vector3 heightAdjust = new Vector3(0, 0, Appearance.AvatarHeight / 2);
1702 pos += heightAdjust; 1711 pos += heightAdjust;
1703 1712
1704 // Anti duck-walking measure 1713 // Anti duck-walking measure
1705 if (Math.Abs(pos.Z - AbsolutePosition.Z) < 0.2f) 1714 if (Math.Abs(pos.Z - AbsolutePosition.Z) < 0.2f)
1715 {
1716// m_log.DebugFormat("[SCENE PRESENCE]: Adjusting MoveToPosition from {0} to {1}", pos, AbsolutePosition);
1706 pos.Z = AbsolutePosition.Z; 1717 pos.Z = AbsolutePosition.Z;
1718 }
1707 1719
1708 m_moveToPositionInProgress = true; 1720 m_moveToPositionInProgress = true;
1709 m_moveToPositionTarget = pos; 1721 m_moveToPositionTarget = pos;