aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-07-29 12:11:54 +0000
committerAdam Frisby2007-07-29 12:11:54 +0000
commit7d2f976b14a526f706cf33bbefce7d4d75d28da5 (patch)
treedddd951edc5b6e8b8d492827ac7de2e6fb767622 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
parent* Switched back to NullStorage until crazy DB4o error is fixed. (diff)
downloadopensim-SC-7d2f976b14a526f706cf33bbefce7d4d75d28da5.zip
opensim-SC-7d2f976b14a526f706cf33bbefce7d4d75d28da5.tar.gz
opensim-SC-7d2f976b14a526f706cf33bbefce7d4d75d28da5.tar.bz2
opensim-SC-7d2f976b14a526f706cf33bbefce7d4d75d28da5.tar.xz
* Fixed a potential div by zero with terrain commands.
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs')
-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