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

CameraProjection::compute_frustum #11139

Merged
merged 2 commits into from
Feb 4, 2024

Conversation

stepancheg
Copy link
Contributor

Frustum computation is nontrivial amount of code private in update_frusta system.

Make it public.

This is needed to decide which entities to spawn/despawn in Update based on camera changes. But if Update also changed camera, frustum is not yet recomputed.

Technically it is probably possible to run an iteration of update_frusta system by a user in Update schedule after propagating GlobalTransform to the cameras, but it is easier to just compute frustum manually using API added in this PR.

Also replace two places where this code is used.

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Dec 30, 2023
crates/bevy_render/src/camera/projection.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@jdm jdm left a comment

Choose a reason for hiding this comment

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

Nice simplification of existing code and sensible new public API.

@james7132 james7132 added this pull request to the merge queue Feb 4, 2024
Merged via the queue into bevyengine:main with commit 08654ad Feb 4, 2024
22 checks passed
tjamaan pushed a commit to tjamaan/bevy that referenced this pull request Feb 6, 2024
Frustum computation is nontrivial amount of code private in
`update_frusta` system.

Make it public.

This is needed to decide which entities to spawn/despawn in `Update`
based on camera changes. But if `Update` also changed camera, frustum is
not yet recomputed.

Technically it is probably possible to run an iteration of
`update_frusta` system by a user in `Update` schedule after propagating
`GlobalTransform` to the cameras, but it is easier to just compute
frustum manually using API added in this PR.

Also replace two places where this code is used.

---------

Co-authored-by: vero <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants