* Fix for hydraulic erosion brush. Still not working as planned, but getting closer. Bugs may be due to the water distribution pattern.

0.6.0-stable
Adam Frisby 2008-03-09 19:22:21 +00:00
parent 7cae577094
commit f89e7107bb
1 changed files with 19 additions and 9 deletions

View File

@ -37,9 +37,9 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{
NeighbourSystem type = NeighbourSystem.Moore; // Parameter
double rainHeight = 1.0;
double rainHeight = 0.2;
int rounds = 10;
double waterSaturation = 0.01; // Can carry 1% of water in height
double waterSaturation = 0.30; // Can carry 1% of water in height
#region Supporting Functions
private enum NeighbourSystem
@ -257,7 +257,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
double altitudeNeighbour = water[coords[0], coords[1]] + map[coords[0], coords[1]];
// If it's greater than me...
if (altitudeNeighbour - altitudeMe > 0)
if (altitudeNeighbour - altitudeMe < 0)
{
// Add it to our calculations
neighbours++;
@ -290,13 +290,20 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
if (coords[1] < 0)
continue;
// Skip if we dont have water to begin with.
if (water[x, y] < 0)
continue;
// Calculate our delta average
double altitudeDelta = altitudeMe - altitudeAvg;
if (altitudeDelta < 0)
continue;
// Calculate how much water we can move
double waterDelta = Math.Min(water[x, y], altitudeDelta)
* (water[coords[0], coords[1]] + map[coords[0], coords[1]])
/ altitudeTotal;
double waterMin = Math.Min(water[x, y], altitudeDelta);
double waterDelta = waterMin * ((water[coords[0], coords[1]] + map[coords[0], coords[1]])
/ altitudeTotal);
double sedimentDelta = sediment[x, y] * (waterDelta / water[x, y]);
@ -320,12 +327,15 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
double waterCapacity = waterSaturation * water[x, y];
double sedimentDeposit = Math.Max(0, sediment[x, y] - waterCapacity);
double sedimentDeposit = sediment[x, y] - waterCapacity;
if (sedimentDeposit > 0)
{
sediment[x, y] -= sedimentDeposit;
map[x, y] += sedimentDeposit;
}
}
}
}
// Deposit any remainder (should be minimal)
for (x = 0; x < water.Width; x++)