Skip to content

mesh_contact: a convex shape against a mesh or height field - #14

Merged
nicolas-maman merged 1 commit into
mainfrom
feat/mesh-contact
Sep 20, 2026
Merged

nicolas-maman merged 1 commit into
mainfrom
feat/mesh-contact

Conversation

@nicolas-maman

Copy link
Copy Markdown
Contributor

The fourteenth layer: the world-free part of Box3D's mesh_contact.c as aephysics.mesh_contact.

  • MeshContactCache with refresh_cache: the triangles under the convex shape's bounds, refreshed only when the shape leaves the query bounds (margin + speculative distance), each triangle's simplex and SAT caches matched across a refresh by sorted index.
  • compute_mesh_manifolds(cache, mesh_shape, xf_a, convex, xf_b, bounds_b, is_fast, enable_speculative, arena): a manifold per triangle in the convex shape's frame, the acceptance rules against ghost collisions, clusters within cos 5 degrees, reduce_cluster/cull_points to four points. Results live in the arena from the call's start; the caller reads them and winds the arena back.
  • The contact-side tail of the reference (warm-start matching, materials, rolling resistance, tangent velocity) is left to the dynamics' contact update.
  • test_mesh_contact.ae: 64 checks of our own. Two reference quirks kept and documented: the cull's tie rule lets zero-area points through on their separation (collinear points can keep four), and a hull face's far clip points stay as speculative points.
  • bench/mesh_contact.ae runs alone (the reference's function needs its world): box 3.2 us/step, sphere 0.7 us, capsule 3.7 us on a wave mesh.

aephysics.mesh_contact, the world-free part of Box3D's mesh_contact.c
in Aether: the triangles under the convex shape's bounds cached and
refreshed only when the shape leaves the bounds they were queried
with, each triangle keeping its simplex and separating-axis warm
starts across a refresh; a manifold per triangle in the convex shape's
frame; the acceptance rules that stop a shape crossing an interior
edge or vertex from colliding with the seam (a triangle face always, a
hull face when it lies with the triangle or is deep, the rest
tentative -- spheres by nearest-first feature ownership, hulls and
capsules skipping only the flat edges an accepted triangle owns);
clusters by manifold and triangle normal within cos 5 degrees; and
the four-point cull (the farthest pair, the largest triangle, the most
area outside). The results live in the caller's arena. What the
reference does next (matching the old manifolds for warm starting,
the materials, rolling resistance and tangent velocity) is the
contact's and comes with the dynamics.

test_mesh_contact.ae (ours; the reference tests this through its
world): the cull on placed points, a box on a grid mesh with the cache
kept and refreshed, a sphere on an interior vertex and edge (one
point), a capsule across triangles, a box on a height field and on a
ridge, and the mesh under a transform. 64 checks. Two reference quirks
kept and noted: the cull's tie rule and a hull face's far clip points.

bench/mesh_contact.ae runs alone (the reference's needs its world): a
box dragged across a wave at 3.2 us a step, a sphere at 0.7 us.
@nicolas-maman
nicolas-maman merged commit 842cbb7 into main Sep 20, 2026
1 check passed
@nicolas-maman
nicolas-maman deleted the feat/mesh-contact branch September 20, 2026 03:35
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