glam-rs
glam-rs copied to clipboard
Implement log2 method for Vec3
Currently I'm doing:
let bits_per_vertex_position_channel_x = range.as_vec3().x.log2().ceil() as u8;
let bits_per_vertex_position_channel_y = range.as_vec3().y.log2().ceil() as u8;
let bits_per_vertex_position_channel_z = range.as_vec3().z.log2().ceil() as u8;
IVec3 -> Vec3 -> log2 -> ceil -> cast to u8. Everything except log2() and cast to u8 can be done as vector ops.
While I can look at adding log2, recent glam changes mean you should be able to do range.as_vec3().map(|x| x.log2()).ceil().as_u8vec3()
map was added in 0.29.0 and as_u8vec3 should be in 0.29.1.