Skip to content

Commit e4a61e9

Browse files
committed
Cleaning up
1 parent e4cffe5 commit e4a61e9

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

HydraulicErosion.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ void HydraulicErosion::Simulate(std::vector<std::vector<float>> &map) {
4848
HeightAndGradient heightAndGradient;
4949

5050
// Cast position floats to ints
51-
droplet.node.x = static_cast<int>(droplet.position.x);
52-
droplet.node.y = static_cast<int>(droplet.position.y);
51+
droplet.node.x = (int)droplet.position.x;
52+
droplet.node.y = (int)droplet.position.y;
5353

5454
// Calculate droplet's offset inside the cell (0,0) = at NW node, (1,1) = at SE node
5555
droplet.cellOffset.x = droplet.position.x - droplet.node.x;
@@ -76,20 +76,17 @@ void HydraulicErosion::Simulate(std::vector<std::vector<float>> &map) {
7676

7777
// Stop simulating droplet if it's not moving or has flowed over edge of map
7878
if ((droplet.direction.x == 0 && droplet.direction.y == 0) ||
79-
droplet.position.x < 0 ||
80-
droplet.position.x >= xMax ||
81-
droplet.position.y < 0 ||
82-
droplet.position.y >= yMax ||
83-
droplet.node.x < 0 ||
84-
droplet.node.y < 0) {
79+
droplet.position.x < 0 || droplet.position.x >= xMax ||
80+
droplet.position.y < 0 || droplet.position.y >= yMax ||
81+
droplet.node.x < 0 || droplet.node.y < 0) {
8582
break;
8683
}
8784

8885
// Find the droplet's new height and calculate the deltaHeight
8986
float newHeight = this->CalculateHeightAndGradient(map, droplet).height;
9087
float oldHeight = heightAndGradient.height;
9188
float deltaHeight = newHeight - oldHeight;
92-
89+
9390
// Calculate the droplet's sediment capacity (higher when moving fast down a slope and contains lots of water)
9491
float sedimentCapacity = std::max(-deltaHeight * droplet.velocity * droplet.water * this->config.sedimentCapacityFactor, this->config.minSedimentCapacity);
9592

0 commit comments

Comments
 (0)