Skip to main content

read_mdl_from_bytes

Function read_mdl_from_bytes 

Source
pub fn read_mdl_from_bytes(
    bytes: &[u8],
    mdx_bytes: Option<&[u8]>,
) -> Result<Mdl, MdlError>
Expand description

Reads an MDL file from the given byte slice.

Accepts an optional mdx_bytes slice for external geometry data. This currently supports reading the node hierarchy, names, transforms, and basic mesh headers (vertex counts).

ยงErrors

MdlError::InvalidHeader when bytes are shorter than the MDL header or a declared section runs past the end, MdlError::InvalidData when the node tree does not hang together, MdlError::ValueOverflow when a declared offset or count will not fit usize, and MdlError::Binary when a primitive read runs off the end.

An absent mdx_bytes is not an error: the model reads without vertex data, which is what a caller inspecting node structure wants. An MDX that is present and too short truncates the affected mesh rather than failing, the way vanilla K1 item models sharing one MDX buffer require.