mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
change get terrain height
This commit is contained in:
@@ -1496,29 +1496,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
public LSL_Float llGround(LSL_Vector offset)
|
||||
{
|
||||
Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset;
|
||||
|
||||
//Get the slope normal. This gives us the equation of the plane tangent to the slope.
|
||||
LSL_Vector vsn = llGroundNormal(offset);
|
||||
|
||||
// Clamp to valid position
|
||||
if (pos.X < 0)
|
||||
pos.X = 0;
|
||||
else if (pos.X >= World.Heightmap.Width)
|
||||
pos.X = World.Heightmap.Width - 1;
|
||||
if (pos.Y < 0)
|
||||
pos.Y = 0;
|
||||
else if (pos.Y >= World.Heightmap.Height)
|
||||
pos.Y = World.Heightmap.Height - 1;
|
||||
|
||||
//Get the height for the integer coordinates from the Heightmap
|
||||
float baseheight = (float)World.Heightmap[(int)pos.X, (int)pos.Y];
|
||||
|
||||
//Calculate the difference between the actual coordinates and the integer coordinates
|
||||
float xdiff = pos.X - (float)((int)pos.X);
|
||||
float ydiff = pos.Y - (float)((int)pos.Y);
|
||||
|
||||
//Use the equation of the tangent plane to adjust the height to account for slope
|
||||
Vector3 pos = m_host.GetWorldPosition();
|
||||
pos.X += (float)offset.x;
|
||||
pos.Y += (float)offset.y;
|
||||
|
||||
return (((vsn.x * xdiff) + (vsn.y * ydiff)) / (-1 * vsn.z)) + baseheight;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user