glam-rs icon indicating copy to clipboard operation
glam-rs copied to clipboard

Implement log2 method for Vec3

Open JMS55 opened this issue 1 year ago • 1 comments

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.

JMS55 avatar Oct 03 '24 02:10 JMS55

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.

bitshifter avatar Oct 30 '24 08:10 bitshifter