Skip to content

compound: the baked compound, with the sphere, capsule and material split out - #10

Merged
nicolas-maman merged 2 commits into
mainfrom
feat/compound
Sep 20, 2026
Merged

nicolas-maman merged 2 commits into
mainfrom
feat/compound

Conversation

@nicolas-maman

Copy link
Copy Markdown
Contributor

The eleventh layer: Box3D's compound.c as aephysics.compound.

  • create_compound: the children's bounds into a tree rebuilt in full and carried in the block (nodes, proxies and a traversal stack); materials deduplicated field by field through core's LongMap; hulls and meshes shared by their own hash verified by bytes; a mesh child's four material slots remapped. get_compound_child in the order capsules, hulls, meshes, spheres.
  • overlap_compound, ray_cast_compound, shape_cast_compound, query_compound, collide_mover_and_compound, compute_compound_aabb, make_compound_child_sweep.
  • To let aephysics.shape dispatch to the compound without an import cycle, sphere.c and capsule.c now live as aephysics.sphere and aephysics.capsule, the surface material as aephysics.material, and the hull's mover beside the mesh's. shape imports them all and gains compound_shape plus the compound branch in every query. dynamic_tree.tree_validate accepts a baked tree (no parents).
  • test_compound.ae: the reference's subtests minus the byte roundtrip, plus the compound through the shape dispatch and a field of a thousand spheres. 159 checks; test_shape.ae unchanged at 440.
  • bench/compound.ae vs bench/compound_box3d.c: identical hits and sums; build 0.7x, queries/overlaps/movers 1.3-1.6x, shape cast 2.1x (GJK cast and overlap on proxies with radii run at 2-2.5x the reference #9), ray cast 2.9x with the time in tree_ray_cast itself (issue to follow). Recorded in bench/RESULTS.md.

…plit out

aephysics.compound, Box3D's compound.c in Aether: capsules, hulls,
meshes and spheres packed into one block under a tree rebuilt in full
and carried in the block with its traversal stack; materials shared by
value (deduplicated field by field through core's LongMap), hulls and
meshes shared by content (their own hash, then their bytes); a mesh
child's four material slots remapped into the compound's table; the
bounds, overlap, ray and shape casts, box query and the mover's planes
through the tree, each child in its own frame and its result carried
back with the child and the material.

So the shape dispatch can reach the compound without a cycle, sphere.c
and capsule.c become aephysics.sphere and aephysics.capsule, the
surface material aephysics.material, and the hull's mover moves beside
the mesh's; aephysics.shape imports them all and gains the compound
kind in every query. tree_validate accepts a baked tree.

test_compound.ae: the reference's creation, material, sharing, child
order, bounds, cast, remap, overlap, query and mover subtests (the byte
roundtrip is not ported), plus the compound through the shape dispatch
and a field of a thousand spheres. 159 checks.

bench/compound.ae against bench/compound_box3d.c on 2,000 children: the
same hits and sums on every phase; the build 0.7x, queries, overlaps
and movers 1.3-1.6x, the shape cast 2.1x, the ray cast 2.9x with the
time in the tree traversal itself, recorded to profile.
@nicolas-maman
nicolas-maman merged commit b91f1f0 into main Sep 20, 2026
1 check passed
@nicolas-maman
nicolas-maman deleted the feat/compound branch September 20, 2026 01:42
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