Skip to content

A resting sphere's normal in single precision, so it comes to rest - #243

Merged
nicolas-maman merged 1 commit into
mainfrom
tiny-row
Nov 26, 2026
Merged

nicolas-maman merged 1 commit into
mainfrom
tiny-row

Conversation

@nicolas-maman

Copy link
Copy Markdown
Collaborator

Progress at a glance

  • Shallow sphere-hull and sphere-triangle normals built in float from the closest points, as Box3D builds them
  • Every sphere in a resting row now settles to exactly zero velocity, as in Box3D
  • New tiny_row bench scene on both sides: eight touching spheres on a floor, never sleeping
  • Golden trace regenerated; full local suite green on Aether 0.946.0, no warnings

The defect

A row of eight spheres touching on a floor ran at 9.0 µs a step, against Box3D's 5.1, with the same colours. Box3D's spheres come to exact rest; ours kept rolling at about 1e-17 m/s forever.

The ground contact's normal was (8.9e-16, 1, 0). GJK's closest points in double keep one last bit of rounding noise across it. Each step the normal impulse pushed the sphere sideways and friction turned that into a roll, so the velocity never reached zero. Products of those residuals were subnormal floats, for example a vertical velocity of 6e-39. Every later solve and finalize step then paid microcode assists on them. The same build with the CPU's flush-to-zero mode on runs at 6.1 µs, which shows that was the cost.

Box3D computes these contacts in float, where that noise rounds away and the normal comes out exactly (0, 1, 0). The manifold stores normals and anchors in float anyway, so both paths now narrow the closest points and form the normal and point in float.

Numbers

Pinned, best of four, ms per step:

Scene main this PR Box3D single Box3D double
tiny_row 0.00900 0.00609 0.00509 0.00524
tiny 0.00366 0.00365 0.00346 0.00367
spinner 3.186 3.183 3.038 3.176
sleep 1.873 1.871 1.766 1.869

Results move

A row of eight spheres touching on a floor stepped at 9.0 us where
Box3D takes 5.1, with the same colours. Box3D's spheres came to an exact
rest; ours rolled at 1e-17 m/s forever. The ground contact's normal was
(8.9e-16, 1, 0): the double closest points of the distance query keep a
last bit of noise across it, the normal impulse pushed the sphere
sideways each step, and the residual never reached exact zero. Products
of those residuals were subnormal (a vertical velocity of 6e-39), and
every later solve and finalize paid for them in microcode assists (with
flush-to-zero the same build steps at 6.1 us).

collide_hull_and_sphere's shallow path and collide_triangle_and_sphere
now form the normal and point in single precision, the manifold's own
and the reference's, from the closest points narrowed. Every sphere
rests at exactly zero, as in Box3D, and the row steps at 6.1 us.

The bench gains tiny_row on both sides. The golden trace is regenerated:
the wave pile sleeps at step 324 where it slept at 318 (Box3D's 314), and
the query spawn's and rolling mix's bits move; the ragdolls and mesh drop
are unchanged.
@nicolas-maman
nicolas-maman merged commit f01c282 into main Nov 26, 2026
3 checks passed
@nicolas-maman
nicolas-maman deleted the tiny-row branch November 26, 2026 22:34
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