Faster roof scan and heat pass with identical results (t21)
- The roof is rescanned only in area columns that changed since the last scan: a quiet Huge world goes from 4.60 to 1.88 ms per scan (every 20 ticks). - The heat pass skips react() for solids and powders below their first reaction threshold: Huge world digging 2.54 -> 2.34 ms/tick, quiet 1.39 -> 1.18. - Every suite's output is identical apart from timing lines; seeds make the same worlds. - test/t_sim_optimizations.js checks the dirty roof against a full scan and the heat loop against the reference loop byte for byte. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+12
-1
@@ -35,7 +35,18 @@ function checkLedger() {
|
||||
|
||||
// Topmost non-air cell of each column: air above it can shed heat to the sky.
|
||||
function updateRoof() {
|
||||
for (let x = 0; x < W; x++) {
|
||||
scanRoof(0, W);
|
||||
roofDirty.fill(0);
|
||||
}
|
||||
function updateDirtyRoof() {
|
||||
for (let cx = 0; cx < CW; cx++) {
|
||||
if (!roofDirty[cx]) continue;
|
||||
scanRoof(cx << 5, Math.min(W, (cx + 1) << 5));
|
||||
roofDirty[cx] = 0;
|
||||
}
|
||||
}
|
||||
function scanRoof(x0, x1) {
|
||||
for (let x = x0; x < x1; x++) {
|
||||
let y = 0;
|
||||
for (; y < H; y++) { const ph = PH[mat[y * W + x]]; if (ph === PH_SOLID || ph === PH_POWDER || ph === PH_LIQUID) break; }
|
||||
roofY[x] = y;
|
||||
|
||||
Reference in New Issue
Block a user