Fix Camera::is_active and delayed spawned no cpu culling camera not rendering anything - #25690
Open
CodingDaniel1 wants to merge 4 commits into
Open
Fix Camera::is_active and delayed spawned no cpu culling camera not rendering anything#25690CodingDaniel1 wants to merge 4 commits into
Camera::is_active and delayed spawned no cpu culling camera not rendering anything#25690CodingDaniel1 wants to merge 4 commits into
Conversation
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 is a followup pr for #25670
I have found issues related to toggling
is_activeat runtime causes the rendering to stop working, and this pr fixes that. While fixing on that, ive found another issues when usingNoCpuCullingon Mesh entity, if the camera is spawned after the entity got collected for rendering, then the camera wont render that entity. The reason whyNoCpuCullingon Mesh causes this but not on camera, is the gpu mesh collect pass looks forViewVisibilitychanges, and cpu culling system will trigger the change detection even if the camera is tagged withNoCpuCulling. But it wont trigger it when mesh haveNoCpuCulling.Solution
For the
is_activeissue, I removedRenderVisibleEntitiesfrom the render camera when its inactive, but dont remove it when the window is minized. This behaviour matches what bevy other places does, which most places dont care if window is minized.For the second issue, I check to see is
RenderVisibleEntitiesadded this frame incollect_gpu_culled_meshesand do a full table flush whenRenderVisibleEntitiesis confirmed to be new. This means a freshly spawned camera will pick up previously registered mesh, and is_active toggling camera will still do the same. Be aware that this is solely forMesh3dtagged withNoCpuCullingsince thats purpose of this function, anyMesh3dnot tagged withNoCpuCullingwill still go through the cpu collect pass instead.Testing
I used the following functions to toggle is_active field and use gpu culling path, put it in 3d_scene and ssao example. Live test it, the rendering stays the same when toggling is_active at runtime. But the issue remains on bevy/main.
Here is the full code snippet i used for testing both issues. The camera spawning will be delayed by 2sec. On main you will not see anything rendered, but with this pr, rendering is normal.