Skip to content

feat: air field, fans, and gunpowder shockwaves - #8

Merged
chowjiaming merged 8 commits into
mainfrom
feat/air-fans
Aug 14, 2026
Merged

chowjiaming merged 8 commits into
mainfrom
feat/air-fans

Conversation

@chowjiaming

Copy link
Copy Markdown
Owner

Summary

  • Add a coarse integer air field (AIR_CELL=4) so fans blow gases and boil/gunpowder launch a pressure wave.
  • Four static fan cells (one palette button cycles facing) and gunpowder that falls like sand, then explodes to fire (stone/fans survive).
  • Stabilize Euler as a two-pass update (velocity from pressure, then pressure from the new velocities) with i32 intermediates so a grain or fan does not saturate the field.

Test plan

  • just verify (fmt, clippy -D warnings, tests, wasm-pack --target web)
  • Paint Fan → and steam in the same 4×4 to the right; steam should drift right, sand on a floor should not blow away
  • Paint gunpowder + fire; 3×3 becomes fire, stone/fans in the blast stay, empty pixels pulse with the shockwave
  • Boil water next to fire; steam appears and a pressure pulse is visible on empty cells
  • Click the Fan swatch repeatedly: → ← ↑ ↓ cycle; Gunpowder paints as charcoal
  • Leave a fan running ~10s: gases should not jitter at max speed and empty space should stay a faint tint, not solid red/green

Native bench after the solver fix (960×600, 300 steps): sparse 839 steps/s, dense top-quarter 353 steps/s.

Reserve ids 7–11 and lock fans like stone so the air pass can paint
walls without them being overwritten by sand.
Run a 4×4 Eulerian pv/vx/vy step before particles so static fans
keep blowing even when their chunk is idle.
Orthogonal fans sharing an air cell were composing because inject_fans
only set the facing axis. Each fan now assigns both vx and vy so the
last pixel in scan order fully wins the shared vector.
Steam and fire take one air-axis move before they rise so a fan in
the same 4×4 can blow them sideways.
Gunpowder falls like sand and turns a 3×3 into fire, leaving stone
and fans, so shockwaves have a source that is not the fan field.
Show fan flow on empty pixels and expose facing-cycle plus gunpowder
on the palette without exporting air buffers to JS.
Pressure from last tick's velocity amplified the 4-cell mode. Compute
velocity first, then pressure from the new field, and widen diffs to i32.

Bench 960×600 native (300 steps, after this change): sparse 839 steps/s,
dense top-quarter 353 steps/s.
@cursor

cursor Bot commented Aug 14, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@chowjiaming
chowjiaming merged commit 682736d into main Aug 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant