Skip to main content

pack_index

Function pack_index 

Source
pub fn pack_index(index: usize) -> Result<f32, String>
Expand description

Converts a usize node or primitive index into an exactly representable f32.

f32 represents integers exactly only up to 2^24; above that a plain as f32 truncates, which would make a shader read the wrong node or primitive rather than failing loudly.

§Arguments

  • usize - The index to convert.

§Returns

  • Result<f32, String> - The exactly representable index, or an error once the index passes the 2^24 exact range.