code wiki / (root) / nx_voxgrid.nx

nx_voxgrid.nx

buildroot/runtime/nx_voxgrid.nx

10313 B271 linesdepth 3pulls 3 transitivereach 13 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_tissue.nx -- 3D voxel grid storage with palette packing. Biology naming per [[feedback-naming-discipline-no-industry- competitor-overlap]]: a tissue is a 3D mass of cells with shared structure and function. Composes naturally with existing biology primitives (cells form tissue, tissue holds the 3D structure of an organ). Avoids: - "chunk" (Minecraft trademark proximity, Java HashMap conflation) - "lattice" (already taken by nx_lattice.nx -- 2D Minkowski math) - "voxel_grid" (too descriptive of industry term) - "volume" (generic infra term) THIS IS THE OTHER UNLOCK PRIMITIVE for Minecraft-equivalent on $5 ESP32 class hardware. Pair with nx_palette (already shipped) and a 32x32x32 (32768 voxel) tissue at 3 bits per voxel fits in 12288 bytes. Six tissues arrayed in a 3x2x1 grid form a walkable scene in 72 KiB -- comfortably within ESP32 SRAM (520 KiB total). Composes: nx_palette -- the sub-byte packing layer (nx_palette_pack / nx_palette_unpack); tissue wraps the (x,y,z) -> linear-index addressing on top. nx_budget -- tissue memory consumption is a RAM budget item; caller registers nx_pal_packed_bytes() with budget nx_tier -- bpp scales with tier (3bpp at MCU, 4bpp at family, 8bpp at workstation+ for cache friendliness) nx_pathway -- a tissue lives in a cell; cell budget covers the tissue's packed byte count V1 ships cubic + cuboid tissues with palette indices. Real-time streaming from flash to RAM (chunk paging) is queued; today the caller materializes the whole tissue in RAM. Gap list (V1 honest perf verdict): - no flash-paging (whole tissue in RAM) - no RLE compression atop palette pack (each voxel costs bpp bits) - no greedy-meshing helper (caller's geometry layer) - no neighbor-iteration helper (queued) - no spatial hash (32^3 = 32K voxels still fits direct addressing)

dependencies 3 imports · 13 importers

nx_syscalls.nx nx_tier.nx nx_palette.nx nx_voxgrid.nx nx_chunk_paginate.nx nx_chunk_paginate_test.nx nx_ecosystem_compose_test.nx nx_game_engine_compose_test.nx nx_minecraft_mcu_compose_test.nx nx_pets_voxel_view.nx nx_raycast_voxel.nx nx_raycast_voxel_test.nx nx_substrate_compose_test.nx nx_tissue_test.nx

diagram shows first 10 each side; +0 more imports, +3 more importers in the complete lists below.

imports: nx_syscalls.nxnx_tier.nxnx_palette.nx

imported by: nx_chunk_paginate.nxnx_chunk_paginate_test.nxnx_ecosystem_compose_test.nxnx_game_engine_compose_test.nxnx_minecraft_mcu_compose_test.nxnx_pets_voxel_view.nxnx_raycast_voxel.nxnx_raycast_voxel_test.nxnx_substrate_compose_test.nxnx_tissue_test.nxnx_voxel_native.nxnx_world_seed.nxnx_world_seed_test.nx

structs

70struct NxTissue

consts

58const NX_TIS_OK: nx_int = 0
59const NX_TIS_ERR_BAD_BPP: nx_int = 1
60const NX_TIS_ERR_BAD_COORD: nx_int = 2
61const NX_TIS_ERR_BAD_INDEX: nx_int = 3
62const NX_TIS_ERR_BAD_DIM: nx_int = 4

functions

84func nx_tissue_new(dim_x: nx_size,
110func nx_tissue_storage_bytes(t: *NxTissue) -> nx_size
116func nx_tissue_in_bounds(t: *NxTissue,
130func _tissue_linear_index(t: *NxTissue,
142func _tissue_unpack_one(packed: *u8, linear: nx_size, bpp: nx_int) -> nx_int
169func _tissue_pack_one(packed: *u8, linear: nx_size, bpp: nx_int, idx: nx_int) -> nx_int
203func nx_tissue_set(t: *NxTissue,
219func nx_tissue_get(t: *NxTissue,
231func nx_tissue_count_nonzero(t: *NxTissue) -> nx_size
254func nx_tissue_fill(t: *NxTissue, idx: nx_int) -> nx_int