Expand description
.10d QuantizedMesh section — the geometry half of a mesh asset in the
container (P0.4).
A QuantizedMesh section wraps a Mesh as a
self-describing .10d section. Vertex positions are quantized to u16
per axis within the mesh’s bounding box — 6 bytes/vertex vs 12 for raw
f32 (2×), and the bbox is exactly what the semantic quins already carry,
so it doubles as the dequantization frame (no information is invented).
Triangle indices are u16 when the mesh has ≤65 536 vertices (6 bytes/tri
vs 12). Quantization error is bbox_extent / 65535 per axis — sub-micron
at organ scale, visually lossless.
Layout: a 40-byte MeshMiniHeader (flags + counts + dequantization
bbox + reserved) followed by the quantized vertex data (N × 6 bytes:
u16×3 per vertex) and then the triangle indices (u16×3 or u32×3 per
triangle, selected by the FLAG_U16_INDICES flag). The mini-header is
repr(C), naturally aligned, no implicit padding.
This replaces the erroneous legacy mesh build artifact that lived in
render/mesh_asset.rs — a pre-release format that was never shipped and
has been refactored out rather than carried forward. The legacy 48-byte
header with its per-format magic is gone; the .10d section-type tag
(SectionType::QuantizedMesh = 1) replaces the magic, and the .10d
container version replaces the per-format version. No backward-compat is
provided — the legacy format was an erroneous build artifact, not a
shipped format anyone depends on.
Determinism + CRC: two encodes of the same mesh are byte-identical (the quantization is deterministic). The per-section CRC-32C (P0.2) catches a flipped bit in the payload. The whole-file CRC-32C (P0.3) catches header corruption.
Structs§
- Mesh
Mini Header - The 40-byte QuantizedMesh-section mini-header.
repr(C), naturally aligned, no implicit padding.
Enums§
- Mesh
Section Error - Mesh-section read/write error.
Constants§
- FLAG_
U16_ INDICES flagsbit 0: triangle indices are u16 (else u32).- MAX_
TRIANGLE_ COUNT - Maximum triangle count. Similarly bounded by the Sentinel: 40MB / 6 bytes per u16-indexed triangle ≈ 6.7M triangles. 4M is the matching ceiling.
- MAX_
VERTEX_ COUNT - Maximum vertex count the mesh section will accept. Bounds against a hostile/malformed file. u16 indices cap at 65 536; above that the encoder switches to u32. The practical ceiling is the 42MB Sentinel: 40MB of vertex data / 6 bytes per vertex ≈ 6.7M vertices. 4M (2^22) is a comfortable upper bound.
- MESH_
MINI_ HEADER_ SIZE - Section payload mini-header size in bytes.
Functions§
- decode_
mesh_ section - Decode a
.10dQuantizedMesh section payload back into aMesh(dequantized positions, exact indices). This is the ingest path (not a hot path), soVecallocation is fine per AGENTS.md §2-B. - encode_
mesh_ section - Encode a
Meshinto a.10dQuantizedMesh section payload in a caller-supplied buffer. Returns the bytes written. Zero-heap. The bbox is recomputed from the positions (independent of any stalemesh.min/max) so it is a faithful dequantization frame. - encoded_
len - Encoded length in bytes for a mesh of the given size (for size reporting without allocating).
- fits_
u16_ indices - Whether a mesh with
vertex_countvertices can use u16 indices. - parse_
mesh_ header - Parse and validate the mesh-section mini-header. Returns the header and the total payload byte length it claims.
- raw_
geometry_ len - Raw in-memory geometry size (f32 positions + u32 triangle indices) — the baseline we shrink from.