diff options
author | Diva Canto | 2011-12-22 08:18:03 -0800 |
---|---|---|
committer | Diva Canto | 2011-12-22 08:18:03 -0800 |
commit | 219ec7ef20ccefb257be5ec650a13758b2a3cda3 (patch) | |
tree | b323896f94d3d3f5d30718481d8703981c23476a /OpenSim | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-219ec7ef20ccefb257be5ec650a13758b2a3cda3.zip opensim-SC-219ec7ef20ccefb257be5ec650a13758b2a3cda3.tar.gz opensim-SC-219ec7ef20ccefb257be5ec650a13758b2a3cda3.tar.bz2 opensim-SC-219ec7ef20ccefb257be5ec650a13758b2a3cda3.tar.xz |
Fixing a bug introduced yesterday. This put the precondition test inside CheckForBorderCrossing the right way.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 214 |
1 files changed, 109 insertions, 105 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6f02475..040cbfc 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -2736,137 +2736,141 @@ namespace OpenSim.Region.Framework.Scenes | |||
2736 | /// </remarks> | 2736 | /// </remarks> |
2737 | protected void CheckForBorderCrossing() | 2737 | protected void CheckForBorderCrossing() |
2738 | { | 2738 | { |
2739 | // Check that we we are not a child and have a physics actor or we're sitting on something | 2739 | // Check that we we are not a child |
2740 | if (IsChildAgent || (ParentID == 0 && PhysicsActor != null || ParentID != 0)) | 2740 | if (IsChildAgent) |
2741 | return; | 2741 | return; |
2742 | 2742 | ||
2743 | Vector3 pos2 = AbsolutePosition; | 2743 | // We only do this if we have a physics actor or we're sitting on something |
2744 | Vector3 vel = Velocity; | 2744 | if (ParentID == 0 && PhysicsActor != null || ParentID != 0) |
2745 | int neighbor = 0; | 2745 | { |
2746 | int[] fix = new int[2]; | 2746 | Vector3 pos2 = AbsolutePosition; |
2747 | Vector3 vel = Velocity; | ||
2748 | int neighbor = 0; | ||
2749 | int[] fix = new int[2]; | ||
2747 | 2750 | ||
2748 | float timeStep = 0.1f; | 2751 | float timeStep = 0.1f; |
2749 | pos2.X = pos2.X + (vel.X*timeStep); | 2752 | pos2.X = pos2.X + (vel.X * timeStep); |
2750 | pos2.Y = pos2.Y + (vel.Y*timeStep); | 2753 | pos2.Y = pos2.Y + (vel.Y * timeStep); |
2751 | pos2.Z = pos2.Z + (vel.Z*timeStep); | 2754 | pos2.Z = pos2.Z + (vel.Z * timeStep); |
2752 | 2755 | ||
2753 | if (!IsInTransit) | 2756 | if (!IsInTransit) |
2754 | { | ||
2755 | // Checks if where it's headed exists a region | ||
2756 | bool needsTransit = false; | ||
2757 | if (m_scene.TestBorderCross(pos2, Cardinals.W)) | ||
2758 | { | 2757 | { |
2759 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) | 2758 | // Checks if where it's headed exists a region |
2759 | bool needsTransit = false; | ||
2760 | if (m_scene.TestBorderCross(pos2, Cardinals.W)) | ||
2760 | { | 2761 | { |
2761 | needsTransit = true; | 2762 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) |
2762 | neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix); | 2763 | { |
2763 | } | 2764 | needsTransit = true; |
2764 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | 2765 | neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix); |
2765 | { | 2766 | } |
2766 | needsTransit = true; | 2767 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) |
2767 | neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix); | 2768 | { |
2769 | needsTransit = true; | ||
2770 | neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix); | ||
2771 | } | ||
2772 | else | ||
2773 | { | ||
2774 | needsTransit = true; | ||
2775 | neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix); | ||
2776 | } | ||
2768 | } | 2777 | } |
2769 | else | 2778 | else if (m_scene.TestBorderCross(pos2, Cardinals.E)) |
2770 | { | 2779 | { |
2771 | needsTransit = true; | 2780 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) |
2772 | neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix); | 2781 | { |
2782 | needsTransit = true; | ||
2783 | neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix); | ||
2784 | } | ||
2785 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | ||
2786 | { | ||
2787 | needsTransit = true; | ||
2788 | neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix); | ||
2789 | } | ||
2790 | else | ||
2791 | { | ||
2792 | needsTransit = true; | ||
2793 | neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix); | ||
2794 | } | ||
2773 | } | 2795 | } |
2774 | } | 2796 | else if (m_scene.TestBorderCross(pos2, Cardinals.S)) |
2775 | else if (m_scene.TestBorderCross(pos2, Cardinals.E)) | ||
2776 | { | ||
2777 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) | ||
2778 | { | 2797 | { |
2779 | needsTransit = true; | 2798 | needsTransit = true; |
2780 | neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix); | 2799 | neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix); |
2781 | } | 2800 | } |
2782 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | 2801 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) |
2783 | { | 2802 | { |
2784 | needsTransit = true; | 2803 | needsTransit = true; |
2785 | neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix); | 2804 | neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix); |
2786 | } | 2805 | } |
2787 | else | ||
2788 | { | ||
2789 | needsTransit = true; | ||
2790 | neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix); | ||
2791 | } | ||
2792 | } | ||
2793 | else if (m_scene.TestBorderCross(pos2, Cardinals.S)) | ||
2794 | { | ||
2795 | needsTransit = true; | ||
2796 | neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix); | ||
2797 | } | ||
2798 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | ||
2799 | { | ||
2800 | needsTransit = true; | ||
2801 | neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix); | ||
2802 | } | ||
2803 | 2806 | ||
2804 | // Makes sure avatar does not end up outside region | 2807 | // Makes sure avatar does not end up outside region |
2805 | if (neighbor <= 0) | 2808 | if (neighbor <= 0) |
2806 | { | ||
2807 | if (needsTransit) | ||
2808 | { | 2809 | { |
2809 | if (m_requestedSitTargetUUID == UUID.Zero) | 2810 | if (needsTransit) |
2810 | { | 2811 | { |
2811 | bool isFlying = Flying; | 2812 | if (m_requestedSitTargetUUID == UUID.Zero) |
2812 | RemoveFromPhysicalScene(); | 2813 | { |
2813 | 2814 | bool isFlying = Flying; | |
2814 | Vector3 pos = AbsolutePosition; | 2815 | RemoveFromPhysicalScene(); |
2815 | if (AbsolutePosition.X < 0) | 2816 | |
2816 | pos.X += Velocity.X * 2; | 2817 | Vector3 pos = AbsolutePosition; |
2817 | else if (AbsolutePosition.X > Constants.RegionSize) | 2818 | if (AbsolutePosition.X < 0) |
2818 | pos.X -= Velocity.X * 2; | 2819 | pos.X += Velocity.X * 2; |
2819 | if (AbsolutePosition.Y < 0) | 2820 | else if (AbsolutePosition.X > Constants.RegionSize) |
2820 | pos.Y += Velocity.Y * 2; | 2821 | pos.X -= Velocity.X * 2; |
2821 | else if (AbsolutePosition.Y > Constants.RegionSize) | 2822 | if (AbsolutePosition.Y < 0) |
2822 | pos.Y -= Velocity.Y * 2; | 2823 | pos.Y += Velocity.Y * 2; |
2823 | Velocity = Vector3.Zero; | 2824 | else if (AbsolutePosition.Y > Constants.RegionSize) |
2824 | AbsolutePosition = pos; | 2825 | pos.Y -= Velocity.Y * 2; |
2825 | 2826 | Velocity = Vector3.Zero; | |
2826 | m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); | 2827 | AbsolutePosition = pos; |
2827 | 2828 | ||
2828 | AddToPhysicalScene(isFlying); | 2829 | m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); |
2830 | |||
2831 | AddToPhysicalScene(isFlying); | ||
2832 | } | ||
2829 | } | 2833 | } |
2830 | } | 2834 | } |
2831 | } | 2835 | else if (neighbor > 0) |
2832 | else if (neighbor > 0) | ||
2833 | { | ||
2834 | if (!CrossToNewRegion()) | ||
2835 | { | 2836 | { |
2836 | if (m_requestedSitTargetUUID == UUID.Zero) | 2837 | if (!CrossToNewRegion()) |
2837 | { | 2838 | { |
2838 | bool isFlying = Flying; | 2839 | if (m_requestedSitTargetUUID == UUID.Zero) |
2839 | RemoveFromPhysicalScene(); | 2840 | { |
2840 | 2841 | bool isFlying = Flying; | |
2841 | Vector3 pos = AbsolutePosition; | 2842 | RemoveFromPhysicalScene(); |
2842 | if (AbsolutePosition.X < 0) | 2843 | |
2843 | pos.X += Velocity.X * 2; | 2844 | Vector3 pos = AbsolutePosition; |
2844 | else if (AbsolutePosition.X > Constants.RegionSize) | 2845 | if (AbsolutePosition.X < 0) |
2845 | pos.X -= Velocity.X * 2; | 2846 | pos.X += Velocity.X * 2; |
2846 | if (AbsolutePosition.Y < 0) | 2847 | else if (AbsolutePosition.X > Constants.RegionSize) |
2847 | pos.Y += Velocity.Y * 2; | 2848 | pos.X -= Velocity.X * 2; |
2848 | else if (AbsolutePosition.Y > Constants.RegionSize) | 2849 | if (AbsolutePosition.Y < 0) |
2849 | pos.Y -= Velocity.Y * 2; | 2850 | pos.Y += Velocity.Y * 2; |
2850 | Velocity = Vector3.Zero; | 2851 | else if (AbsolutePosition.Y > Constants.RegionSize) |
2851 | AbsolutePosition = pos; | 2852 | pos.Y -= Velocity.Y * 2; |
2852 | 2853 | Velocity = Vector3.Zero; | |
2853 | AddToPhysicalScene(isFlying); | 2854 | AbsolutePosition = pos; |
2855 | |||
2856 | AddToPhysicalScene(isFlying); | ||
2857 | } | ||
2854 | } | 2858 | } |
2855 | } | 2859 | } |
2856 | } | 2860 | } |
2857 | } | 2861 | else |
2858 | else | 2862 | { |
2859 | { | 2863 | // This constant has been inferred from experimentation |
2860 | // This constant has been inferred from experimentation | 2864 | // I'm not sure what this value should be, so I tried a few values. |
2861 | // I'm not sure what this value should be, so I tried a few values. | 2865 | timeStep = 0.04f; |
2862 | timeStep = 0.04f; | 2866 | pos2 = AbsolutePosition; |
2863 | pos2 = AbsolutePosition; | 2867 | pos2.X = pos2.X + (vel.X * timeStep); |
2864 | pos2.X = pos2.X + (vel.X * timeStep); | 2868 | pos2.Y = pos2.Y + (vel.Y * timeStep); |
2865 | pos2.Y = pos2.Y + (vel.Y * timeStep); | 2869 | // Don't touch the Z |
2866 | // Don't touch the Z | 2870 | m_pos = pos2; |
2867 | m_pos = pos2; | 2871 | m_log.DebugFormat("[SCENE PRESENCE]: In transit m_pos={0}", m_pos); |
2868 | m_log.ErrorFormat("m_pos={0}", m_pos); | 2872 | } |
2869 | } | 2873 | } |
2870 | } | 2874 | } |
2871 | 2875 | ||
2872 | /// <summary> | 2876 | /// <summary> |