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

Add predicate variants to all casts #493

Merged
merged 2 commits into from
Aug 21, 2024
Merged

Conversation

janhohenheim
Copy link
Contributor

@janhohenheim janhohenheim commented Aug 21, 2024

Objective

  • cast_ray already has a sister function called cast_ray_predicate that returns the first hit that satisfies a predicate. The other casts do not.

Solution

  • Implement them. Note that I set the internal implementations of the non-predicate versions to use the predicate to reduce code duplication. The predicate does not introduce an extra branch since we already have an if for the filter in place, so this should be equivalent in performance.

Changelog

This section is optional. If this was a trivial fix, or has no externally-visible impact, you can delete this section.

  • Added
    • cast_ray already has a sister function called cast_ray_predicate that returns the first hit that satisfies a predicate. Now, the other cast function have a similar analogue:
      • Added cast_shape_predicate for cast_shape
      • Added project_point_predicate for project_point

@Jondolf Jondolf added C-Enhancement New feature or request A-Spatial-Query Relates to spatial queries, such as ray casting, shape casting, and intersection tests labels Aug 21, 2024
Copy link
Owner

@Jondolf Jondolf left a comment

Choose a reason for hiding this comment

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

Thanks!

(FYI I noticed the PR description mentioned cast_ray_predicate in the Added list even though it was probably intended to be cast_shape_predicate, so I edited the description. Hope that's fine 😄)

@Jondolf Jondolf merged commit 950fd61 into Jondolf:main Aug 21, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Spatial-Query Relates to spatial queries, such as ray casting, shape casting, and intersection tests C-Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants