From 3af71b8aa4976d2eb6ed9eb61e9e8ac5bd6d309a Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 18 May 2025 10:56:57 -0700 Subject: Fix unupdated sand Just grow the dirty rect by 1 on each side, update neighbors of any updated sand. --- src/sandbox.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/sandbox.cpp') diff --git a/src/sandbox.cpp b/src/sandbox.cpp index c6d0294..2c09d77 100644 --- a/src/sandbox.cpp +++ b/src/sandbox.cpp @@ -102,17 +102,24 @@ void Sandbox::simulate_step() { dirty_writeto = {}; const auto [x0, y0] = dirty_curr.bl; const auto [x1, y1] = dirty_curr.tr; + // Clear update bit for this cycle for (_y = y0; _y <= y1; ++_y) { for (_x = x0; _x <= x1; ++_x) { gs(_x, _y).updated = false; } } + + // Update for (_y = y0; _y <= y1; ++_y) { for (_x = x0; _x <= x1; ++_x) { simulate_sand_tile(*this, _x, _y); } } + dirty_writeto.bl -= Pt(1, 1); + dirty_writeto.tr += Pt(1, 1); + dirty_writeto = rect_intersect(dirty_writeto, Rect(0, 0, width - 1, height - 1)); + ++ncycle; } -- cgit v1.2.3-70-g09d2