Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some minor issues around initialization #243

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions crates/blenvy/src/blueprints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ impl Plugin for BlueprintsPlugin {
.add_plugins(RonAssetPlugin::<BlueprintPreloadAssets>::new(&["meta.ron"]))
.configure_sets(
Update,
(GltfBlueprintsSet::Spawn, GltfBlueprintsSet::AfterSpawn)
.chain()
.after(GltfComponentsSet::Injection),
(
GltfComponentsSet::Injection,
GltfBlueprintsSet::Spawn,
GltfBlueprintsSet::AfterSpawn,
)
.chain(),
)
.add_systems(
Update,
Expand Down
20 changes: 13 additions & 7 deletions crates/blenvy/src/blueprints/spawn_from_blueprints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,12 @@ pub(crate) fn blueprints_check_assets_loading(

pub(crate) fn blueprints_assets_loaded(
spawn_placeholders: Query<
(Entity, &BlueprintInfo, Option<&Transform>, Option<&Name>),
(
Entity,
&BlueprintInfo,
Option<(&Transform, &GlobalTransform)>,
Option<&Name>,
),
(
Added<BlueprintAssetsLoaded>,
Without<BlueprintAssetsNotLoaded>,
Expand All @@ -454,7 +459,7 @@ pub(crate) fn blueprints_assets_loaded(

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

// transforms are optional, but still deal with them correctly
let mut transforms: Transform = Transform::default();
if transform.is_some() {
transforms = *transform.unwrap();
}
let (transform, global_transform) = match maybe_transform {
Some((transform, global_transform)) => (*transform, *global_transform),
None => (Transform::default(), GlobalTransform::default()),
};

let mut original_children: Vec<Entity> = vec![];
if let Ok(c) = all_children.get(entity) {
Expand Down Expand Up @@ -516,7 +521,8 @@ pub(crate) fn blueprints_assets_loaded(
commands.entity(entity).insert((
SceneBundle {
scene: scene.clone(),
transform: transforms,
transform,
global_transform,
..Default::default()
},
OriginalChildren(original_children),
Expand Down
Loading