15.7. Mesh remapping, optimization, and buffer codecs (meshoptimizer)
Checked array bindings for meshoptimizer 1.2 vertex remapping, vertex-cache and vertex-fetch optimization, and vertex and index buffer codecs. The API accepts triangle-list uint indices and packed vertex bytes with a nonzero, 4-byte-aligned stride of at most 256 bytes.
15.7.1. Vertex remapping
- meshopt_generate_remap(remap: array<uint>; indices: array<uint>; vertices: array<uint8>; stride: uint ): uint
Build a vertex remap table from triangle-list indices and packed vertices, returning the number of unique vertices. stride must be nonzero, 4-byte aligned, at most 256 bytes, and divide the vertex byte count; every index must be in range, and remap must not alias indices.
- Arguments:
remap : array<uint> implicit
indices : array<uint> implicit
vertices : array<uint8> implicit
stride : uint
- meshopt_remap_indices(output: array<uint>; indices: array<uint>; remap: array<uint> )
Apply a vertex remap table to triangle-list indices and resize output to the index count. Every input index must address the remap table, and output must not alias remap.
- Arguments:
output : array<uint> implicit
indices : array<uint> implicit
remap : array<uint> implicit
- meshopt_remap_vertices(output: array<uint8>; vertices: array<uint8>; remap: array<uint>; stride: uint; count: uint )
Apply remap to packed vertices and resize output to count * stride bytes. The remap table must contain one entry per input vertex, each entry must be less than count or the unused value 0xffffffff, and output must not alias vertices.
- Arguments:
output : array<uint8> implicit
vertices : array<uint8> implicit
remap : array<uint> implicit
stride : uint
count : uint
15.7.2. Mesh optimization
- meshopt_optimize_cache(indices: array<uint>; count: uint )
Reorder triangle-list indices in place to improve post-transform vertex-cache locality while preserving each triangle’s orientation. Every index must be less than count.
- Arguments:
indices : array<uint> implicit
count : uint
- meshopt_optimize_fetch(indices: array<uint>; vertices: array<uint8>; stride: uint ): uint
Reorder indices and packed vertices in place for sequential vertex fetch, discard unreferenced vertices, and return the resulting vertex count. The vertex stride and all triangle-list indices are validated before either array is modified.
- Arguments:
indices : array<uint> implicit
vertices : array<uint8> implicit
stride : uint
15.7.3. Vertex codec
- meshopt_decode_vertices(output: array<uint8>; encoded: array<uint8>; count: uint; stride: uint ): bool
Decode count packed vertex records of stride bytes into output and return true on success. Invalid codec data returns false and clears output; invalid stride, oversized output, or aliasing encoded raises an error.
- Arguments:
output : array<uint8> implicit
encoded : array<uint8> implicit
count : uint
stride : uint
- meshopt_encode_vertices(output: array<uint8>; vertices: array<uint8>; stride: uint )
Encode packed vertex records into the meshoptimizer vertex codec and resize output to the encoded byte count. stride must be nonzero, 4-byte aligned, at most 256 bytes, and divide the input size; output must not alias vertices.
- Arguments:
output : array<uint8> implicit
vertices : array<uint8> implicit
stride : uint
15.7.4. Index codec
- meshopt_decode_indices(output: array<uint>; encoded: array<uint8>; count: uint ): bool
Decode exactly count triangle-list indices into output and return true on success. count must be divisible by three; invalid codec data returns false and clears output.
- Arguments:
output : array<uint> implicit
encoded : array<uint8> implicit
count : uint
- meshopt_encode_indices(output: array<uint8>; indices: array<uint>; count: uint )
Encode triangle-list indices with the meshoptimizer index codec and resize output to the encoded byte count. Every index must be less than the supplied vertex count. Triangle order and winding are preserved, but the three indices within each triangle may be cyclically rotated.
- Arguments:
output : array<uint8> implicit
indices : array<uint> implicit
count : uint