aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/TerrainData.cs50
-rw-r--r--OpenSim/Region/Framework/Scenes/TerrainCompressor.cs24
2 files changed, 41 insertions, 33 deletions
diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs
index 5cec2b5..f99dd00 100644
--- a/OpenSim/Framework/TerrainData.cs
+++ b/OpenSim/Framework/TerrainData.cs
@@ -80,6 +80,10 @@ namespace OpenSim.Framework
80 80
81 public abstract float[] GetFloatsSerialized(); 81 public abstract float[] GetFloatsSerialized();
82 public abstract double[,] GetDoubles(); 82 public abstract double[,] GetDoubles();
83
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);
86
83 public abstract TerrainData Clone(); 87 public abstract TerrainData Clone();
84 } 88 }
85 89
@@ -275,6 +279,37 @@ namespace OpenSim.Framework
275 return ret; 279 return ret;
276 } 280 }
277 281
282 public override void GetPatchMinMax(int px, int py, out float zmin, out float zmax)
283 {
284 zmax = float.MinValue;
285 zmin = float.MaxValue;
286
287 int startx = px * 16;
288 int starty = py * 16;
289 for (int i = startx; i < startx + 16; i++)
290 {
291 for (int j = starty; j < starty + 16; j++)
292 {
293 float val = m_heightmap[i, j];
294 if (val > zmax) zmax = val;
295 if (val < zmin) zmin = val;
296 }
297 }
298 }
299
300 public override void GetPatchBlock(ref float[] block, int px, int py, float sub, float premult)
301 {
302 int k = 0;
303 int startX = px * 16;
304 int startY = py * 16;
305 for (int y = startY; y < startY + 16; y++)
306 {
307 for (int x = startX; x < startX + 16; x++)
308 {
309 block[k++] = (m_heightmap[x, y] - sub) * premult;
310 }
311 }
312 }
278 313
279 // ============================================================= 314 // =============================================================
280 315
@@ -476,13 +511,9 @@ namespace OpenSim.Framework
476 ret = str.ToArray(); 511 ret = str.ToArray();
477 } 512 }
478 } 513 }
479 catch 514 catch {}
480 {
481 515
482 } 516 m_log.DebugFormat("{0} V2D {1} bytes", LogHeader, ret.Length);
483
484 m_log.DebugFormat("{0} V2D {1} bytes",
485 LogHeader, ret.Length);
486 517
487 return ret; 518 return ret;
488 } 519 }
@@ -520,12 +551,9 @@ namespace OpenSim.Framework
520 } 551 }
521 } 552 }
522 } 553 }
523 catch 554 catch {}
524 {
525 555
526 } 556 m_log.DebugFormat("{0} V2DGzip {1} bytes", LogHeader, ret.Length);
527 m_log.DebugFormat("{0} V2DGzip {1} bytes",
528 LogHeader, ret.Length);
529 return ret; 557 return ret;
530 } 558 }
531 559
diff --git a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
index 8d79a86..d3f2737 100644
--- a/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
+++ b/OpenSim/Region/Framework/Scenes/TerrainCompressor.cs
@@ -256,18 +256,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
256 float zmax = float.MinValue; 256 float zmax = float.MinValue;
257 float zmin = float.MaxValue; 257 float zmin = float.MaxValue;
258 258
259 int startx = patchX * 16; 259 terrData.GetPatchMinMax(patchX, patchY, out zmin, out zmax);
260 int starty = patchY * 16;
261
262 for (int i = startx; i < startx + 16; i++)
263 {
264 for (int j = starty; j < starty + 16; j++)
265 {
266 float val = terrData[i, j];
267 if (val > zmax) zmax = val;
268 if (val < zmin) zmin = val;
269 }
270 }
271 260
272 header.DCOffset = zmin; 261 header.DCOffset = zmin;
273 frange = ((zmax - zmin) + 1.0f); 262 frange = ((zmax - zmin) + 1.0f);
@@ -380,16 +369,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
380 header.QuantWBits = wordsize; 369 header.QuantWBits = wordsize;
381 header.QuantWBits |= wordsize << 4; 370 header.QuantWBits |= wordsize << 4;
382 371
383 int k = 0; 372 terrData.GetPatchBlock(ref block, patchX, patchY, sub, premult);
384 int startX = patchX * 16;
385 int startY = patchY * 16;
386 for (int y = startY; y < startY + 16; y++)
387 {
388 for (int x = startX; x < startX + 16; x++)
389 {
390 block[k++] = (terrData[x, y] - sub) * premult;
391 }
392 }
393 373
394 wbits = (prequant >> 1); 374 wbits = (prequant >> 1);
395 375