aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs19
1 files changed, 9 insertions, 10 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
index 4f58f71..0e47e1b 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
@@ -44,7 +42,7 @@ namespace libTerrain
44 Channel waterFlow = new Channel(w, h); 42 Channel waterFlow = new Channel(w, h);
45 43
46 NeighbourSystem type = NeighbourSystem.Moore; 44 NeighbourSystem type = NeighbourSystem.Moore;
47 int NEIGHBOUR_ME = 4; 45 int NEIGHBOUR_ME = 4;
48 46
49 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; 47 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5;
50 48
@@ -52,7 +50,7 @@ namespace libTerrain
52 { 50 {
53 water += rain; 51 water += rain;
54 52
55 sediment = terrain * water; 53 sediment = terrain*water;
56 terrain -= sediment; 54 terrain -= sediment;
57 55
58 for (int x = 1; x < w - 1; x++) 56 for (int x = 1; x < w - 1; x++)
@@ -72,7 +70,8 @@ namespace libTerrain
72 coords[0] += x; 70 coords[0] += x;
73 coords[1] += y; 71 coords[1] += y;
74 72
75 heights[j] = map[coords[0], coords[1]] + water.map[coords[0], coords[1]] + sediment.map[coords[0], coords[1]]; 73 heights[j] = map[coords[0], coords[1]] + water.map[coords[0], coords[1]] +
74 sediment.map[coords[0], coords[1]];
76 diffs[j] = heightCenter - heights[j]; 75 diffs[j] = heightCenter - heights[j];
77 } 76 }
78 } 77 }
@@ -97,13 +96,13 @@ namespace libTerrain
97 if (totalCellsCounted == 1) 96 if (totalCellsCounted == 1)
98 continue; 97 continue;
99 98
100 double averageHeight = totalHeight / totalCellsCounted; 99 double averageHeight = totalHeight/totalCellsCounted;
101 double waterAmount = Math.Min(water.map[x, y], heightCenter - averageHeight); 100 double waterAmount = Math.Min(water.map[x, y], heightCenter - averageHeight);
102 101
103 // TODO: Check this. 102 // TODO: Check this.
104 waterFlow.map[x, y] += waterFlow.map[x, y] - waterAmount; 103 waterFlow.map[x, y] += waterFlow.map[x, y] - waterAmount;
105 104
106 double totalInverseDiff = waterAmount / totalHeightDiff; 105 double totalInverseDiff = waterAmount/totalHeightDiff;
107 106
108 for (int j = 0; j < NEIGHBOUR_MAX; j++) 107 for (int j = 0; j < NEIGHBOUR_MAX; j++)
109 { 108 {
@@ -115,7 +114,8 @@ namespace libTerrain
115 114
116 if (diffs[j] > 0) 115 if (diffs[j] > 0)
117 { 116 {
118 waterFlow.SetWrap(coords[0], coords[1], waterFlow.map[coords[0], coords[1]] + diffs[j] * totalInverseDiff); 117 waterFlow.SetWrap(coords[0], coords[1],
118 waterFlow.map[coords[0], coords[1]] + diffs[j]*totalInverseDiff);
119 } 119 }
120 } 120 }
121 } 121 }
@@ -131,7 +131,7 @@ namespace libTerrain
131 { 131 {
132 for (int y = 0; y < h; y++) 132 for (int y = 0; y < h; y++)
133 { 133 {
134 double deposition = sediment.map[x, y] - water.map[x, y] * solubility; 134 double deposition = sediment.map[x, y] - water.map[x, y]*solubility;
135 if (deposition > 0) 135 if (deposition > 0)
136 { 136 {
137 sediment.map[x, y] -= deposition; 137 sediment.map[x, y] -= deposition;
@@ -139,7 +139,6 @@ namespace libTerrain
139 } 139 }
140 } 140 }
141 } 141 }
142
143 } 142 }
144 } 143 }
145 } 144 }