code wiki / (root) / nx_raycast_voxel.nx

nx_raycast_voxel.nx

buildroot/runtime/nx_raycast_voxel.nx

9479 B255 linesdepth 4pulls 5 transitivereach 4 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_raycast_voxel.nx -- DDA voxel ray traversal. Per user 2026-05-19 session 1: "we want to build minecraft equivalent on the lowest possible hardware." THE rendering core for that vision. Digital Differential Analyzer ray traversal walks a ray from camera through nx_tissue voxel grid, returning the first non-empty voxel + distance + which face was hit. Fixed-point math throughout — NO floating point. Per cardinals minimum-hardware-floor + bits-up-exceed-never-match: this primitive runs on Cortex-M0+ (no FPU) without modification. Q14 fixed point: 16384 = 1.0; range ~ -131072 to +131071 (covers 32x32x32 worlds with headroom for camera + direction vectors). Composes: nx_tissue -- the voxel world being traversed nx_palette -- voxel palette indices returned on hit nx_fb_1bpp -- caller renders the hit results into framebuffer nx_metabolism -- raycast is the canonical hot path that metabolism promotes through tier ladder V1 ships: - sealed enum NxRayFace (which face of voxel was hit) - struct NxRay + NxRayHit - cast: DDA walk; returns first non-empty voxel or MISS - normalize_q14: caller-helper to scale a direction to Q14

dependencies 3 imports · 4 importers

nx_syscalls.nx nx_tier.nx nx_tissue.nx nx_raycast_voxel.nx nx_game_engine_compose_test.nx nx_minecraft_mcu_compose_test.nx nx_pets_voxel_view.nx nx_raycast_voxel_test.nx

imports: nx_syscalls.nxnx_tier.nxnx_tissue.nx

imported by: nx_game_engine_compose_test.nxnx_minecraft_mcu_compose_test.nxnx_pets_voxel_view.nxnx_raycast_voxel_test.nx

structs

60struct NxRay
72struct NxRayHit

consts

32const NX_MAGIC_2147483647: i64 = 2147483647
34const NX_RV_Q14: nx_int = 16384
38const NX_RF_NONE: nx_int = 0
39const NX_RF_X_POS: nx_int = 1
40const NX_RF_X_NEG: nx_int = 2
41const NX_RF_Y_POS: nx_int = 3
42const NX_RF_Y_NEG: nx_int = 4
43const NX_RF_Z_POS: nx_int = 5
44const NX_RF_Z_NEG: nx_int = 6
45const NX_RF_N_FACES: nx_int = 7
49const NX_RV_HIT: nx_int = 0
50const NX_RV_MISS: nx_int = 1
51const NX_RV_OUT_OF_BOX: nx_int = 2
52const NX_RV_MAX_STEPS: nx_int = 3

functions

82func nx_rf_is_valid(f: nx_int) -> nx_int
called by 1: main
90func _abs_q14(x: nx_int) -> nx_int
called by 1: nx_raycast_voxel
97func _sign(x: nx_int) -> nx_int
called by 1: nx_raycast_voxel
105func nx_ray_new(origin_x_q14: nx_int, origin_y_q14: nx_int, origin_z_q14: nx_int,
called by 3: mainmainmain calls 1: sys_mmap
130func nx_raycast_voxel(ray: *NxRay, world: *NxTissue, out: *NxRayHit) -> nx_int
245func nx_ray_hit_face_normal_q14(hit: *NxRayHit, out_nx_q14: *i64,
called by 1: main