fix(bevy_gltf_blueprints): fixed aabb caching issue (#59)

closes #58
This commit is contained in:
Mark Moissette 2023-11-25 02:52:23 +01:00 committed by GitHub
parent 9a765d5e12
commit 21ad422f46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

2
Cargo.lock generated
View File

@ -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)",

View File

@ -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"

View File

@ -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);
}
}