varregion: add ITerrainChannel.GetHeightAtXYZ() for eventual mesh terrain.

Implementation of same in TerrainChannel.cs.
Check for bounds in TerrainChannel[x,y] to prevent array access exceptions.
varregion
Robert Adams 2013-11-28 08:22:41 -08:00
parent 7aa00632b9
commit 109136c074
2 changed files with 15 additions and 1 deletions

View File

@ -37,6 +37,8 @@ namespace OpenSim.Region.Framework.Interfaces
double this[int x, int y] { get; set; }
float GetHeightAtXYZ(float x, float y, float z);
// Return the packaged terrain data for passing into lower levels of communication
TerrainData GetTerrainData();

View File

@ -156,7 +156,11 @@ namespace OpenSim.Region.Framework.Scenes
// ITerrainChannel.this[x,y]
public double this[int x, int y]
{
get { return (double)m_terrainData[x, y]; }
get {
if (x < 0 || x >= Width || y < 0 || y >= Height)
return 0;
return (double)m_terrainData[x, y];
}
set
{
if (Double.IsNaN(value) || Double.IsInfinity(value))
@ -166,6 +170,14 @@ namespace OpenSim.Region.Framework.Scenes
}
}
// ITerrainChannel.GetHieghtAtXYZ(x, y, z)
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];
}
// ITerrainChannel.Tainted()
public bool Tainted(int x, int y)
{