aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRobert Adams2013-11-28 08:22:41 -0800
committerRobert Adams2013-11-28 08:22:41 -0800
commit109136c074fd4ce68f4c5615c05665a81fa7c7d9 (patch)
treeb7fbc4f356f831fc826aaeb804012a056485936b
parentvarregion: many replacements of in-place arithmetic with calls to (diff)
downloadopensim-SC-109136c074fd4ce68f4c5615c05665a81fa7c7d9.zip
opensim-SC-109136c074fd4ce68f4c5615c05665a81fa7c7d9.tar.gz
opensim-SC-109136c074fd4ce68f4c5615c05665a81fa7c7d9.tar.bz2
opensim-SC-109136c074fd4ce68f4c5615c05665a81fa7c7d9.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/TerrainChannel.cs14
2 files changed, 15 insertions, 1 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs b/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs
index cc8a236..469bd31 100644
--- a/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs
+++ b/OpenSim/Region/Framework/Interfaces/ITerrainChannel.cs
@@ -37,6 +37,8 @@ namespace OpenSim.Region.Framework.Interfaces
37 37
38 double this[int x, int y] { get; set; } 38 double this[int x, int y] { get; set; }
39 39
40 float GetHeightAtXYZ(float x, float y, float z);
41
40 // Return the packaged terrain data for passing into lower levels of communication 42 // Return the packaged terrain data for passing into lower levels of communication
41 TerrainData GetTerrainData(); 43 TerrainData GetTerrainData();
42 44
diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
index a5b42ff..b4b1823 100644
--- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
+++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs
@@ -156,7 +156,11 @@ namespace OpenSim.Region.Framework.Scenes
156 // ITerrainChannel.this[x,y] 156 // ITerrainChannel.this[x,y]
157 public double this[int x, int y] 157 public double this[int x, int y]
158 { 158 {
159 get { return (double)m_terrainData[x, y]; } 159 get {
160 if (x < 0 || x >= Width || y < 0 || y >= Height)
161 return 0;
162 return (double)m_terrainData[x, y];
163 }
160 set 164 set
161 { 165 {
162 if (Double.IsNaN(value) || Double.IsInfinity(value)) 166 if (Double.IsNaN(value) || Double.IsInfinity(value))
@@ -166,6 +170,14 @@ namespace OpenSim.Region.Framework.Scenes
166 } 170 }
167 } 171 }
168 172
173 // ITerrainChannel.GetHieghtAtXYZ(x, y, z)
174 public float GetHeightAtXYZ(float x, float y, float z)
175 {
176 if (x < 0 || x >= Width || y < 0 || y >= Height)
177 return 0;
178 return m_terrainData[(int)x, (int)y];
179 }
180
169 // ITerrainChannel.Tainted() 181 // ITerrainChannel.Tainted()
170 public bool Tainted(int x, int y) 182 public bool Tainted(int x, int y)
171 { 183 {