Skip to main content

Module normal_section

Module normal_section 

Source
Expand description

Compact, optional vertex-normal field sidecar for compiled mesh assets.

The existing QuantizedMesh payload remains byte-for-byte stable. This field sidecar stores unit normals as two signed normalized 16-bit octahedral coordinates (4 bytes per vertex).

Structs§

MeshFrameDecodeLimits
Admission limits apply equally to borrowed decoding and cold owned output. Decoded bytes count only active streams (12 bytes/normal, 16 bytes/tangent). They bound logical output storage, not allocator bookkeeping or the envelope.
MeshFrameLayout
Fully validated active stream layout; no borrowed typed cast is required.
MeshFrameStreams
Normal and tangent data decoded from one vertex-aligned FieldSidecar.

Enums§

NormalSectionError

Constants§

MAX_NORMAL_COUNT
NORMAL_ENCODING_OCT16
NORMAL_SECTION_HEADER_SIZE
NORMAL_SECTION_VERSION

Functions§

decode_mesh_frames
Decode either the legacy NRM1 stream or the combined FRM1 normal/tangent stream.
decode_mesh_frames_into
Decode all present streams into caller storage. Absent streams and buffer tails remain untouched. A present stream requires at least layout.count slots, even if the caller only plans to consume the other stream. Every validation and capacity error leaves BOTH outputs unchanged.
decode_mesh_frames_with_limits
Cold convenience API. Full admission precedes any allocation; requested vector capacities fit the explicit decoded-byte budget. Allocation refusal is an error, not an unchecked with_capacity panic. The hot API is _into.
decode_normals
Decode vertex normals from a normal-only or combined mesh-frame FieldSidecar.
decode_tangents
Decode vertex tangents and handedness from a combined mesh-frame FieldSidecar.
encode_mesh_frames
Encode normal and tangent streams in an interleaved, vertex-aligned FRM1 sidecar. Normals-only data retains the existing NRM1 representation for byte-stable containers.
encode_normals
Encode normalized vertex normals into a caller-owned payload buffer.
encoded_len
Byte size of a normals-only (NRM1) section for count vertices (header + 4 bytes per vertex); None on overflow.
frame_encoded_len
Byte size of an interleaved FRM1 frame section for count vertices, with 4-byte normals and/or 8-byte tangents per vertex. None when neither stream is present or on overflow.
inspect_mesh_frames
Validate the entire payload, including every late tangent, without mutation or allocation. Unaligned bytes and LE headers share the native/WASM path.
is_normal_section
Whether a FieldSidecar payload uses the per-vertex normal codec.