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

Generic mapping function for vectors #547

Merged
merged 7 commits into from
Aug 11, 2024
Merged

Conversation

Aceeri
Copy link
Contributor

@Aceeri Aceeri commented Aug 8, 2024

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.

@Aceeri
Copy link
Contributor Author

Aceeri commented Aug 8, 2024

Copy link
Owner

@bitshifter bitshifter left a 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).

@Aceeri
Copy link
Contributor Author

Aceeri commented Aug 8, 2024

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.

@Aceeri
Copy link
Contributor Author

Aceeri commented Aug 9, 2024

Whoops, did a silly. Should be good now, includes non-float vectors.

@Aceeri Aceeri reopened this Aug 9, 2024
@bitshifter
Copy link
Owner

Just needs a rust fmt. It would be good if I could auto fmt PRs but I don't think that is possible

@bitshifter bitshifter merged commit fe3365b into bitshifter:main Aug 11, 2024
18 checks passed
@bitshifter
Copy link
Owner

Thanks for the PR!

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

Successfully merging this pull request may close these issues.

2 participants