aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie Thielker2009-07-08 08:38:23 +0000
committerMelanie Thielker2009-07-08 08:38:23 +0000
commitd8fe7777bf5497b5eab949a0baa279c919ee1ac6 (patch)
treedb9fa786069f2b11ef7c4324d468a1f10d29b25d /OpenSim
parentExperimental fix for tilted avatar capsule, Mantis #2905 (diff)
downloadopensim-SC-d8fe7777bf5497b5eab949a0baa279c919ee1ac6.zip
opensim-SC-d8fe7777bf5497b5eab949a0baa279c919ee1ac6.tar.gz
opensim-SC-d8fe7777bf5497b5eab949a0baa279c919ee1ac6.tar.bz2
opensim-SC-d8fe7777bf5497b5eab949a0baa279c919ee1ac6.tar.xz
Prevent teleports from ending underground
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs41
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs11
2 files changed, 52 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c5c957f..c9fd6b5 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3760,5 +3760,46 @@ namespace OpenSim.Region.Framework.Scenes
3760 return (Scene)MainConsole.Instance.ConsoleScene; 3760 return (Scene)MainConsole.Instance.ConsoleScene;
3761 return null; 3761 return null;
3762 } 3762 }
3763
3764 public float GetGroundHeight(float x, float y)
3765 {
3766 if (x < 0)
3767 x = 0;
3768 if (x >= Heightmap.Width)
3769 x = Heightmap.Width - 1;
3770 if (y < 0)
3771 y = 0;
3772 if (y >= Heightmap.Height)
3773 y = Heightmap.Height - 1;
3774
3775 Vector3 p0 = new Vector3(x, y, (float)Heightmap[(int)x, (int)y]);
3776 Vector3 p1 = new Vector3(p0);
3777 Vector3 p2 = new Vector3(p0);
3778
3779 p1.X += 1.0f;
3780 if (p1.X < Heightmap.Width)
3781 p1.Z = (float)Heightmap[(int)p1.X, (int)p1.Y];
3782
3783 p2.Y += 1.0f;
3784 if (p2.Y < Heightmap.Height)
3785 p2.Z = (float)Heightmap[(int)p2.X, (int)p2.Y];
3786
3787 Vector3 v0 = new Vector3(p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z);
3788 Vector3 v1 = new Vector3(p2.X - p0.X, p2.Y - p0.Y, p2.Z - p0.Z);
3789
3790 v0.Normalize();
3791 v1.Normalize();
3792
3793 Vector3 vsn = new Vector3();
3794 vsn.X = (v0.Y * v1.Z) - (v0.Z * v1.Y);
3795 vsn.Y = (v0.Z * v1.X) - (v0.X * v1.Z);
3796 vsn.Z = (v0.X * v1.Y) - (v0.Y * v1.X);
3797 vsn.Normalize();
3798
3799 float xdiff = x - (float)((int)x);
3800 float ydiff = y - (float)((int)y);
3801
3802 return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z;
3803 }
3763 } 3804 }
3764} 3805}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 01facd1..b85a138 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1020,6 +1020,17 @@ namespace OpenSim.Region.Framework.Scenes
1020 look = new Vector3(0.99f, 0.042f, 0); 1020 look = new Vector3(0.99f, 0.042f, 0);
1021 } 1021 }
1022 1022
1023 // Prevent teleporting to an underground location
1024 // (may crash client otherwise)
1025 //
1026 Vector3 pos = AbsolutePosition;
1027 float ground = m_scene.GetGroundHeight(pos.X, pos.Y);
1028 if (pos.Z < ground + 1.5f)
1029 {
1030 pos.Z = ground + 1.5f;
1031 AbsolutePosition = pos;
1032 }
1033
1023 if (m_isChildAgent) 1034 if (m_isChildAgent)
1024 { 1035 {
1025 m_isChildAgent = false; 1036 m_isChildAgent = false;