diff options
author | Melanie | 2011-12-22 16:37:25 +0000 |
---|---|---|
committer | Melanie | 2011-12-22 16:37:25 +0000 |
commit | b970d4f976ec7f264c33948c734a15a2dbf0ac7d (patch) | |
tree | 93a3365e4a8a32bdfce1ef92bafc02f79f98d449 /OpenSim/Region/Framework/Scenes | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Fixing a bug introduced yesterday. This put the precondition test inside Chec... (diff) | |
download | opensim-SC_OLD-b970d4f976ec7f264c33948c734a15a2dbf0ac7d.zip opensim-SC_OLD-b970d4f976ec7f264c33948c734a15a2dbf0ac7d.tar.gz opensim-SC_OLD-b970d4f976ec7f264c33948c734a15a2dbf0ac7d.tar.bz2 opensim-SC_OLD-b970d4f976ec7f264c33948c734a15a2dbf0ac7d.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/Framework/Scenes/ScenePresence.cs
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 229 |
1 files changed, 112 insertions, 117 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 34b3c1d..b0a0046 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1180,10 +1180,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1180 | public void CompleteMovement(IClientAPI client, bool openChildAgents) | 1180 | public void CompleteMovement(IClientAPI client, bool openChildAgents) |
1181 | { | 1181 | { |
1182 | // DateTime startTime = DateTime.Now; | 1182 | // DateTime startTime = DateTime.Now; |
1183 | 1183 | ||
1184 | // m_log.DebugFormat( | 1184 | m_log.DebugFormat( |
1185 | // "[SCENE PRESENCE]: Completing movement of {0} into region {1}", | 1185 | "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}", |
1186 | // client.Name, Scene.RegionInfo.RegionName); | 1186 | client.Name, Scene.RegionInfo.RegionName, AbsolutePosition); |
1187 | 1187 | ||
1188 | Vector3 look = Velocity; | 1188 | Vector3 look = Velocity; |
1189 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1189 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
@@ -2405,9 +2405,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2405 | m_lastVelocity = Velocity; | 2405 | m_lastVelocity = Velocity; |
2406 | } | 2406 | } |
2407 | 2407 | ||
2408 | // followed suggestion from mic bowman. reversed the two lines below. | 2408 | CheckForBorderCrossing(); |
2409 | if (ParentID == 0 && PhysicsActor != null || ParentID != 0) // Check that we have a physics actor or we're sitting on something | ||
2410 | CheckForBorderCrossing(); | ||
2411 | 2409 | ||
2412 | CheckForSignificantMovement(); // sends update to the modules. | 2410 | CheckForSignificantMovement(); // sends update to the modules. |
2413 | } | 2411 | } |
@@ -2760,146 +2758,143 @@ namespace OpenSim.Region.Framework.Scenes | |||
2760 | /// </remarks> | 2758 | /// </remarks> |
2761 | protected void CheckForBorderCrossing() | 2759 | protected void CheckForBorderCrossing() |
2762 | { | 2760 | { |
2763 | if (IsChildAgent) | 2761 | // Check that we we are not a child |
2762 | if (IsChildAgent) | ||
2764 | return; | 2763 | return; |
2765 | 2764 | ||
2766 | if (ParentID != 0) | 2765 | if (ParentID != 0) |
2767 | return; | 2766 | return; |
2768 | 2767 | ||
2769 | Vector3 pos2 = AbsolutePosition; | ||
2770 | Vector3 vel = Velocity; | ||
2771 | int neighbor = 0; | ||
2772 | int[] fix = new int[2]; | ||
2773 | |||
2774 | float timeStep = 0.1f; | ||
2775 | pos2.X = pos2.X + (vel.X*timeStep); | ||
2776 | pos2.Y = pos2.Y + (vel.Y*timeStep); | ||
2777 | pos2.Z = pos2.Z + (vel.Z*timeStep); | ||
2778 | |||
2779 | if (!IsInTransit) | 2768 | if (!IsInTransit) |
2780 | { | 2769 | { |
2781 | // Checks if where it's headed exists a region | 2770 | Vector3 pos2 = AbsolutePosition; |
2771 | Vector3 vel = Velocity; | ||
2772 | int neighbor = 0; | ||
2773 | int[] fix = new int[2]; | ||
2774 | |||
2775 | float timeStep = 0.1f; | ||
2776 | pos2.X = pos2.X + (vel.X * timeStep); | ||
2777 | pos2.Y = pos2.Y + (vel.Y * timeStep); | ||
2778 | pos2.Z = pos2.Z + (vel.Z * timeStep); | ||
2782 | 2779 | ||
2783 | bool needsTransit = false; | 2780 | if (!IsInTransit) |
2784 | if (m_scene.TestBorderCross(pos2, Cardinals.W)) | ||
2785 | { | 2781 | { |
2786 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) | 2782 | // Checks if where it's headed exists a region |
2787 | { | 2783 | bool needsTransit = false; |
2788 | needsTransit = true; | 2784 | if (m_scene.TestBorderCross(pos2, Cardinals.W)) |
2789 | neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix); | ||
2790 | } | ||
2791 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | ||
2792 | { | 2785 | { |
2793 | needsTransit = true; | 2786 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) |
2794 | neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix); | 2787 | { |
2788 | needsTransit = true; | ||
2789 | neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix); | ||
2790 | } | ||
2791 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | ||
2792 | { | ||
2793 | needsTransit = true; | ||
2794 | neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix); | ||
2795 | } | ||
2796 | else | ||
2797 | { | ||
2798 | needsTransit = true; | ||
2799 | neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix); | ||
2800 | } | ||
2795 | } | 2801 | } |
2796 | else | 2802 | else if (m_scene.TestBorderCross(pos2, Cardinals.E)) |
2797 | { | 2803 | { |
2798 | needsTransit = true; | 2804 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) |
2799 | neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix); | 2805 | { |
2806 | needsTransit = true; | ||
2807 | neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix); | ||
2808 | } | ||
2809 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | ||
2810 | { | ||
2811 | needsTransit = true; | ||
2812 | neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix); | ||
2813 | } | ||
2814 | else | ||
2815 | { | ||
2816 | needsTransit = true; | ||
2817 | neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix); | ||
2818 | } | ||
2800 | } | 2819 | } |
2801 | } | 2820 | else if (m_scene.TestBorderCross(pos2, Cardinals.S)) |
2802 | else if (m_scene.TestBorderCross(pos2, Cardinals.E)) | ||
2803 | { | ||
2804 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) | ||
2805 | { | 2821 | { |
2806 | needsTransit = true; | 2822 | needsTransit = true; |
2807 | neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix); | 2823 | neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix); |
2808 | } | 2824 | } |
2809 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | 2825 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) |
2810 | { | 2826 | { |
2811 | needsTransit = true; | 2827 | needsTransit = true; |
2812 | neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix); | 2828 | neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix); |
2813 | } | ||
2814 | else | ||
2815 | { | ||
2816 | needsTransit = true; | ||
2817 | neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix); | ||
2818 | } | 2829 | } |
2819 | } | ||
2820 | else if (m_scene.TestBorderCross(pos2, Cardinals.S)) | ||
2821 | { | ||
2822 | needsTransit = true; | ||
2823 | neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix); | ||
2824 | } | ||
2825 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | ||
2826 | { | ||
2827 | needsTransit = true; | ||
2828 | neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix); | ||
2829 | } | ||
2830 | 2830 | ||
2831 | // Makes sure avatar does not end up outside region | 2831 | // Makes sure avatar does not end up outside region |
2832 | if (neighbor <= 0) | 2832 | if (neighbor <= 0) |
2833 | { | ||
2834 | if (needsTransit) | ||
2835 | { | 2833 | { |
2836 | if (m_requestedSitTargetUUID == UUID.Zero) | 2834 | if (needsTransit) |
2837 | { | 2835 | { |
2838 | bool isFlying = Flying; | 2836 | if (m_requestedSitTargetUUID == UUID.Zero) |
2839 | RemoveFromPhysicalScene(); | 2837 | { |
2840 | 2838 | bool isFlying = Flying; | |
2841 | Vector3 pos = AbsolutePosition; | 2839 | RemoveFromPhysicalScene(); |
2842 | if (AbsolutePosition.X < 0) | 2840 | |
2843 | pos.X += Velocity.X * 2; | 2841 | Vector3 pos = AbsolutePosition; |
2844 | else if (AbsolutePosition.X > Constants.RegionSize) | 2842 | if (AbsolutePosition.X < 0) |
2845 | pos.X -= Velocity.X * 2; | 2843 | pos.X += Velocity.X * 2; |
2846 | if (AbsolutePosition.Y < 0) | 2844 | else if (AbsolutePosition.X > Constants.RegionSize) |
2847 | pos.Y += Velocity.Y * 2; | 2845 | pos.X -= Velocity.X * 2; |
2848 | else if (AbsolutePosition.Y > Constants.RegionSize) | 2846 | if (AbsolutePosition.Y < 0) |
2849 | pos.Y -= Velocity.Y * 2; | 2847 | pos.Y += Velocity.Y * 2; |
2850 | Velocity = Vector3.Zero; | 2848 | else if (AbsolutePosition.Y > Constants.RegionSize) |
2851 | AbsolutePosition = pos; | 2849 | pos.Y -= Velocity.Y * 2; |
2852 | 2850 | Velocity = Vector3.Zero; | |
2853 | // m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); | 2851 | AbsolutePosition = pos; |
2854 | 2852 | ||
2855 | AddToPhysicalScene(isFlying); | 2853 | m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); |
2854 | |||
2855 | AddToPhysicalScene(isFlying); | ||
2856 | } | ||
2856 | } | 2857 | } |
2857 | } | 2858 | } |
2858 | } | 2859 | else if (neighbor > 0) |
2859 | else if (neighbor > 0) | ||
2860 | { | ||
2861 | if (!CrossToNewRegion()) | ||
2862 | { | 2860 | { |
2863 | if (m_requestedSitTargetUUID == UUID.Zero) | 2861 | if (!CrossToNewRegion()) |
2864 | { | 2862 | { |
2865 | bool isFlying = Flying; | 2863 | if (m_requestedSitTargetUUID == UUID.Zero) |
2866 | RemoveFromPhysicalScene(); | 2864 | { |
2867 | 2865 | bool isFlying = Flying; | |
2868 | Vector3 pos = AbsolutePosition; | 2866 | RemoveFromPhysicalScene(); |
2869 | if (AbsolutePosition.X < 0) | 2867 | |
2870 | pos.X += Velocity.X * 2; | 2868 | Vector3 pos = AbsolutePosition; |
2871 | else if (AbsolutePosition.X > Constants.RegionSize) | 2869 | if (AbsolutePosition.X < 0) |
2872 | pos.X -= Velocity.X * 2; | 2870 | pos.X += Velocity.X * 2; |
2873 | if (AbsolutePosition.Y < 0) | 2871 | else if (AbsolutePosition.X > Constants.RegionSize) |
2874 | pos.Y += Velocity.Y * 2; | 2872 | pos.X -= Velocity.X * 2; |
2875 | else if (AbsolutePosition.Y > Constants.RegionSize) | 2873 | if (AbsolutePosition.Y < 0) |
2876 | pos.Y -= Velocity.Y * 2; | 2874 | pos.Y += Velocity.Y * 2; |
2877 | Velocity = Vector3.Zero; | 2875 | else if (AbsolutePosition.Y > Constants.RegionSize) |
2878 | AbsolutePosition = pos; | 2876 | pos.Y -= Velocity.Y * 2; |
2879 | 2877 | Velocity = Vector3.Zero; | |
2880 | AddToPhysicalScene(isFlying); | 2878 | AbsolutePosition = pos; |
2879 | |||
2880 | AddToPhysicalScene(isFlying); | ||
2881 | } | ||
2881 | } | 2882 | } |
2882 | } | 2883 | } |
2883 | } | 2884 | } |
2884 | } | 2885 | else |
2885 | else | 2886 | { |
2886 | { | 2887 | // This constant has been inferred from experimentation |
2887 | // We must remove the agent from the physical scene if it has been placed in transit. If we don't, | 2888 | // I'm not sure what this value should be, so I tried a few values. |
2888 | // then this method continues to be called from ScenePresence.Update() until the handover of the client between | 2889 | timeStep = 0.04f; |
2889 | // regions is completed. Since this handover can take more than 1000ms (due to the 1000ms | 2890 | pos2 = AbsolutePosition; |
2890 | // event queue polling response from the server), this results in the avatar pausing on the border | 2891 | pos2.X = pos2.X + (vel.X * timeStep); |
2891 | // for the handover period. | 2892 | pos2.Y = pos2.Y + (vel.Y * timeStep); |
2892 | RemoveFromPhysicalScene(); | 2893 | // Don't touch the Z |
2893 | 2894 | m_pos = pos2; | |
2894 | // This constant has been inferred from experimentation | 2895 | m_log.DebugFormat("[SCENE PRESENCE]: In transit m_pos={0}", m_pos); |
2895 | // I'm not sure what this value should be, so I tried a few values. | 2896 | } |
2896 | timeStep = 0.04f; | 2897 | } |
2897 | pos2 = AbsolutePosition; | ||
2898 | pos2.X = pos2.X + (vel.X * timeStep); | ||
2899 | pos2.Y = pos2.Y + (vel.Y * timeStep); | ||
2900 | pos2.Z = pos2.Z + (vel.Z * timeStep); | ||
2901 | m_pos = pos2; | ||
2902 | } | ||
2903 | } | 2898 | } |
2904 | 2899 | ||
2905 | /// <summary> | 2900 | /// <summary> |