Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement log2 method for Vec3 #566

Open
JMS55 opened this issue Oct 3, 2024 · 1 comment
Open

Implement log2 method for Vec3 #566

JMS55 opened this issue Oct 3, 2024 · 1 comment

Comments

@JMS55
Copy link

JMS55 commented Oct 3, 2024

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.

@bitshifter
Copy link
Owner

bitshifter commented Oct 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants