Skip to content

Commit 39042d2

Browse files
authored
Merge pull request #40 from johncohn/feature/substeps-flag
Add -substeps: trade solver accuracy for CPU headroom on slower hardware
2 parents e07a526 + 731a44f commit 39042d2

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ func main() {
3030
scenePath := flag.String("scene", "", "path to an .afoil scene file to load at startup instead of the interactive default foil")
3131
fullscreen := flag.Bool("fullscreen", false, "start in full screen")
3232
hideControls := flag.Bool("hidecontrols", false, "hide every panel and control, showing only the flow image (kiosk mode)")
33+
substepsFlag := flag.Int("substeps", substeps, "solver steps per displayed frame; lower this on slower hardware to trade physical accuracy for CPU headroom")
3334
flag.Parse()
3435

36+
if *substepsFlag < 1 {
37+
log.Fatalf("kutta: -substeps %d: must be at least 1", *substepsFlag)
38+
}
39+
substeps = *substepsFlag
40+
3541
ebiten.SetWindowSize(winW, winH)
3642
ebiten.SetWindowTitle(windowTitle)
3743
ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled)

substeps_js.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ package main
1212
// The trade is that the flow evolves slower in wall-clock time than on the
1313
// desktop. Smooth and slow reads better than fast and juddering, and the
1414
// physics per step is identical either way.
15-
const substeps = 1
15+
//
16+
// It's a var, not a const, so the same -substeps flag in main.go that
17+
// overrides the native default can override this one too.
18+
var substeps = 1

substeps_other.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ package main
55
// substeps is how many solver steps advance per displayed frame. A native build
66
// runs a step in about 2.3 ms on this grid, so three of them fit inside a 60 Hz
77
// frame with room left for the smoke, the field and the panels.
8-
const substeps = 3
8+
//
9+
// It's a var, not a const: the -substeps flag in main.go overrides it, to
10+
// trade physical accuracy/responsiveness for CPU headroom on slower hardware
11+
// (e.g. a Raspberry Pi) without a rebuild.
12+
var substeps = 3

0 commit comments

Comments
 (0)