-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
UI stack partition #20870
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
UI stack partition #20870
Conversation
… the same root and globalzindex.
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.
Very neat
continue; | ||
} | ||
|
||
// Nodes with Display::None have a (0., 0.) logical rect and can be ignored |
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.
I stumbled here for a moment... I was like: "What does Display::None have to do with this?" until I figured that I should read the sentence in another way:
"Nodes that have a size of 0 - logical rect of (0., 0.) - are actually "Display::None" and thus can be ignored
Objective
In the UI picking and rendering systems, we first query for all the pickable or renderable UI nodes and then query per node for the details of the camera and its render target. But the typical application using Bevy UI will have hundreds of UI nodes and just one UI camera, so this is extremely inefficient.
Instead, we can partition the UI stack into disjoint slices where all the UI nodes in each slice have the same camera target. Then perform any camera and render target lookups per slice, instead of per node.
Solution
Partition the UI stack into disjoint layers of nodes sharing the same camera target.
partition: Vec<Range<usize>>
field toUiStack
.ui_stack_system
.ui_focus_system
andui_picking
.Splitting the rendering changes off into their own PR.
Testing
Some basic checks have been added to the existing
test_ui_stack_system
andtest_with_equal_global_zindex_zindex_decides_order
tests.Examples like
ui_target_camera
,viewport_node
andui_drag_and_drop
can be used to test the changes.Showcase
yellow this PR, red main:
cargo run --example many_buttons --release --features bevy/trace_tracy
ui_picking
ui_stack_system