From 9f89d1a9ec1883c77c5693af60b79a347530150f Mon Sep 17 00:00:00 2001 From: Schmarni Date: Fri, 31 Oct 2025 07:40:04 +0100 Subject: [PATCH] fix: don't recursivly despawn entities that handles depsawning themselfs Signed-off-by: Schmarni --- src/core/entity_handle.rs | 18 ++++++++++++++++-- src/nodes/drawable/text.rs | 1 - 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/core/entity_handle.rs b/src/core/entity_handle.rs index e14511f..00e12ba 100644 --- a/src/core/entity_handle.rs +++ b/src/core/entity_handle.rs @@ -3,6 +3,8 @@ use std::sync::Arc; use bevy::prelude::*; +use crate::nodes::spatial::SpatialNode; + use super::bevy_channel::{BevyChannel, BevyChannelReader}; pub struct EntityHandlePlugin; @@ -13,9 +15,21 @@ impl Plugin for EntityHandlePlugin { } } -fn despawn(mut cmds: Commands, mut reader: ResMut>) { +fn despawn( + mut cmds: Commands, + mut reader: ResMut>, + child_query: Query<&Children>, + has_spatial: Query>, +) { while let Some(e) = reader.read() { - cmds.entity(e).try_despawn(); + if let Ok(children) = child_query.get(e) { + for e in children { + if has_spatial.get(*e).unwrap_or_default() { + cmds.entity(*e).remove::(); + } + } + } + cmds.entity(e).despawn(); } } diff --git a/src/nodes/drawable/text.rs b/src/nodes/drawable/text.rs index f5af010..54780a7 100644 --- a/src/nodes/drawable/text.rs +++ b/src/nodes/drawable/text.rs @@ -32,7 +32,6 @@ pub struct TextNodePlugin; impl Plugin for TextNodePlugin { fn build(&self, app: &mut App) { // Text init stuff - // 1.0 for font size in meters app.add_plugins(MeshTextPlugin); app.world_mut() .resource_mut::()