Repository navigation
A resting sphere's normal in single precision, so it comes to rest - #243
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Progress at a glance
tiny_rowbench scene on both sides: eight touching spheres on a floor, never sleepingThe 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:
Results move