Skip to content

Add .contains_aabb for Frustum#16022

Merged
mockersf merged 13 commits intobevyengine:mainfrom
Soulghost:feature/frustum_contains_aabb
Dec 1, 2024
Merged

Add .contains_aabb for Frustum#16022
mockersf merged 13 commits intobevyengine:mainfrom
Soulghost:feature/frustum_contains_aabb

Conversation

@Soulghost
Copy link
Copy Markdown
Contributor

@Soulghost Soulghost commented Oct 20, 2024

Objective

Solution

  • Add an is_forward_plane method to Aabb, and a contains_aabb method to Frustum.

Test

  • I have created a frustum with an offset along with three unit tests to evaluate the contains_aabb algorithm.

Explanation for the Test Cases

  • To facilitate the code review, I will explain how the frustum is created. Initially, we create a frustum without any offset and then create a cuboid that is just contained within it.
image
  • Secondly, we move the cuboid by 2 units along both the x-axis and the y-axis to make it more general.

Reference

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Math Fundamental domain-agnostic mathematical operations D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged X-Uncontroversial This work is generally agreed upon labels Oct 20, 2024
@Soulghost Soulghost marked this pull request as ready for review October 26, 2024 06:13
@Soulghost
Copy link
Copy Markdown
Contributor Author

Hi @alice-i-cecile , this pull request is ready for review. Could you please remove the "Waiting on Author" label and assign some reviewers. Thank you.

@alice-i-cecile alice-i-cecile added S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Nov 7, 2024
@IQuick143
Copy link
Copy Markdown
Contributor

I'll review later today, I have some comments to the math.

Copy link
Copy Markdown
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'll have to go over the geometry to make sure the algorithm is correct, but I've left some comments regarding algebraic simplifications of the code. (Most notably they enable better SIMD optimisations by the compiler.)

@Soulghost
Copy link
Copy Markdown
Contributor Author

Hi @IQuick143 , sorry for the late response. I have resolved all the issues and added some cases involving rotation, please take another look and review them. Thank you!

Copy link
Copy Markdown
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.

Seems good, hope I didn't miss anything.

Thanks for the PR.

@IQuick143 IQuick143 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 Nov 27, 2024
@mockersf mockersf added this pull request to the merge queue Dec 1, 2024
Merged via the queue into bevyengine:main with commit 206f4f7 Dec 1, 2024
ecoskey pushed a commit to ecoskey/bevy that referenced this pull request Dec 2, 2024
# Objective

- Fixes: bevyengine#15663

## Solution

- Add an `is_forward_plane` method to `Aabb`, and a `contains_aabb`
method to `Frustum`.

## Test
- I have created a frustum with an offset along with three unit tests to
evaluate the `contains_aabb` algorithm.

## Explanation for the Test Cases
- To facilitate the code review, I will explain how the frustum is
created. Initially, we create a frustum without any offset and then
create a cuboid that is just contained within it.

<img width="714" alt="image"
src="https://github.com/user-attachments/assets/a9ac53a2-f8a3-4e09-b20b-4ee71b27a099">

- Secondly, we move the cuboid by 2 units along both the x-axis and the
y-axis to make it more general.


## Reference
- [Frustum
Culling](https://learnopengl.com/Guest-Articles/2021/Scene/Frustum-Culling#)
- [AABB Plane
intersection](https://gdbooks.gitbooks.io/3dcollisions/content/Chapter2/static_aabb_plane.html)

---------

Co-authored-by: IQuick 143 <[email protected]>
ecoskey pushed a commit to ecoskey/bevy that referenced this pull request Jan 6, 2025
# Objective

- Fixes: bevyengine#15663

## Solution

- Add an `is_forward_plane` method to `Aabb`, and a `contains_aabb`
method to `Frustum`.

## Test
- I have created a frustum with an offset along with three unit tests to
evaluate the `contains_aabb` algorithm.

## Explanation for the Test Cases
- To facilitate the code review, I will explain how the frustum is
created. Initially, we create a frustum without any offset and then
create a cuboid that is just contained within it.

<img width="714" alt="image"
src="https://github.com/user-attachments/assets/a9ac53a2-f8a3-4e09-b20b-4ee71b27a099">

- Secondly, we move the cuboid by 2 units along both the x-axis and the
y-axis to make it more general.


## Reference
- [Frustum
Culling](https://learnopengl.com/Guest-Articles/2021/Scene/Frustum-Culling#)
- [AABB Plane
intersection](https://gdbooks.gitbooks.io/3dcollisions/content/Chapter2/static_aabb_plane.html)

---------

Co-authored-by: IQuick 143 <[email protected]>
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-Feature A new feature, making something new possible 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 X-Uncontroversial This work is generally agreed upon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add .contains_aabb for Frustum

5 participants