luvcraft/physics-tests.lisp
A flat world: dirt at y=0, grass at y=1, width cells square from the origin.
Resting on the grass top at y=2, a slop under its radius.
The bouncy ball rose again after landing; the dead one never did.
It got somewhere: rolling friction is off, so it barely slowed.
And it never hopped at a seam.
A ball thrown into the pile wakes what it hits, and they wake others.
A box a cell wide walks into the ball from the west at 3 cells/s.
The slot is reused with a new generation, so the old handle stays dead.
It fell into the hole.
A ball flying at 10 cells/s into a box owned by :turtle.
(&key (width 32))(&key (id (gensym "BLOCK-WORLD-"))
(chunk-width 16)
(chunk-height 16)
(chunk-depth 16)
(cell-extent 1d0)
source)(world x y z)(world x y z)Return one site as BLOCK and :RESIDENT, or NIL and :ABSENT. This sparse world-coordinate accessor constructs coordinate descriptors and a chunk lookup key. It is appropriate for inspectors, ray hits, collision probes, and sparse interaction. Algorithms over many cells should select a chunk/domain once and use…
(physics steps)(world &optional dt)Advance WORLD by DT seconds (its step by default) and return it. Events from the step are then readable until the next step begins. #IDVK7G
(&key terrain (kernels :fastest))A ball to throw. The hand never runs out: each throw is a new body.
(world x y z &key (radius 0.25) (mass 1.0) (vx 0.0) (vy 0.0) (vz 0.0)
(restitution 0.3) (friction 0.5) (rolling-resistance 0.01)
(damping 0.05) (kind 0)
(collides-with-bodies-p t) (hit-report-p nil)
(never-sleep-p nil) (lifetime nil))(world handle)Test whether one compatible scalar is less than another.
The componentwise absolute value of a raw value.
Subtraction or unary negation.
How much overlap a contact tolerates before it pushes, in cells.
(world handle)(world)Check every forwarding address, the way B3VALIDATESOLVERSETS does: each live id names a row whose handle names it back, and each contact row is where its key says. Signal on the first inconsistency; return T.
(world handle)Logical conjunction of tests and raw truth values.
Logical negation of one test or raw truth value.
The maximum of compatible quantities.
Test whether one compatible scalar is greater than another.
Addition over compatible quantities.
Multiplication and scalar scaling.
(world handle)Compare compatible quantities and produce dimensionless values.
Test whether two compatible scalars are equal.
Division of two represented quantities.
(world)(world min-x min-y min-z max-x max-y max-z
&key (vx 0.0) (vy 0.0) (vz 0.0) owner)(world)(handle)(world x y z radius)(kernels steps)(world)A hash of every body's position and velocity, in set and row order, so two runs of the same code can be compared. Same-image reproducibility is the claim (#S6T2MV); this is how it is policed.
Approach speed above which a contact reports a hit event, cells/s.
Executable claims for the sphere physics: what a pile does, what a rolling ball does not do, and that the wide kernels are the scalar ones.