nx_sdf.nx
buildroot/runtime/nx_sdf.nx
about
nx_sdf.nx -- signed distance fields for solid primitives + boolean combinators,
the algebra under CSG (Constructive Solid Geometry). A primitive returns a Q14-mm
signed distance (negative = inside). Booleans are min/max combinators -- which is
why SDF CSG is UNCONDITIONALLY robust: union/difference/intersection can never fail
or self-intersect the way B-rep mesh booleans do on degenerate geometry. Sign-
correct fields (the zero-isosurface is the exact surface) are all marching needs.
Reuses nx_isqrt. No dup: grepped, no nx_sdf/csg existed. license_tier: ORIGINAL
dependencies 2 imports · 23 importers
diagram shows first 10 each side; +0 more imports, +13 more importers in the complete lists below.
imports: nx_syscalls.nxnx_isqrt.nx
imported by: nx_cad_exceed.nxnx_cad_page.nxnx_cad_prims2_test.nxnx_csg.nxnx_csg_fillet_test.nxnx_csg_rot_gate.nxnx_csg_rotxz_gate.nxnx_csg_scene.nxnx_csg_scene_gate.nxnx_csg_test.nxnx_csg_torus_test.nxnx_mesh_decimate_gate.nxnx_underridge_cleaner.nxnx_underridge_cleaner_gate.nxnx_underridge_gel_gate.nxnx_underridge_hook_gate.nxnx_underridge_hook_gcode_gate.nxnx_underridge_hook_petg_gate.nxnx_underridge_master_gate.nxnx_vessel_csg.nxnx_vessel_csg_test.nxnx_vessel_emit.nxnx_vessel_gcode.nx
structs
| 22 | struct NxSdfPrim { kind: i64, cx: i64, cy: i64, cz: i64, a: i64, b: i64, c: i64, d: i64 } |
consts
| 12 | const NX_SDF_SPHERE: i64 = 0 |
| 13 | const NX_SDF_BOX: i64 = 1 |
| 14 | const NX_SDF_CYL: i64 = 2 // axis = Z |
| 15 | const NX_SDF_TORUS: i64 = 3 // hole along Z; a = major R, b = minor r |
| 16 | const NX_SDF_ROUNDBOX: i64 = 4 // a,b,c = half extents; d = corner round radius |
| 77 | const NX_CSG_UNION: i64 = 0 |
| 78 | const NX_CSG_INTERSECT: i64 = 1 |
| 79 | const NX_CSG_DIFF: i64 = 2 // A minus B |
functions
| 24 | func sdf_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } called by 1: nx_sdf_eval |
| 25 | func sdf_max(a: i64, b: i64) -> i64 { if a > b { return a } return b } |
| 26 | func sdf_min(a: i64, b: i64) -> i64 { if a < b { return a } return b } |
| 28 | func nx_sdf_make(kind: i64, cx: i64, cy: i64, cz: i64, a: i64, b: i64, c: i64) -> *NxSdfPrim called by 16: nx_cad_measure_filletmainnx_csg_box_minus_cylnx_csg_torus_meshnx_csg_two_sphere_filletmain+10 calls 1: sys_mmap |
| 36 | func nx_sdf_make4(kind: i64, cx: i64, cy: i64, cz: i64, a: i64, b: i64, c: i64, d: i64) -> *NxSdfPrim |
| 43 | func nx_sdf_eval(p: *NxSdfPrim, x: i64, y: i64, z: i64) -> i64 called by 5: mainnx_csg_scene_eval_imainnx_csg_fieldnx_csg_field_k calls 4: nx_isqrtsdf_maxsdf_abssdf_min |
| 82 | func nx_csg_combine(op: i64, da: i64, db: i64) -> i64 |
| 89 | func nx_csg_field(a: *NxSdfPrim, b: *NxSdfPrim, op: i64, x: i64, y: i64, z: i64) -> i64 |
| 99 | func nx_csg_smin(a: i64, b: i64, k: i64) -> i64 called by 1: nx_csg_combine_k |
| 111 | func nx_csg_combine_k(op: i64, da: i64, db: i64, k: i64) -> i64 |
| 118 | func nx_csg_field_k(a: *NxSdfPrim, b: *NxSdfPrim, op: i64, k: i64, x: i64, y: i64, z: i64) -> i64 |