diff options
Diffstat (limited to 'OpenSim/Framework/TerrainData.cs')
-rw-r--r-- | OpenSim/Framework/TerrainData.cs | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs index f99dd00..7b99427 100644 --- a/OpenSim/Framework/TerrainData.cs +++ b/OpenSim/Framework/TerrainData.cs | |||
@@ -82,7 +82,7 @@ namespace OpenSim.Framework | |||
82 | public abstract double[,] GetDoubles(); | 82 | public abstract double[,] GetDoubles(); |
83 | 83 | ||
84 | public abstract void GetPatchMinMax(int px, int py, out float zmin, out float zmax); | 84 | public abstract void GetPatchMinMax(int px, int py, out float zmin, out float zmax); |
85 | public abstract void GetPatchBlock(ref float[] block, int px, int py, float sub, float premult); | 85 | public abstract void GetPatchBlock(float[] block, int px, int py, float sub, float premult); |
86 | 86 | ||
87 | public abstract TerrainData Clone(); | 87 | public abstract TerrainData Clone(); |
88 | } | 88 | } |
@@ -279,34 +279,47 @@ namespace OpenSim.Framework | |||
279 | return ret; | 279 | return ret; |
280 | } | 280 | } |
281 | 281 | ||
282 | public override void GetPatchMinMax(int px, int py, out float zmin, out float zmax) | 282 | public override unsafe void GetPatchMinMax(int px, int py, out float zmin, out float zmax) |
283 | { | 283 | { |
284 | zmax = float.MinValue; | 284 | zmax = float.MinValue; |
285 | zmin = float.MaxValue; | 285 | zmin = float.MaxValue; |
286 | 286 | ||
287 | int startx = px * 16; | 287 | int stride = m_heightmap.GetLength(1); |
288 | |||
289 | int startx = px * 16 * stride; | ||
290 | int endx = (px + 1) * 16 * stride; | ||
288 | int starty = py * 16; | 291 | int starty = py * 16; |
289 | for (int i = startx; i < startx + 16; i++) | 292 | fixed (float* map = m_heightmap) |
290 | { | 293 | { |
291 | for (int j = starty; j < starty + 16; j++) | 294 | for (int i = startx; i < endx; i += stride) |
292 | { | 295 | { |
293 | float val = m_heightmap[i, j]; | 296 | float* p = &map[i]; |
294 | if (val > zmax) zmax = val; | 297 | for (int j = starty; j < starty + 16; j++) |
295 | if (val < zmin) zmin = val; | 298 | { |
299 | float val = p[j]; | ||
300 | if (val > zmax) zmax = val; | ||
301 | if (val < zmin) zmin = val; | ||
302 | } | ||
296 | } | 303 | } |
297 | } | 304 | } |
298 | } | 305 | } |
299 | 306 | ||
300 | public override void GetPatchBlock(ref float[] block, int px, int py, float sub, float premult) | 307 | public override unsafe void GetPatchBlock(float[] _block, int px, int py, float sub, float premult) |
301 | { | 308 | { |
302 | int k = 0; | 309 | int k = 0; |
303 | int startX = px * 16; | 310 | int stride = m_heightmap.GetLength(1); |
311 | |||
312 | int startX = px * 16 * stride; | ||
313 | int endX = (px + 1) * 16 * stride; | ||
304 | int startY = py * 16; | 314 | int startY = py * 16; |
305 | for (int y = startY; y < startY + 16; y++) | 315 | fixed(float* block = _block, map = m_heightmap) |
306 | { | 316 | { |
307 | for (int x = startX; x < startX + 16; x++) | 317 | for (int y = startY; y < startY + 16; y++) |
308 | { | 318 | { |
309 | block[k++] = (m_heightmap[x, y] - sub) * premult; | 319 | for (int x = startX; x < endX; x += stride) |
320 | { | ||
321 | block[k++] = (map[x + y] - sub) * premult; | ||
322 | } | ||
310 | } | 323 | } |
311 | } | 324 | } |
312 | } | 325 | } |