Skip to content

Commit 8be0495

Browse files
ickshonpemockersf
authored andcommitted
Remove the visited local system param from update_ui_context_system. (#18664)
# Objective The `visited: Local<HashSet<Entity>>` system param is meant to track which entities `update_contexts_recursively` has visited and updated but when the reparent_nodes_query isn't ordered descending from parent to child nodes can get marked as visited even though their camera target is unset and if the camera target is unset then the node won't be rendered. Fixes #18616 ## Solution Remove the `visited` system param from `update_ui_context_system` and the associated visited check from `update_contexts_recursively`. It was redundant anyway since the set_if_neq check is sufficient to track already updated nodes. ## Testing The example from #18616 can be used for testing.
1 parent 9d4d110 commit 8be0495

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

crates/bevy_ui/src/update.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ use crate::{
99
use super::ComputedNode;
1010
use bevy_ecs::{
1111
change_detection::DetectChangesMut,
12-
entity::{Entity, EntityHashSet},
12+
entity::Entity,
1313
hierarchy::ChildOf,
1414
query::{Changed, With},
15-
system::{Commands, Local, Query, Res},
15+
system::{Commands, Query, Res},
1616
};
1717
use bevy_math::{Rect, UVec2};
1818
use bevy_render::camera::Camera;
@@ -139,9 +139,7 @@ pub fn update_ui_context_system(
139139
mut computed_target_query: Query<&mut ComputedNodeTarget>,
140140
ui_children: UiChildren,
141141
reparented_nodes: Query<(Entity, &ChildOf), (Changed<ChildOf>, With<ComputedNodeTarget>)>,
142-
mut visited: Local<EntityHashSet>,
143142
) {
144-
visited.clear();
145143
let default_camera_entity = default_ui_camera.get();
146144

147145
for root_entity in ui_root_nodes.iter() {
@@ -172,7 +170,6 @@ pub fn update_ui_context_system(
172170
},
173171
&ui_children,
174172
&mut computed_target_query,
175-
&mut visited,
176173
);
177174
}
178175

@@ -186,7 +183,6 @@ pub fn update_ui_context_system(
186183
*computed_target,
187184
&ui_children,
188185
&mut computed_target_query,
189-
&mut visited,
190186
);
191187
}
192188
}
@@ -196,24 +192,14 @@ fn update_contexts_recursively(
196192
inherited_computed_target: ComputedNodeTarget,
197193
ui_children: &UiChildren,
198194
query: &mut Query<&mut ComputedNodeTarget>,
199-
visited: &mut EntityHashSet,
200195
) {
201-
if !visited.insert(entity) {
202-
return;
203-
}
204196
if query
205197
.get_mut(entity)
206198
.map(|mut computed_target| computed_target.set_if_neq(inherited_computed_target))
207199
.unwrap_or(false)
208200
{
209201
for child in ui_children.iter_ui_children(entity) {
210-
update_contexts_recursively(
211-
child,
212-
inherited_computed_target,
213-
ui_children,
214-
query,
215-
visited,
216-
);
202+
update_contexts_recursively(child, inherited_computed_target, ui_children, query);
217203
}
218204
}
219205
}

0 commit comments

Comments
 (0)