diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-13 21:31:53 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-13 21:31:53 -0700 |
| commit | 69f0407637a071d79d73115e4ae9c0ab526066a7 (patch) | |
| tree | c22f8fa6e761985a70d86ad023b54fc374f6f6a3 /src/sim/materials | |
| parent | feefeecec6c6050635b2c016452dfa1529575987 (diff) | |
parallelization
Diffstat (limited to 'src/sim/materials')
| -rw-r--r-- | src/sim/materials/water.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/sim/materials/water.rs b/src/sim/materials/water.rs index 65782dd..d76ec5b 100644 --- a/src/sim/materials/water.rs +++ b/src/sim/materials/water.rs @@ -25,6 +25,17 @@ pub fn sim_update(ctx: &mut UpdateCtx) { return; } + // if we can't move left, just move right + if !can_move_left { + ctx.candidates_swap(&[(1, 0)]); + return; + } + // and vice versa + if !can_move_right { + ctx.candidates_swap(&[(-1, 0)]); + return; + } + // find the closest hole within 20 pixels (TODO optimize) // a hole is any space below us with a lesser density // prevents equidistance stuck state @@ -35,9 +46,6 @@ pub fn sim_update(ctx: &mut UpdateCtx) { } else { -starting_side }; - if (side == 1 && !can_move_right) || (side == -1 && !can_move_left) { - continue; - } let offset = side * (1 + i / 2); let hole_target = ctx.get_cell(offset, 1); |
