-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Error in frustum math. #3744
Comments
I think it is correct. The frustum plane normals are inward facing and normalised. Given the equation for points in a plane Could you give more details about the flickering bug and either provide a minimal example that reproduces it or give instructions? |
Sorry for the bad description. An example of how I think it works: |
|
Thanks. In my re-reading I had missed that the Vec4s were being normalized including all 4 components. I understand the problem now. |
I'll add this to the rendering project board. Given no one has noticed this so far suggests it's not that bad of an impact in practice, and to fix it I would like to add a bunch of tests for these intersection checks, and that will take a bit of time. |
# Objective Fixes bevyengine#3744 ## Solution The old code used the formula `normal . center + d + radius <= 0` to determine if the sphere with center `center` and radius `radius` is outside the plane with normal `normal` and distance from origin `d`. This only works if `normal` is normalized, which is not necessarily the case. Instead, `normal` and `d` are both multiplied by some factor that `radius` isn't multiplied by. So the additional code multiplied `radius` by that factor.
# Objective Fixes bevyengine#3744 ## Solution The old code used the formula `normal . center + d + radius <= 0` to determine if the sphere with center `center` and radius `radius` is outside the plane with normal `normal` and distance from origin `d`. This only works if `normal` is normalized, which is not necessarily the case. Instead, `normal` and `d` are both multiplied by some factor that `radius` isn't multiplied by. So the additional code multiplied `radius` by that factor.
# Objective Fixes bevyengine#3744 ## Solution The old code used the formula `normal . center + d + radius <= 0` to determine if the sphere with center `center` and radius `radius` is outside the plane with normal `normal` and distance from origin `d`. This only works if `normal` is normalized, which is not necessarily the case. Instead, `normal` and `d` are both multiplied by some factor that `radius` isn't multiplied by. So the additional code multiplied `radius` by that factor.
Bevy version
0.6.0
What you did
When trying to use the new frustum from 0.6 I noticed it being too inclusive when using the
intersects_sphere
method, causing some flickering when loading new meshes within it.Looking at the code I think I see an error in how the radius is handled. Adding radius directly to the normalized dot product causes it to add multiples of the vector's original length instead of the
radius * length of normalized normal vector
I assume it is meant to use.The text was updated successfully, but these errors were encountered: