diff --git a/crates/bevy_gltf_blueprints/src/lib.rs b/crates/bevy_gltf_blueprints/src/lib.rs index 266289a..a89619c 100644 --- a/crates/bevy_gltf_blueprints/src/lib.rs +++ b/crates/bevy_gltf_blueprints/src/lib.rs @@ -144,14 +144,29 @@ impl Plugin for BlueprintsPlugin { .add_systems( Update, ( - (spawn_from_blueprints, - check_for_loaded, - actually_spawn_stuff, apply_deferred).chain(), + ( + prepare_blueprints, + check_for_loaded, + spawn_from_blueprints, + apply_deferred + ) + .chain(), + ( + compute_scene_aabbs, + apply_deferred + ) + .chain() + .run_if(aabbs_enabled), - compute_scene_aabbs.run_if(aabbs_enabled), - apply_deferred.run_if(aabbs_enabled), apply_deferred, - (materials_inject, check_for_material_loaded, materials_inject2).chain().run_if(materials_library_enabled), + + ( + materials_inject, + check_for_material_loaded, + materials_inject2 + ) + .chain() + .run_if(materials_library_enabled), ) .chain() .in_set(GltfBlueprintsSet::Spawn), diff --git a/crates/bevy_gltf_blueprints/src/spawn_from_blueprints.rs b/crates/bevy_gltf_blueprints/src/spawn_from_blueprints.rs index 915c932..8603479 100644 --- a/crates/bevy_gltf_blueprints/src/spawn_from_blueprints.rs +++ b/crates/bevy_gltf_blueprints/src/spawn_from_blueprints.rs @@ -46,7 +46,6 @@ pub struct AddToGameWorld; /// helper component, just to transfer child data pub(crate) struct OriginalChildren(pub Vec); - #[derive(Component, Reflect, Default, Debug)] #[reflect(Component)] pub struct BlueprintsList(pub HashMap>); @@ -75,7 +74,7 @@ pub(crate) struct BlueprintAssetsNotLoaded; /// spawning prepare function, /// * also takes into account the already exisiting "override" components, ie "override components" > components from blueprint -pub(crate) fn spawn_from_blueprints( +pub(crate) fn prepare_blueprints( spawn_placeholders: Query< ( Entity, @@ -156,10 +155,14 @@ pub(crate) fn spawn_from_blueprints( .insert(BlueprintAssetsLoaded); } } + else { // in case there are no blueprintsList + commands + .entity(entity) + .insert(BlueprintAssetsLoaded); + } } } - pub(crate) fn check_for_loaded( mut blueprint_assets_to_load: Query<(Entity, &mut AssetsToLoad), With>, asset_server: Res, @@ -192,7 +195,7 @@ pub(crate) fn check_for_loaded( } } -pub(crate) fn actually_spawn_stuff( +pub(crate) fn spawn_from_blueprints( spawn_placeholders: Query< ( Entity, diff --git a/crates/bevy_gltf_blueprints/src/spawn_post_process.rs b/crates/bevy_gltf_blueprints/src/spawn_post_process.rs index 16bbca9..db84f89 100644 --- a/crates/bevy_gltf_blueprints/src/spawn_post_process.rs +++ b/crates/bevy_gltf_blueprints/src/spawn_post_process.rs @@ -7,7 +7,7 @@ use bevy::scene::SceneInstance; use super::{AnimationPlayerLink, Animations}; use super::{SpawnHere, Spawned}; -use crate::{AssetsToLoad, CopyComponents, InBlueprint, NoInBlueprint, OriginalChildren}; +use crate::{AssetsToLoad, BlueprintAssetsLoaded, CopyComponents, InBlueprint, NoInBlueprint, OriginalChildren}; /// this system is in charge of doing any necessary post processing after a blueprint scene has been spawned /// - it removes one level of useless nesting @@ -91,6 +91,7 @@ pub(crate) fn spawned_blueprint_post_process( commands.entity(original).remove::(); commands.entity(original).remove::>(); commands.entity(original).remove::>();// also clear the sub assets tracker to free up handles, perhaps just freeing up the handles and leave the rest would be better ? + commands.entity(original).remove::(); commands.entity(root_entity).despawn_recursive(); } }