Commit cb02445
committed
Add MESH geometric object type for arbitrary triangulated 3D surfaces
Implement a new MESH primitive alongside SPHERE, CYLINDER, BLOCK, and
PRISM. A mesh is defined by a vertex array and triangle index array,
with a BVH (bounding volume hierarchy) for O(log N) queries.
Core operations implemented:
- point_in_mesh: ray casting with parity counting and deduplication
- normal_to_mesh: BVH-accelerated closest-face search
- get_mesh_bounding_box: from BVH root node
- get_mesh_volume: divergence theorem (signed tetrahedron volumes)
- intersect_line_segment_with_mesh: for subpixel smoothing integration
- init_mesh: validates geometry, computes normals, fixes winding, builds BVH
BVH uses SAH (surface area heuristic) binned construction with flat
array layout. Ray-triangle intersection uses Moller-Trumbore algorithm.
Closest-point queries use Eberly's algorithm with BVH pruning.
Also adds make_mesh/make_mesh_with_center constructors, mesh
copy/equal/destroy in geom-ctl-io.c, and 11 unit tests covering
point-in, volume, bbox, normals, line-segment intersection, and
comparison against the Block primitive.1 parent 5699493 commit cb02445
5 files changed
Lines changed: 1193 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
176 | 185 | | |
177 | 186 | | |
178 | 187 | | |
| |||
0 commit comments