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

Use Vec3A for 3D bounding volumes and raycasts #13087

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

NiseVoid
Copy link
Contributor

Objective

  • People have reported bounding volumes being slower than their existing solution because it doesn't use SIMD aligned types.

Solution

  • Use Vec3A internally for bounding volumes, accepting Into<Vec3A> wherever possible
  • Change some code to make it more likely SIMD operations are used.

Changelog

  • Use Vec3A for 3D bounding volumes and raycasts

Migration Guide

  • 3D bounding volumes now use Vec3A types internally, return values from methods on them now return Vec3A instead of Vec3

@NthTensor NthTensor added C-Performance A change motivated by improving speed, memory usage or compile times A-Math Fundamental domain-agnostic mathematical operations labels Apr 24, 2024
@NthTensor
Copy link
Contributor

Do we have a good test to best mark this on?

@james7132 james7132 requested a review from Jondolf April 24, 2024 23:03
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.

Seems like straightforward changes, I haven't spotted any problems.

} else {
(aabb.max.z, aabb.min.z)
};
let positive = self.direction.signum().cmpgt(Vec3A::ZERO);
Copy link
Contributor

Choose a reason for hiding this comment

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

is the signum needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without the signum it'll break on 0 vs -0, signum always turns it into 1 or -1 ... Would be nice if glam had a function to get a BVec3A for the signs directly tho 🤔

@NthTensor NthTensor added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Apr 25, 2024
@Jondolf Jondolf added the C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide label Apr 25, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Apr 25, 2024
Merged via the queue into bevyengine:main with commit 414abb4 Apr 25, 2024
32 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-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide C-Performance A change motivated by improving speed, memory usage or compile times 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.

None yet

6 participants