-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Visibility range takes the model aabb into acount #15164
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
Haven't thought if it's more costly, but maybe we should pick a point on the edge of the AABB nearest the camera? And not the AABB center. |
In the frustum culling code the radius of the aabb is calculated as transform.radius_vec3a(model_aabb.half_extents). Maybe we could use the center point + the radius as the edge point? Please tell me if you would like to add that! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, we can add the closest point thing later. This is already an improvement as is.
PR bevyengine#15164 made Bevy consider the center of the mesh to be the center of the axis-aligned bounding box (AABB). Unfortunately, this breaks crossfading in many cases. LODs may have different AABBs and so the center of the AABB may differ for different LODs of the same mesh. The crossfading, however, relies on all LODs having *precisely* the same position. To address this problem, this PR adds a new field, `use_aabb`, to `VisibilityRange`, which makes the AABB center point behavior opt-in. @BenjaminBrienen first noticed this issue when reviewing PR bevyengine#16286. That PR contains a video showing the effects of this regression on the `visibility_range` example. This commit fixes that example.
…ed. (#16468) PR #15164 made Bevy consider the center of the mesh to be the center of the axis-aligned bounding box (AABB). Unfortunately, this breaks crossfading in many cases. LODs may have different AABBs and so the center of the AABB may differ for different LODs of the same mesh. The crossfading, however, relies on all LODs having *precisely* the same position. To address this problem, this PR adds a new field, `use_aabb`, to `VisibilityRange`, which makes the AABB center point behavior opt-in. @BenjaminBrienen first noticed this issue when reviewing PR #16286. That PR contains a video showing the effects of this regression on the `visibility_range` example. This commit fixes that example. ## Migration Guide * The `VisibilityRange` component now has an extra field, `use_aabb`. Generally, you can safely set it to false.
…ed. (#16468) PR #15164 made Bevy consider the center of the mesh to be the center of the axis-aligned bounding box (AABB). Unfortunately, this breaks crossfading in many cases. LODs may have different AABBs and so the center of the AABB may differ for different LODs of the same mesh. The crossfading, however, relies on all LODs having *precisely* the same position. To address this problem, this PR adds a new field, `use_aabb`, to `VisibilityRange`, which makes the AABB center point behavior opt-in. @BenjaminBrienen first noticed this issue when reviewing PR #16286. That PR contains a video showing the effects of this regression on the `visibility_range` example. This commit fixes that example. ## Migration Guide * The `VisibilityRange` component now has an extra field, `use_aabb`. Generally, you can safely set it to false.
…ed. (bevyengine#16468) PR bevyengine#15164 made Bevy consider the center of the mesh to be the center of the axis-aligned bounding box (AABB). Unfortunately, this breaks crossfading in many cases. LODs may have different AABBs and so the center of the AABB may differ for different LODs of the same mesh. The crossfading, however, relies on all LODs having *precisely* the same position. To address this problem, this PR adds a new field, `use_aabb`, to `VisibilityRange`, which makes the AABB center point behavior opt-in. @BenjaminBrienen first noticed this issue when reviewing PR bevyengine#16286. That PR contains a video showing the effects of this regression on the `visibility_range` example. This commit fixes that example. ## Migration Guide * The `VisibilityRange` component now has an extra field, `use_aabb`. Generally, you can safely set it to false.
…ed. (bevyengine#16468) PR bevyengine#15164 made Bevy consider the center of the mesh to be the center of the axis-aligned bounding box (AABB). Unfortunately, this breaks crossfading in many cases. LODs may have different AABBs and so the center of the AABB may differ for different LODs of the same mesh. The crossfading, however, relies on all LODs having *precisely* the same position. To address this problem, this PR adds a new field, `use_aabb`, to `VisibilityRange`, which makes the AABB center point behavior opt-in. @BenjaminBrienen first noticed this issue when reviewing PR bevyengine#16286. That PR contains a video showing the effects of this regression on the `visibility_range` example. This commit fixes that example. ## Migration Guide * The `VisibilityRange` component now has an extra field, `use_aabb`. Generally, you can safely set it to false.
Objective
I'm building a game where i generate a set of meshes where the transform is identity, and in each mesh the vertices are offset to where the model is. When adding visibility ranges to the models i noticed that they only switched when the distance to the origin changed over the threshold and all at the same time.
Solution
I believe that each mesh gets a Aabb generated for use with visibility testing. So we can use that aabb to calculate a more representative distance to the mesh.
The code to transform the aabb is taken from the visibility sysyem.
Testing
I tested the changes locally in my project.
Would you like me to write an example or a test somewhere?
Is there any other code that uses the visibility range, that i should also update?