Skip to content

Commit

Permalink
Drain ExtractedUiNodes in prepare_uinodes (#9142)
Browse files Browse the repository at this point in the history
# Objective

`ExtractedUiNodes` is cleared by the `extract_uinodes` function during
the extraction schedule. Because the Bevy UI renderer uses a painters
algorithm, this makes it impossible for users to create a custom
extraction function that adds items for a node to be drawn behind the
rectangle added by `extract_uniodes`.

## Solution

Drain `ExtractedUiNodes` in `prepare_ui_nodes` instead, after the
extraction schedule has finished.
  • Loading branch information
ickshonpe authored Jul 13, 2023
1 parent c720e7f commit 0df3d7f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ pub fn extract_uinodes(
>,
>,
) {
extracted_uinodes.uinodes.clear();

for (stack_index, entity) in ui_stack.uinodes.iter().enumerate() {
if let Ok((uinode, transform, color, maybe_image, visibility, clip)) =
uinode_query.get(*entity)
Expand Down Expand Up @@ -636,7 +634,7 @@ pub fn prepare_uinodes(
image.id() != DEFAULT_IMAGE_HANDLE.id()
}

for extracted_uinode in &extracted_uinodes.uinodes {
for extracted_uinode in extracted_uinodes.uinodes.drain(..) {
let mode = if is_textured(&extracted_uinode.image) {
if current_batch_image.id() != extracted_uinode.image.id() {
if is_textured(&current_batch_image) && start != end {
Expand Down

0 comments on commit 0df3d7f

Please sign in to comment.