mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 11:57:03 +08:00
change get terrain height
This commit is contained in:
@@ -5563,65 +5563,7 @@ Environment.Exit(1);
|
||||
// does a linear approximation of the height at this intermediate point.
|
||||
public float GetGroundHeight(float x, float y)
|
||||
{
|
||||
int ix;
|
||||
int iy;
|
||||
float dx;
|
||||
float dy;
|
||||
|
||||
// make position fit into array
|
||||
if (x < 0)
|
||||
{
|
||||
ix = 0;
|
||||
dx = 0;
|
||||
}
|
||||
else if (x < Heightmap.Width - 1)
|
||||
{
|
||||
ix = (int)x;
|
||||
dx = x - ix;
|
||||
}
|
||||
else // out world use external height
|
||||
{
|
||||
ix = Heightmap.Width - 2;
|
||||
dx = 0;
|
||||
}
|
||||
if (y < 0)
|
||||
{
|
||||
iy = 0;
|
||||
dy = 0;
|
||||
}
|
||||
else if (y < Heightmap.Height - 1)
|
||||
{
|
||||
iy = (int)y;
|
||||
dy = y - iy;
|
||||
}
|
||||
else
|
||||
{
|
||||
iy = Heightmap.Height - 2;
|
||||
dy = 0;
|
||||
}
|
||||
|
||||
float h1;
|
||||
float h2;
|
||||
float h0 = Heightmap[ix, iy]; // 0,0 vertice
|
||||
|
||||
if (dy > dx)
|
||||
{
|
||||
++iy;
|
||||
h2 = Heightmap[ix, iy]; // 0,1 vertice
|
||||
h1 = (h2 - h0) * dy; // 0,1 vertice minus 0,0
|
||||
++ix;
|
||||
h2 = (Heightmap[ix, iy] - h2) * dx; // 1,1 vertice minus 0,1
|
||||
}
|
||||
else
|
||||
{
|
||||
++ix;
|
||||
h2 = Heightmap[ix, iy]; // vertice 1,0
|
||||
h1 = (h2 - h0) * dx; // 1,0 vertice minus 0,0
|
||||
++iy;
|
||||
h2 = (Heightmap[ix, iy] - h2) * dy; // 1,1 vertice minus 1,0
|
||||
}
|
||||
|
||||
return h0 + h1 + h2;
|
||||
return Heightmap.GetHeight(x, y);
|
||||
}
|
||||
|
||||
private void CheckHeartbeat()
|
||||
|
||||
@@ -159,12 +159,14 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
}
|
||||
|
||||
// ITerrainChannel.GetHieghtAtXYZ(x, y, z)
|
||||
public float GetHeight(float x, float y)
|
||||
{
|
||||
return m_terrainData.GetHeight(x, y);
|
||||
}
|
||||
|
||||
public float GetHeightAtXYZ(float x, float y, float z)
|
||||
{
|
||||
if (x < 0 || x >= Width || y < 0 || y >= Height)
|
||||
return 0;
|
||||
return m_terrainData[(int)x, (int)y];
|
||||
return m_terrainData.GetHeight(x, y);
|
||||
}
|
||||
|
||||
// ITerrainChannel.Tainted()
|
||||
|
||||
Reference in New Issue
Block a user