-
Notifications
You must be signed in to change notification settings - Fork 158
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
Add swizzle variants of with_X
methods
#584
Conversation
Ah right, I guess I didn't see a need to port the swizzle test generation to tera when I migrated everything else. This is the old swizzlegen code before it was deleted https://github.com/bitshifter/glam-rs/blob/88e4538695cf1babddec1a9778510790cd1d7671/swizzlegen/src/main.rs |
Rather than adding it to tera I've restore enough of the old code to generate swizzle tests. |
The tests use the values // Examples
assert_eq!(v.with_xyz(rhs3), vec4(11_f32, 12_f32, 13_f32, 4_f32));
assert_eq!(v.with_zx(rhs2), vec4(12_f32, 2_f32, 11_f32, 4_f32)); |
I haven't reviewed every generated line but hopefully I've looked at enough to check things look correct AFAICT. It took a little while to understand exactly what this does (having not used this in shaders) but it looks like it matches the https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf swizzle assignments. The testing approach makes sense to me. For set, it can be added later if there is a desire for it. I think into Thanks for this, it's a pretty fiddly thing to implement. |
Example
Notes
Do we want
set_X
swizzles also?Quote from the linked comment. Trivial to solve by taking
impl Into<{{ vec3_t }}>
though that would allow[f32, f32, f32]
, etc. as well.