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 triangle_math tests and fix Triangle3d::bounding_sphere bug #13467

Merged
merged 7 commits into from
May 23, 2024

Conversation

aristaeus
Copy link
Contributor

@aristaeus aristaeus commented May 22, 2024

Objective

Adopted #12659.

Resolved the merge conflicts on #12659;

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Math Fundamental domain-agnostic mathematical operations D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 22, 2024
@alice-i-cecile
Copy link
Member

Diff on the final commit looks good to me :)

Copy link
Contributor

@IQuick143 IQuick143 left a comment

Choose a reason for hiding this comment

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

I believe that the computation for the degenerate triangle should be done in the same way as for the obtuse one, which will remove a division by zero bug as well as making the code more regular. (Also depending on what optimisations the compiler misses it might make this path faster by avoiding unnecessary math.)

crates/bevy_math/src/bounding/bounded3d/primitive_impls.rs Outdated Show resolved Hide resolved
crates/bevy_math/src/bounding/bounded3d/primitive_impls.rs Outdated Show resolved Hide resolved
crates/bevy_math/src/primitives/dim3.rs Show resolved Hide resolved
Copy link
Contributor

@IQuick143 IQuick143 left a comment

Choose a reason for hiding this comment

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

I believe that the computation for the degenerate triangle should be done in the same way as for the obtuse one, which will remove a division by zero bug as well as making the code more regular. (Also depending on what optimisations the compiler misses it might make this path faster by avoiding unnecessary math.)

@aristaeus
Copy link
Contributor Author

I've simplified the code paths as mentioned, and also added is_obtuse() (and is_acute for completeness).

I've just realised that Triangle2d doesn't have is_obtuse, is_acute (added in this PR) or is_degenerate (already exists). Should I copy those methods over for consistency?

@aristaeus aristaeus requested a review from IQuick143 May 23, 2024 04:39
@alice-i-cecile
Copy link
Member

I've just realised that Triangle2d doesn't have is_obtuse, is_acute (added in this PR) or is_degenerate (already exists). Should I copy those methods over for consistency?

Yes please: these are really nice little utility methods.

Copy link
Contributor

@IQuick143 IQuick143 left a comment

Choose a reason for hiding this comment

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

Overall it's pretty good, only thing I'd change is optimising away the square roots in the actute and obtuse functions.

crates/bevy_math/src/primitives/dim3.rs Outdated Show resolved Hide resolved
crates/bevy_math/src/primitives/dim3.rs Outdated Show resolved Hide resolved
crates/bevy_math/src/bounding/bounded3d/primitive_impls.rs Outdated Show resolved Hide resolved
@aristaeus aristaeus requested a review from IQuick143 May 23, 2024 14:48
@IQuick143
Copy link
Contributor

Thanks for the work on this PR!

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 23, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue May 23, 2024
Merged via the queue into bevyengine:main with commit bd5148e May 23, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Math Fundamental domain-agnostic mathematical operations C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants