-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Call MeshRayCast cast_ray without mut #19176
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
base: main
Are you sure you want to change the base?
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
it is to cache the capacity of the vectors, if every call to |
@hukasu It's actually slower if you make it require |
did you already bench it to be affirming that? |
thread_local cache could be the best of both worlds |
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.
Nit: Alternatively, cast_ray
could take into parameters the offending structures needed for its call, so we can instantiate as much as we need (1 per thread) and reuse them, rather than reallocating them each time but in parallel.
As there has been a positive benchmark for stress test, I'm approving.
Objective
cast_ray
always clean up the storage first without checking anything. So I don't see why it needs to store those values.cast_ray
without&mut self
is that we can easily parallelize this call. For example I was trying to simulate lidar. The original implementation makes the bottleneck of simulating thousands of ray cast on one CPU thread becauseMeshRayCast
is SystemParam and it requires&mut self
to callcast_ray
. After removing&mut self
you can easily use it with rayon par_iter.Solution
&mut self
fromcast_ray
.Testing