diff options
-rwxr-xr-x | OpenSim/Region/Framework/Scenes/Scene.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 74 |
2 files changed, 54 insertions, 25 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a7e06a8..5799cd4 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1309,7 +1309,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1309 | 1309 | ||
1310 | protected virtual void RegisterDefaultSceneEvents() | 1310 | protected virtual void RegisterDefaultSceneEvents() |
1311 | { | 1311 | { |
1312 | m_eventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; | 1312 | // m_eventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | public override string GetSimulatorVersion() | 1315 | public override string GetSimulatorVersion() |
@@ -6334,6 +6334,7 @@ Environment.Exit(1); | |||
6334 | /// This is not intended as a permament location for this method. | 6334 | /// This is not intended as a permament location for this method. |
6335 | /// </remarks> | 6335 | /// </remarks> |
6336 | /// <param name="presence"></param> | 6336 | /// <param name="presence"></param> |
6337 | /* move to target is now done on presence update | ||
6337 | private void HandleOnSignificantClientMovement(ScenePresence presence) | 6338 | private void HandleOnSignificantClientMovement(ScenePresence presence) |
6338 | { | 6339 | { |
6339 | if (presence.MovingToTarget) | 6340 | if (presence.MovingToTarget) |
@@ -6390,7 +6391,7 @@ Environment.Exit(1); | |||
6390 | } | 6391 | } |
6391 | } | 6392 | } |
6392 | } | 6393 | } |
6393 | 6394 | */ | |
6394 | // manage and select spawn points in sequence | 6395 | // manage and select spawn points in sequence |
6395 | public int SpawnPoint() | 6396 | public int SpawnPoint() |
6396 | { | 6397 | { |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 4e63310..142d643 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -2467,7 +2467,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2467 | // The UseClientAgentPosition is set if parcel ban is forcing the avatar to move to a | 2467 | // The UseClientAgentPosition is set if parcel ban is forcing the avatar to move to a |
2468 | // certain position. It's only check for tolerance on returning to that position is 0.2 | 2468 | // certain position. It's only check for tolerance on returning to that position is 0.2 |
2469 | // rather than 1, at which point it removes its force target. | 2469 | // rather than 1, at which point it removes its force target. |
2470 | if (HandleMoveToTargetUpdate(agentData.UseClientAgentPosition ? 0.2 : 1, ref agent_control_v3)) | 2470 | if (HandleMoveToTargetUpdate(agentData.UseClientAgentPosition ? 0.2f : 1f, ref agent_control_v3)) |
2471 | update_movementflag = true; | 2471 | update_movementflag = true; |
2472 | } | 2472 | } |
2473 | } | 2473 | } |
@@ -2643,31 +2643,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
2643 | /// </remarks> | 2643 | /// </remarks> |
2644 | /// <param value="agent_control_v3">Cumulative agent movement that this method will update.</param> | 2644 | /// <param value="agent_control_v3">Cumulative agent movement that this method will update.</param> |
2645 | /// <returns>True if movement has been updated in some way. False otherwise.</returns> | 2645 | /// <returns>True if movement has been updated in some way. False otherwise.</returns> |
2646 | public bool HandleMoveToTargetUpdate(double tolerance, ref Vector3 agent_control_v3) | 2646 | public bool HandleMoveToTargetUpdate(float tolerance, ref Vector3 agent_control_v3) |
2647 | { | 2647 | { |
2648 | // m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name); | 2648 | // m_log.DebugFormat("[SCENE PRESENCE]: Called HandleMoveToTargetUpdate() for {0}", Name); |
2649 | 2649 | ||
2650 | bool updated = false; | 2650 | bool updated = false; |
2651 | 2651 | ||
2652 | Vector3 LocalVectorToTarget3D = MoveToPositionTarget - AbsolutePosition; | 2652 | Vector3 LocalVectorToTarget3D = MoveToPositionTarget - AbsolutePosition; |
2653 | 2653 | ||
2654 | // m_log.DebugFormat( | 2654 | // m_log.DebugFormat( |
2655 | // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", | 2655 | // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", |
2656 | // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); | 2656 | // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); |
2657 | 2657 | ||
2658 | double distanceToTarget = LocalVectorToTarget3D.Length(); | 2658 | float distanceToTarget; |
2659 | if(Flying && !LandAtTarget) | ||
2660 | { | ||
2661 | distanceToTarget = LocalVectorToTarget3D.Length(); | ||
2662 | } | ||
2663 | else | ||
2664 | { | ||
2665 | Vector3 hdist = LocalVectorToTarget3D; | ||
2666 | hdist.Z = 0; | ||
2667 | distanceToTarget = hdist.Length(); | ||
2668 | } | ||
2659 | 2669 | ||
2660 | // m_log.DebugFormat( | 2670 | // m_log.DebugFormat( |
2661 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", | 2671 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", |
2662 | // Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); | 2672 | // Name, AbsolutePosition, MoveToPositionTarget, distanceToTarget); |
2663 | 2673 | ||
2664 | // Check the error term of the current position in relation to the target position | 2674 | // Check the error term of the current position in relation to the target position |
2665 | if (distanceToTarget <= tolerance) | 2675 | if (distanceToTarget <= tolerance) |
2666 | { | 2676 | { |
2667 | // We are close enough to the target | 2677 | // We are close enough to the target |
2678 | Velocity = Vector3.Zero; | ||
2668 | AbsolutePosition = MoveToPositionTarget; | 2679 | AbsolutePosition = MoveToPositionTarget; |
2680 | if (Flying) | ||
2681 | { | ||
2682 | if (LandAtTarget) | ||
2683 | Flying = false; | ||
2684 | |||
2685 | // A horrible hack to stop the avatar dead in its tracks rather than having them overshoot | ||
2686 | // the target if flying. | ||
2687 | // We really need to be more subtle (slow the avatar as it approaches the target) or at | ||
2688 | // least be able to set collision status once, rather than 5 times to give it enough | ||
2689 | // weighting so that that PhysicsActor thinks it really is colliding. | ||
2690 | for (int i = 0; i < 5; i++) | ||
2691 | IsColliding = true; | ||
2692 | } | ||
2669 | ResetMoveToTarget(); | 2693 | ResetMoveToTarget(); |
2670 | updated = true; | 2694 | return false; |
2671 | } | 2695 | } |
2672 | else | 2696 | else |
2673 | { | 2697 | { |
@@ -2680,8 +2704,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2680 | // to such forces, but the following simple approach seems to works fine. | 2704 | // to such forces, but the following simple approach seems to works fine. |
2681 | 2705 | ||
2682 | LocalVectorToTarget3D = LocalVectorToTarget3D * Quaternion.Inverse(Rotation); // change to avatar coords | 2706 | LocalVectorToTarget3D = LocalVectorToTarget3D * Quaternion.Inverse(Rotation); // change to avatar coords |
2683 | // Ignore z component of vector | ||
2684 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | ||
2685 | 2707 | ||
2686 | LocalVectorToTarget3D.Normalize(); | 2708 | LocalVectorToTarget3D.Normalize(); |
2687 | 2709 | ||
@@ -2771,6 +2793,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2771 | } | 2793 | } |
2772 | 2794 | ||
2773 | return updated; | 2795 | return updated; |
2796 | // AddNewMovement(agent_control_v3); | ||
2774 | } | 2797 | } |
2775 | 2798 | ||
2776 | /// <summary> | 2799 | /// <summary> |
@@ -2807,6 +2830,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2807 | || pos.Z < 0) | 2830 | || pos.Z < 0) |
2808 | return; | 2831 | return; |
2809 | 2832 | ||
2833 | float terrainHeight; | ||
2810 | Scene targetScene = m_scene; | 2834 | Scene targetScene = m_scene; |
2811 | // Get terrain height for sub-region in a megaregion if necessary | 2835 | // Get terrain height for sub-region in a megaregion if necessary |
2812 | if (regionCombinerModule != null) | 2836 | if (regionCombinerModule != null) |
@@ -2819,18 +2843,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2819 | return; | 2843 | return; |
2820 | UUID target_regionID = target_region.RegionID; | 2844 | UUID target_regionID = target_region.RegionID; |
2821 | SceneManager.Instance.TryGetScene(target_region.RegionID, out targetScene); | 2845 | SceneManager.Instance.TryGetScene(target_region.RegionID, out targetScene); |
2846 | terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)]; | ||
2822 | } | 2847 | } |
2823 | 2848 | else | |
2824 | float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)]; | 2849 | terrainHeight = m_scene.GetGroundHeight(pos.X, pos.Y); |
2850 | |||
2825 | // dont try to land underground | 2851 | // dont try to land underground |
2826 | terrainHeight += Appearance.AvatarHeight / 2; | 2852 | terrainHeight += Appearance.AvatarHeight * 0.5f + 0.2f; |
2827 | |||
2828 | pos.Z = Math.Max(terrainHeight, pos.Z); | ||
2829 | 2853 | ||
2830 | // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is | 2854 | if(terrainHeight > pos.Z) |
2831 | // always slightly higher than the actual terrain height. | ||
2832 | // FIXME: This constrains NPC movements as well, so should be somewhere else. | ||
2833 | if (pos.Z - terrainHeight < 0.2) | ||
2834 | pos.Z = terrainHeight; | 2855 | pos.Z = terrainHeight; |
2835 | 2856 | ||
2836 | // m_log.DebugFormat( | 2857 | // m_log.DebugFormat( |
@@ -2839,7 +2860,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2839 | 2860 | ||
2840 | if (noFly) | 2861 | if (noFly) |
2841 | Flying = false; | 2862 | Flying = false; |
2842 | else if (pos.Z > terrainHeight + Appearance.AvatarHeight / 2 || Flying) | 2863 | else if (pos.Z > terrainHeight || Flying) |
2843 | Flying = true; | 2864 | Flying = true; |
2844 | 2865 | ||
2845 | LandAtTarget = landAtTarget; | 2866 | LandAtTarget = landAtTarget; |
@@ -2861,9 +2882,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2861 | Rotation = Quaternion.CreateFromEulers(angle); | 2882 | Rotation = Quaternion.CreateFromEulers(angle); |
2862 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, Rotation); | 2883 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, Rotation); |
2863 | 2884 | ||
2864 | Vector3 agent_control_v3 = new Vector3(); | 2885 | Vector3 control = Vector3.Zero; |
2865 | HandleMoveToTargetUpdate(1, ref agent_control_v3); | 2886 | if(HandleMoveToTargetUpdate(1f, ref control)) |
2866 | AddNewMovement(agent_control_v3); | 2887 | AddNewMovement(control); |
2867 | } | 2888 | } |
2868 | 2889 | ||
2869 | /// <summary> | 2890 | /// <summary> |
@@ -3526,6 +3547,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3526 | if (IsInTransit || IsLoggingIn) | 3547 | if (IsInTransit || IsLoggingIn) |
3527 | return; | 3548 | return; |
3528 | 3549 | ||
3550 | if(MovingToTarget) | ||
3551 | { | ||
3552 | Vector3 control = Vector3.Zero; | ||
3553 | if(HandleMoveToTargetUpdate(1f, ref control)) | ||
3554 | AddNewMovement(control); | ||
3555 | } | ||
3556 | |||
3529 | if (Appearance.AvatarSize != m_lastSize) | 3557 | if (Appearance.AvatarSize != m_lastSize) |
3530 | SendAvatarDataToAllAgents(); | 3558 | SendAvatarDataToAllAgents(); |
3531 | 3559 | ||