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

Raycast fn using fast traversal #25

Merged
merged 11 commits into from
Jun 5, 2024

Conversation

dtaralla
Copy link
Contributor

@dtaralla dtaralla commented Jun 3, 2024

I could successfully replace the step algorithm you were using by the new voxel line traversal for the same results. I leave this in draft though as this PR depends on the other to be approved first. Also, I'd like to do some benchmark to make sure the performance are equal or better.

dtaralla added 8 commits May 31, 2024 16:32
+ Added `voxel_line_traversal` and `voxel_cartesian_traversal` for versatile and fast traversal of the voxel grid
+ Created a new bevy_voxel_world::traversal_alg module to make it easy for crate users to import those algorithms
+ Added VoxelFace enum to represent the face of a voxel, automatically imported by the prelude
+ Added VOXEL_SIZE constant (because I was uncomfortable implicitly using the fact that voxels are unit-sized)
+ Added an example showing how to use and debug voxel traces
Returns Err for VoxelFace::None, Ok for regular faces.
+ New get_bounds function on ChunkMap
+ Updating or removing chunks automatically updates the bounds
+ VoxelRaycastResult::normal is now an Option<Vec3>, which is None when the raycast result is the voxel from which the trace originated from
@dtaralla
Copy link
Contributor Author

dtaralla commented Jun 3, 2024

I've executed the benchmarks and the new algo is outperforming the old one by quite much. You can find the benchmark code on this branch if you want to see by yourself! To test, just checkout this branch and run cargo bench. The results will be in target/criterion/report/index.html.

image

Copy link
Owner

@splashdust splashdust left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing the stepping algo with the fast traversal one makes perfect sense. Thank you for contributing this as well!

@splashdust splashdust marked this pull request as ready for review June 5, 2024 21:50
@splashdust splashdust merged commit 866c837 into splashdust:main Jun 5, 2024
3 checks passed
@dtaralla
Copy link
Contributor Author

dtaralla commented Jun 6, 2024

Good catch on the fixes you made ! And thanks for merging <3

@dtaralla dtaralla deleted the raycast_fn_using_fast_traversal branch June 6, 2024 13:13
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