From 21ad422f4639bd0d6a150eea266e05c4176593ec Mon Sep 17 00:00:00 2001 From: Mark Moissette Date: Sat, 25 Nov 2023 02:52:23 +0100 Subject: [PATCH] fix(bevy_gltf_blueprints): fixed aabb caching issue (#59) closes #58 --- Cargo.lock | 2 +- crates/bevy_gltf_blueprints/Cargo.toml | 2 +- crates/bevy_gltf_blueprints/src/aabb.rs | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c74ee6..27adf74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -755,7 +755,7 @@ dependencies = [ [[package]] name = "bevy_gltf_blueprints" -version = "0.3.2" +version = "0.3.3" dependencies = [ "bevy", "bevy_gltf_components 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/crates/bevy_gltf_blueprints/Cargo.toml b/crates/bevy_gltf_blueprints/Cargo.toml index 43ac2b4..9b7e7af 100644 --- a/crates/bevy_gltf_blueprints/Cargo.toml +++ b/crates/bevy_gltf_blueprints/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_gltf_blueprints" -version = "0.3.2" +version = "0.3.3" authors = ["Mark 'kaosat-dev' Moissette"] description = "Adds the ability to define Blueprints/Prefabs for [Bevy](https://bevyengine.org/) inside gltf files and spawn them in Bevy." homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow" diff --git a/crates/bevy_gltf_blueprints/src/aabb.rs b/crates/bevy_gltf_blueprints/src/aabb.rs index b3e0d58..68cca60 100644 --- a/crates/bevy_gltf_blueprints/src/aabb.rs +++ b/crates/bevy_gltf_blueprints/src/aabb.rs @@ -21,10 +21,15 @@ pub fn compute_scene_aabbs( let root_entity = root_entity.2.first().unwrap(); // only recompute aabb if it has not already been done before - if !blueprints_config.aabb_cache.contains_key(&name.to_string()) { + if blueprints_config.aabb_cache.contains_key(&name.to_string()) { + let aabb = blueprints_config + .aabb_cache + .get(&name.to_string()) + .expect("we should have the aabb available"); + commands.entity(*root_entity).insert(*aabb); + } else { let aabb = compute_descendant_aabb(*root_entity, &children, &existing_aabbs); commands.entity(*root_entity).insert(aabb); - blueprints_config.aabb_cache.insert(name.to_string(), aabb); } }