From 5d89a28ecd2ad0d87bb474606b5df102ff566870 Mon Sep 17 00:00:00 2001 From: Danny McGee Date: Wed, 28 Feb 2024 19:58:22 -0500 Subject: [PATCH] More reliable SceneElement tagging --- studio/src/inspector/wasm.rs | 6 +++++- studio/src/scene.rs | 11 +---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/studio/src/inspector/wasm.rs b/studio/src/inspector/wasm.rs index 286619a..062a56b 100644 --- a/studio/src/inspector/wasm.rs +++ b/studio/src/inspector/wasm.rs @@ -131,6 +131,7 @@ pub(super) fn notify_entity_spawn_changes( mut l_missing_parents: Local>, q_window: Query<&Window, With>, q_inspectables: Query<(Entity, &SceneElement)>, + q_element_changes: Query>, q_others: Query>, q_names: Query<&Name>, q_parents: Query<&Children>, @@ -146,6 +147,7 @@ pub(super) fn notify_entity_spawn_changes( ent, type_, &q_inspectables, + &q_element_changes, &q_names, &q_parents, &q_children, @@ -166,6 +168,7 @@ pub(super) fn notify_entity_spawn_changes( ent, SceneElement::Generic, &q_inspectables, + &q_element_changes, &q_names, &q_parents, &q_children, @@ -204,11 +207,12 @@ fn build_scene_object( ent: Entity, type_: SceneElement, q_inspectables: &Query<(Entity, &SceneElement)>, + q_element_changes: &Query>, q_names: &Query<&Name>, q_parents: &Query<&Children>, q_children: &Query<&Parent>, ) -> Option { - if notified.contains(&ent) { + if notified.contains(&ent) && !q_element_changes.contains(ent) { return None; } diff --git a/studio/src/scene.rs b/studio/src/scene.rs index 9cd07df..06d5f34 100644 --- a/studio/src/scene.rs +++ b/studio/src/scene.rs @@ -395,17 +395,8 @@ fn tag_scene_elements( mesh_entities: Query>>, ) { for (e, children) in q_named_non_primitives.iter() { - let mut has_mesh = false; - for child in children { - if mesh_entities.contains(*child) { - has_mesh = true; - break; - } - } - if has_mesh { + if children.iter().any(|child| mesh_entities.contains(*child)) { cmd.entity(e).insert(SceneElement::Mesh); - } else { - cmd.entity(e).insert(SceneElement::Generic); } } }