Add optimized is_in_half_space_identity, contains_aabb_identity, and intersects_obb_identity#21249
Merged
mockersf merged 12 commits intobevyengine:mainfrom Dec 8, 2025
Merged
Add optimized is_in_half_space_identity, contains_aabb_identity, and intersects_obb_identity#21249mockersf merged 12 commits intobevyengine:mainfrom
mockersf merged 12 commits intobevyengine:mainfrom
Conversation
Contributor
Author
|
Please squash commits, I see no button to do so. |
alice-i-cecile
requested changes
Sep 28, 2025
Member
alice-i-cecile
left a comment
There was a problem hiding this comment.
I like this! Before I approve, can you check if we can get the same performance improvements by using const if branching on the existing methods?
If that fails, please:
- Add doc links to these methods from the unspecialized versions.
- Add true doc links back to the unspecialized versions.
- Add some basic tests asserting equivalence.
Member
We always squash on merge: don't worry about it for this project :) |
alice-i-cecile
approved these changes
Sep 29, 2025
The word "entire" is badly needed here. its not obvious that this returns false when only part of the aabb is in the frustum
Add optimized intersects_obb_identity method for frustum culling.
Contributor
Author
|
@alice-i-cecile 38% increase on windows and 39% increase on linux with a similar identity fn for intersects_obb. intersects_obb also seems to be more heavily used and heavier to compute. I would appreciate another code review :) |
hymm
approved these changes
Nov 18, 2025
IQuick143
reviewed
Nov 20, 2025
IQuick143
approved these changes
Nov 20, 2025
Co-authored-by: IQuick 143 <IQuick143cz@gmail.com>
mockersf
approved these changes
Dec 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
This adds an optimized version of is_in_half_space,
Frustum::contains_aabb_identity,Aabb::is_in_half_space_identity, andFrustum::intersects_obb_identitythat takes advantage of how calling with IDENTITY (common) reduces the amount of matrix multiplications.Solution
Add a specialized function without touching the original that assumes Identity was passed to simplify math.
Testing
I use this function extensively in my own project. I asserted the old function called with identity always returns the same as my new function.
I bench marked and profiled the usage in my real application and noticed a 16% speed up on Linux and 20% on windows for contains_aabb.
I bench marked intersects_obb_identity and noticed a 39% increase on linux and 38% on windows.
Both functions have unit tests that assert calling with identity yields the same result in both versions.