diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs index 1023108661..b53806c651 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/tests/Remote.cs @@ -169,7 +169,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory.Tests float y = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Y]); float z = Convert.ToSingle(rdata.Parameters[PARM_MOVE_Z]); Vector3 vector = new Vector3(x, y, z); - presence.MoveToTarget(vector, false); + presence.MoveToTarget(vector, false, false); } catch (Exception e) { diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index ee3d6b6fde..cdd50d0222 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -940,7 +940,7 @@ namespace OpenSim.Framework event ScriptReset OnScriptReset; event GetScriptRunning OnGetScriptRunning; event SetScriptRunning OnSetScriptRunning; - event Action OnAutoPilotGo; + event Action OnAutoPilotGo; event TerrainUnacked OnUnackedTerrain; event ActivateGesture OnActivateGesture; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 37024fd5db..243dad5e7c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -232,7 +232,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event ScriptReset OnScriptReset; public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; - public event Action OnAutoPilotGo; + public event Action OnAutoPilotGo; public event TerrainUnacked OnUnackedTerrain; public event ActivateGesture OnActivateGesture; public event DeactivateGesture OnDeactivateGesture; @@ -11756,9 +11756,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP locy = Convert.ToSingle(args[1]) - (float)regionY; locz = Convert.ToSingle(args[2]); - Action handlerAutoPilotGo = OnAutoPilotGo; + Action handlerAutoPilotGo = OnAutoPilotGo; if (handlerAutoPilotGo != null) - handlerAutoPilotGo(new Vector3(locx, locy, locz), false); + handlerAutoPilotGo(new Vector3(locx, locy, locz), false, false); } /// diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 3b740e24e4..54c1c21a61 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -222,7 +222,7 @@ namespace OpenSim.Region.Examples.SimpleModule public event ScriptReset OnScriptReset; public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; - public event Action OnAutoPilotGo; + public event Action OnAutoPilotGo; public event TerrainUnacked OnUnackedTerrain; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fc89b2a5ab..01ab199c19 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5447,10 +5447,10 @@ namespace OpenSim.Region.Framework.Scenes for (int i = 0; i < 5; i++) presence.PhysicsActor.IsColliding = true; -// Vector3 targetPos = presence.MoveToPositionTarget; -// if (m_avatars[presence.UUID].LandAtTarget) -// presence.PhysicsActor.Flying = false; + if (presence.LandAtTarget) + presence.PhysicsActor.Flying = false; +// Vector3 targetPos = presence.MoveToPositionTarget; // float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; // if (targetPos.Z - terrainHeight < 0.2) // { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5e9cb327a8..6ff53646ca 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1939,7 +1939,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); if (avatar != null) { - avatar.MoveToTarget(target, false); + avatar.MoveToTarget(target, false, false); } } else diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 91052ec3e9..09a8bb7667 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -236,6 +236,11 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 MoveToPositionTarget { get; private set; } private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); + /// + /// Controls whether an avatar automatically moving to a target will land when it gets there (if flying). + /// + public bool LandAtTarget { get; private set; } + private bool m_followCamAuto; private int m_movementUpdateCount; @@ -1829,7 +1834,10 @@ namespace OpenSim.Region.Framework.Scenes /// This is to allow movement to targets that are known to be on an elevated platform with a continuous path /// from start to finish. /// - public void MoveToTarget(Vector3 pos, bool noFly) + /// + /// If true and the avatar starts flying during the move then land at the target. + /// + public void MoveToTarget(Vector3 pos, bool noFly, bool landAtTarget) { m_log.DebugFormat( "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", @@ -1868,6 +1876,7 @@ namespace OpenSim.Region.Framework.Scenes else if (pos.Z > terrainHeight) PhysicsActor.Flying = true; + LandAtTarget = landAtTarget; MovingToTarget = true; MoveToPositionTarget = pos; diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs index 5a85d7f9da..64c36ffaef 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs @@ -85,7 +85,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos)); Vector3 targetPos = startPos + new Vector3(0, 10, 0); - sp.MoveToTarget(targetPos, false); + sp.MoveToTarget(targetPos, false, false); Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos)); Assert.That( @@ -110,7 +110,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests // Try a second movement startPos = sp.AbsolutePosition; targetPos = startPos + new Vector3(10, 0, 0); - sp.MoveToTarget(targetPos, false); + sp.MoveToTarget(targetPos, false, false); Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos)); Assert.That( diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 00b1c1e2ff..c92f121a7a 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -806,7 +806,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public event ScriptReset OnScriptReset; public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; - public event Action OnAutoPilotGo; + public event Action OnAutoPilotGo; public event TerrainUnacked OnUnackedTerrain; public event ActivateGesture OnActivateGesture; public event DeactivateGesture OnDeactivateGesture; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 4f831a4889..253fdee0c9 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -37,11 +37,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC { public class NPCAvatar : IClientAPI { - /// - /// Signal whether the avatar should land when it reaches a move target - /// - public bool LandAtTarget { get; set; } - private readonly string m_firstname; private readonly string m_lastname; private readonly Vector3 m_startPos; @@ -333,7 +328,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event ScriptReset OnScriptReset; public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; - public event Action OnAutoPilotGo; + public event Action OnAutoPilotGo; public event TerrainUnacked OnUnackedTerrain; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 62822459f6..bcd9e943ee 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -53,78 +53,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (config != null && config.GetBoolean("Enabled", false)) { scene.RegisterModuleInterface(this); -// scene.EventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; - } - } - - public void HandleOnSignificantClientMovement(ScenePresence presence) - { - lock (m_avatars) - { - if (m_avatars.ContainsKey(presence.UUID) && presence.MovingToTarget) - { - double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget); -// m_log.DebugFormat( -// "[NPC MODULE]: Abs pos of {0} is {1}, target {2}, distance {3}", -// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget); - - // Check the error term of the current position in relation to the target position - if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT) - { - // We are close enough to the target - m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name); - - presence.Velocity = Vector3.Zero; - presence.AbsolutePosition = presence.MoveToPositionTarget; - presence.ResetMoveToTarget(); - - if (presence.PhysicsActor.Flying) - { - // A horrible hack to stop the NPC dead in its tracks rather than having them overshoot - // the target if flying. - // We really need to be more subtle (slow the avatar as it approaches the target) or at - // least be able to set collision status once, rather than 5 times to give it enough - // weighting so that that PhysicsActor thinks it really is colliding. - for (int i = 0; i < 5; i++) - presence.PhysicsActor.IsColliding = true; - -// Vector3 targetPos = presence.MoveToPositionTarget; - if (m_avatars[presence.UUID].LandAtTarget) - presence.PhysicsActor.Flying = false; - -// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; -// if (targetPos.Z - terrainHeight < 0.2) -// { -// presence.PhysicsActor.Flying = false; -// } - } - -// m_log.DebugFormat( -// "[NPC MODULE]: AgentControlFlags {0}, MovementFlag {1} for {2}", -// presence.AgentControlFlags, presence.MovementFlag, presence.Name); - } - else - { -// m_log.DebugFormat( -// "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}", -// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); - - Vector3 agent_control_v3 = new Vector3(); - presence.HandleMoveToTargetUpdate(ref agent_control_v3); - presence.AddNewMovement(agent_control_v3); - } -// -//// presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null); - -// -// - - } } } public bool IsNPC(UUID agentId, Scene scene) { + // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect + // that directly). ScenePresence sp = scene.GetScenePresence(agentId); if (sp == null || sp.IsChildAgent) return false; @@ -218,8 +153,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); - m_avatars[agentID].LandAtTarget = landAtTarget; - sp.MoveToTarget(pos, noFly); + sp.MoveToTarget(pos, noFly, landAtTarget); return true; } diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 014f7f6a81..b4f521fa5c 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -234,7 +234,7 @@ namespace OpenSim.Tests.Common.Mock public event ScriptReset OnScriptReset; public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; - public event Action OnAutoPilotGo; + public event Action OnAutoPilotGo; public event TerrainUnacked OnUnackedTerrain;