aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs21
1 files changed, 17 insertions, 4 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
index 18e40b5..76bad27 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
@@ -65,6 +65,12 @@ namespace libTerrain
65 { 65 {
66 SetDiff(); 66 SetDiff();
67 67
68 if (minv == maxv)
69 {
70 Fill(minv);
71 return this;
72 }
73
68 double max = FindMax(); 74 double max = FindMax();
69 double min = FindMin(); 75 double min = FindMin();
70 76
@@ -74,11 +80,18 @@ namespace libTerrain
74 { 80 {
75 for (y = 0; y < h; y++) 81 for (y = 0; y < h; y++)
76 { 82 {
77 double val = (map[x, y] - min) * (1.0 / max - min); 83 if (min != max)
78 val *= maxv - minv; 84 {
79 val += minv; 85 double val = (map[x, y] - min) * (1.0 / max - min);
86 val *= maxv - minv;
87 val += minv;
80 88
81 map[x, y] = val; 89 map[x, y] = val;
90 }
91 else
92 {
93 map[x, y] = 0.5;
94 }
82 } 95 }
83 } 96 }
84 97