-
Notifications
You must be signed in to change notification settings - Fork 169
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
Generic mapping function for vectors #547
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was expecting someone to suggest this eventually :)
One change that I think would make sense is add it for all vector types, not just floating point vectors, I don't think there's any reason not to? This should just be a case of moving the function in codegen to a common area, it would also require tests (which again is mostly a case of moving them to a common location and casting the inputs to the scalar type in the test).
Oop ya that makes sense, I had thought this already did this but didn't check. |
Whoops, did a silly. Should be good now, includes non-float vectors. |
Just needs a rust fmt. It would be good if I could auto fmt PRs but I don't think that is possible |
Thanks for the PR! |
Hi! Sorry I didn't make a discussion about this first, didn't read the guidelines until I already wrote this up, so figured I might as well post the PR.
This adds a generic mapping function that acts on all of the elements of a vector. Adding it to matrices as well might be useful, but my use cases for this has always just been vectors so far. I'm happy to add it to matrices if you think that'd be good for consistency's sake.
The use case, as an example, I had recently was taking any vector element in a normal below some
EPSILON
and setting it to 0.0, since the collision normal that was generated was a little bit finnicky. I don't see that use case alone as very useful in the library, but allowing per-element operations definitely is imo.