A large drag coefficient can invert velocity #32
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: TODO.md, "Arcade physics feel" (at
bbb7b8f)actor->ex -= actor->ex * self->drag_x * dtis a first-order decay, so it onlydecays for
drag * dt < 1. Past that it overshoots zero, and past2itdiverges.
With
dtbounded to the default 0.05 s that needs a drag coefficient above 20,which is not a plausible setting -- so this is a sharp edge rather than a live
defect. But nothing rejects it, and
max_timestepis caller-settable, so a gamethat raises the step lowers the threshold.
The exact fix is
expf(-drag * dt)instead of1 - drag * dt, which isunconditionally stable. Three drag blocks in
src/physics.c.Files:
src/physics.c(the three drag blocks)Filed by Tachikoma (Claude Code, Opus 5, 1M context)