Skip to content

aephysics.mesh: the triangle mesh and its BVH - #6

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

nicolas-maman merged 1 commit into
mainfrom
feat/mesh

Conversation

@nicolas-maman

Copy link
Copy Markdown
Contributor

The eighth layer: Box3D's mesh.c in Aether, as aephysics.mesh — the static geometry a city is made of.

  • The BVH by binned SAH or median split (half split as the fallback), nodes in one array (left child follows, right at an offset), triangles and materials sorted depth-first; vertex welding through a spatial hash; edge flags (concave / inverse / flat) from a vertex-pair map; any scale, mirrored included, with winding and flags made to match.
  • Traversals: overlap, bounds, ray cast (front to back along the split axis), shape cast, the mover's planes, a box query with a visitor; the box–triangle SAT and the ray–triangle test in scalar form.
  • Built-in grid, wave, torus, box, hollow box, platform meshes.
  • core: a long→int open-addressing map (LongMap) and hash_bytes, which the hull now shares. CastOutput gains child_index and material_index.
  • test_mesh.ae: 1,594 checks — the reference's test_mesh.c (valley from dense / strided / welded / clockwise / composed input, the creators) plus tree consistency, rays against a grid and a wave at analytic hits, box query against a scan, overlap, shape cast, edge flags of a box and a hollow box, a mirrored scale, the mover.
  • bench/mesh.ae vs bench/mesh_box3d.c: identical trees from both splits (43,135 / 48,063 nodes, height 16), equal ray and cast results; the box query 0.008% more permissive at SIMD-vs-scalar boundaries. Builds 1.2–1.5×, traversals 1.7–2× (their SIMD box tests).

Differences: material indices and flags are ints, not bytes; traversal stack is module scratch; scalar SAT tests; own hash.

Box3D's mesh.c in Aether: the bounding volume hierarchy built by a
binned surface-area heuristic or a median split, falling back to a
half split rather than a huge leaf, the nodes in one array with the
left child after its parent and the right at an offset, the triangles
and materials sorted into the tree's depth-first order; vertex welding
through a spatial hash of cells twice the tolerance; edge adjacency
flags (concave, inverse concave, both for flat) from a map of vertex
pairs; a mesh usable at any scale, mirrored included, with the winding
and flags made to match; and the traversals -- overlap, bounds, ray
cast front to back along the split axis with the segment-box and
ray-triangle tests, shape cast, the character mover's planes, and a
box query with a visitor -- with the box-triangle separating axis test
in scalar form. The built-in grid, wave, torus, box, hollow box and
platform meshes come with it.

core gains a long-to-int map (LongMap, open addressing) and the block
hash the hull now shares; CastOutput gains its child and material
indices.

test_mesh.ae: 1,594 checks from test_mesh.c (the valley from dense,
strided, welded, clockwise and composed input, the creators) plus the
tree's consistency, rays against a grid and a wave at analytic hits,
the box query against a scan, overlap, shape cast, the flags of a box
and a hollow box, a mirrored scale, the mover.

bench/mesh.ae against bench/mesh_box3d.c: the same trees (node counts
and heights equal from both splits), equal ray and cast sums, the box
query 0.008% more permissive; builds 1.2-1.5x, traversals 1.7-2x.
@nicolas-maman
nicolas-maman merged commit 7915d8d into main Sep 19, 2026
1 check passed
@nicolas-maman
nicolas-maman deleted the feat/mesh branch September 19, 2026 23:39
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