aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs41
1 files changed, 41 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}