Skip to content

Commit e883f3a

Browse files
authored
fix(Blenvy-Bevy): Fix some minor issues around initialization (#243)
* Fix unconfigured set * Improve global transform initialization
1 parent dd03026 commit e883f3a

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

crates/blenvy/src/blueprints/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@ impl Plugin for BlueprintsPlugin {
107107
.add_plugins(RonAssetPlugin::<BlueprintPreloadAssets>::new(&["meta.ron"]))
108108
.configure_sets(
109109
Update,
110-
(GltfBlueprintsSet::Spawn, GltfBlueprintsSet::AfterSpawn)
111-
.chain()
112-
.after(GltfComponentsSet::Injection),
110+
(
111+
GltfComponentsSet::Injection,
112+
GltfBlueprintsSet::Spawn,
113+
GltfBlueprintsSet::AfterSpawn,
114+
)
115+
.chain(),
113116
)
114117
.add_systems(
115118
Update,

crates/blenvy/src/blueprints/spawn_from_blueprints.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,12 @@ pub(crate) fn blueprints_check_assets_loading(
440440

441441
pub(crate) fn blueprints_assets_loaded(
442442
spawn_placeholders: Query<
443-
(Entity, &BlueprintInfo, Option<&Transform>, Option<&Name>),
443+
(
444+
Entity,
445+
&BlueprintInfo,
446+
Option<(&Transform, &GlobalTransform)>,
447+
Option<&Name>,
448+
),
444449
(
445450
Added<BlueprintAssetsLoaded>,
446451
Without<BlueprintAssetsNotLoaded>,
@@ -454,7 +459,7 @@ pub(crate) fn blueprints_assets_loaded(
454459

455460
mut commands: Commands,
456461
) {
457-
for (entity, blueprint_info, transform, name) in spawn_placeholders.iter() {
462+
for (entity, blueprint_info, maybe_transform, name) in spawn_placeholders.iter() {
458463
/*info!(
459464
"BLUEPRINT: all assets loaded, attempting to spawn blueprint SCENE {:?} for entity {:?}, id: {:}, parent:{:?}",
460465
blueprint_info.name, name, entity, original_parent
@@ -485,10 +490,10 @@ pub(crate) fn blueprints_assets_loaded(
485490
let scene = &blueprint_gltf.named_scenes[main_scene_name];
486491

487492
// transforms are optional, but still deal with them correctly
488-
let mut transforms: Transform = Transform::default();
489-
if transform.is_some() {
490-
transforms = *transform.unwrap();
491-
}
493+
let (transform, global_transform) = match maybe_transform {
494+
Some((transform, global_transform)) => (*transform, *global_transform),
495+
None => (Transform::default(), GlobalTransform::default()),
496+
};
492497

493498
let mut original_children: Vec<Entity> = vec![];
494499
if let Ok(c) = all_children.get(entity) {
@@ -516,7 +521,8 @@ pub(crate) fn blueprints_assets_loaded(
516521
commands.entity(entity).insert((
517522
SceneBundle {
518523
scene: scene.clone(),
519-
transform: transforms,
524+
transform,
525+
global_transform,
520526
..Default::default()
521527
},
522528
OriginalChildren(original_children),

0 commit comments

Comments
 (0)