fn decompress_f32(value: CompressedBits, min: f32, max: f32, bit_count: NonZeroU64) -> Option<f32> {
    // Anim supports custom ranges and non standard bit counts for fine tuning compression.
    // Unsigned normalized u8 would use min: 0.0, max: 1.0, and bit_count: 8.
    // This produces 2 ^ 8 evenly spaced floating point values between 0.0 and 1.0,
    // so 0b00000000 corresponds to 0.0 and 0b11111111 corresponds to 1.0.

    // We don't allow zero to prevent divide by zero.
    let scale = bit_mask(bit_count);

    // TODO: There may be some edge cases with this implementation of linear interpolation.
    // TODO: What happens when value > scale?
    let lerp = |a, b, t| a * (1.0 - t) + b * t;
    let value = lerp(min, max, value as f32 / scale as f32);

    Some(value)
}
// TODO: It should be possible to test the edge cases by debugging Smash running in an emulator.
// Ex: Create a vector4 animation with all frames set to the same compressed value and inspect the uniform buffer.
It should be possible to test the edge cases by debugging Smash running in an emulator.
Ex: Create a vector4 animation with all frames set to the same compressed value and inspect the uniform buffer.
It should be possible to test the edge cases by debugging Smash running in an emulator . Ex : Create a vector4 animation with all frames set to the same compressed value and inspect the uniform buffer .
fn decompress_f32(value: CompressedBits, min: f32, max: f32, bit_count: NonZeroU64) -> Option<f32> {
    // Anim supports custom ranges and non standard bit counts for fine tuning compression.
    // Unsigned normalized u8 would use min: 0.0, max: 1.0, and bit_count: 8.
    // This produces 2 ^ 8 evenly spaced floating point values between 0.0 and 1.0,
    // so 0b00000000 corresponds to 0.0 and 0b11111111 corresponds to 1.0.
    // We don't allow zero to prevent divide by zero.
    let scale = bit_mask(bit_count);
    // TODO: There may be some edge cases with this implementation of linear interpolation.
    // TODO: What happens when value > scale?
    let lerp = |a, b, t| a * (1.0 - t) + b * t;
    let value = lerp(min, max, value as f32 / scale as f32);
    Some(value)
}
fn decompress_f32 ( value : CompressedBits , min : f32 , max : f32 , bit_count : NonZeroU64 ) -> Option < f32 > { // Anim supports custom ranges and non standard bit counts for fine tuning compression. // Unsigned normalized u8 would use min: 0.0, max: 1.0, and bit_count: 8. // This produces 2 ^ 8 evenly spaced floating point values between 0.0 and 1.0, // so 0b00000000 corresponds to 0.0 and 0b11111111 corresponds to 1.0. // We don't allow zero to prevent divide by zero. let scale = bit_mask ( bit_count ) ; // TODO: There may be some edge cases with this implementation of linear interpolation. // TODO: What happens when value > scale? let lerp = | a , b , t | a * ( 1.0 - t ) + b * t ; let value = lerp ( min , max , value as f32 / scale as f32 ) ; Some ( value ) }
TODO: It should be possible to test the edge cases by debugging Smash running in an emulator.
TODO : It should be possible to test the edge cases by debugging Smash running in an emulator .
value
CompressedBits
min
f32
max
f32
bit_count
NonZeroU64
value
CompressedBits
min
f32
max
f32
bit_count
NonZeroU64