diff options
author | Justin Clark-Casey (justincc) | 2011-09-21 23:56:11 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-09-21 23:56:11 +0100 |
commit | 241e07d006fad1b54e088d8a9ddede0b98a1e800 (patch) | |
tree | 828c62846bdd47d6eea0a47b02d366dd1728b9ea /OpenSim/Region/Framework/Scenes/Scene.cs | |
parent | Remove unused and never set SP.PreviousRotation (diff) | |
download | opensim-SC_OLD-241e07d006fad1b54e088d8a9ddede0b98a1e800.zip opensim-SC_OLD-241e07d006fad1b54e088d8a9ddede0b98a1e800.tar.gz opensim-SC_OLD-241e07d006fad1b54e088d8a9ddede0b98a1e800.tar.bz2 opensim-SC_OLD-241e07d006fad1b54e088d8a9ddede0b98a1e800.tar.xz |
Move code which handles NPC movement into Scene so that this can also be used by Autopilot coming from the client side.
I thought that I had implemented this but must have accidentally removed it.
Adds a regression test to detect if this happens again.
Temporarily disables automatic landing of NPC at a target. Will be fixed presently.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 976e001..000a6ed 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -870,6 +870,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
870 | 870 | ||
871 | if (dm != null) | 871 | if (dm != null) |
872 | m_eventManager.OnPermissionError += dm.SendAlertToUser; | 872 | m_eventManager.OnPermissionError += dm.SendAlertToUser; |
873 | |||
874 | m_eventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; | ||
873 | } | 875 | } |
874 | 876 | ||
875 | public override string GetSimulatorVersion() | 877 | public override string GetSimulatorVersion() |
@@ -5138,5 +5140,70 @@ namespace OpenSim.Region.Framework.Scenes | |||
5138 | reason = String.Empty; | 5140 | reason = String.Empty; |
5139 | return true; | 5141 | return true; |
5140 | } | 5142 | } |
5143 | |||
5144 | /// <summary> | ||
5145 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | ||
5146 | /// autopilot that moves an avatar to a sit target!. | ||
5147 | /// </summary> | ||
5148 | /// <remarks> | ||
5149 | /// This is not intended as a permament location for this method. | ||
5150 | /// </remarks> | ||
5151 | /// <param name="presence"></param> | ||
5152 | private void HandleOnSignificantClientMovement(ScenePresence presence) | ||
5153 | { | ||
5154 | if (presence.MovingToTarget) | ||
5155 | { | ||
5156 | double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget); | ||
5157 | // m_log.DebugFormat( | ||
5158 | // "[SCENE]: Abs pos of {0} is {1}, target {2}, distance {3}", | ||
5159 | // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget); | ||
5160 | |||
5161 | // Check the error term of the current position in relation to the target position | ||
5162 | if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT) | ||
5163 | { | ||
5164 | // We are close enough to the target | ||
5165 | // m_log.DebugFormat("[SCENEE]: Stopping autopilot of {0}", presence.Name); | ||
5166 | |||
5167 | presence.Velocity = Vector3.Zero; | ||
5168 | presence.AbsolutePosition = presence.MoveToPositionTarget; | ||
5169 | presence.ResetMoveToTarget(); | ||
5170 | |||
5171 | if (presence.PhysicsActor.Flying) | ||
5172 | { | ||
5173 | // A horrible hack to stop the avatar dead in its tracks rather than having them overshoot | ||
5174 | // the target if flying. | ||
5175 | // We really need to be more subtle (slow the avatar as it approaches the target) or at | ||
5176 | // least be able to set collision status once, rather than 5 times to give it enough | ||
5177 | // weighting so that that PhysicsActor thinks it really is colliding. | ||
5178 | for (int i = 0; i < 5; i++) | ||
5179 | presence.PhysicsActor.IsColliding = true; | ||
5180 | |||
5181 | // Vector3 targetPos = presence.MoveToPositionTarget; | ||
5182 | // if (m_avatars[presence.UUID].LandAtTarget) | ||
5183 | // presence.PhysicsActor.Flying = false; | ||
5184 | |||
5185 | // float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; | ||
5186 | // if (targetPos.Z - terrainHeight < 0.2) | ||
5187 | // { | ||
5188 | // presence.PhysicsActor.Flying = false; | ||
5189 | // } | ||
5190 | } | ||
5191 | |||
5192 | // m_log.DebugFormat( | ||
5193 | // "[SCENE]: AgentControlFlags {0}, MovementFlag {1} for {2}", | ||
5194 | // presence.AgentControlFlags, presence.MovementFlag, presence.Name); | ||
5195 | } | ||
5196 | else | ||
5197 | { | ||
5198 | // m_log.DebugFormat( | ||
5199 | // "[SCENE]: Updating npc {0} at {1} for next movement to {2}", | ||
5200 | // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); | ||
5201 | |||
5202 | Vector3 agent_control_v3 = new Vector3(); | ||
5203 | presence.HandleMoveToTargetUpdate(ref agent_control_v3); | ||
5204 | presence.AddNewMovement(agent_control_v3); | ||
5205 | } | ||
5206 | } | ||
5207 | } | ||
5141 | } | 5208 | } |
5142 | } | 5209 | } |