refactor(): minor cleanups
This commit is contained in:
parent
10e85fce26
commit
bb0975bbe8
|
@ -30,8 +30,6 @@ pub(crate) struct BlueprintMaterialAssetsLoaded;
|
|||
#[derive(Component)]
|
||||
pub(crate) struct BlueprintMaterialAssetsNotLoaded;
|
||||
|
||||
|
||||
|
||||
/// system that injects / replaces materials from material library
|
||||
pub(crate) fn materials_inject(
|
||||
blueprints_config: ResMut<BluePrintsConfig>,
|
||||
|
@ -65,7 +63,6 @@ pub(crate) fn materials_inject(
|
|||
} else {
|
||||
let material_file_handle: Handle<Gltf> = asset_server.load(materials_path.clone());
|
||||
let material_file_id = material_file_handle.id();
|
||||
println!("loading material {} {}", material_full_path, material_file_id);
|
||||
let mut asset_infos:Vec<AssetLoadTracker<Gltf>> = vec![];
|
||||
|
||||
asset_infos.push(AssetLoadTracker {
|
||||
|
@ -103,14 +100,12 @@ pub(crate) fn check_for_material_loaded(
|
|||
let loaded = asset_server.is_loaded_with_dependencies(asset_id);
|
||||
tracker.loaded = loaded;
|
||||
if loaded {
|
||||
println!("loaded {} {}", tracker.name, tracker.id);
|
||||
loaded_amount += 1;
|
||||
}else{
|
||||
all_loaded = false;
|
||||
}
|
||||
}
|
||||
let progress:f32 = loaded_amount as f32 / total as f32;
|
||||
println!("progress (materials): {}",progress);
|
||||
assets_to_load.progress = progress;
|
||||
|
||||
if all_loaded {
|
||||
|
@ -141,7 +136,6 @@ pub(crate) fn materials_inject2(
|
|||
mut commands: Commands,
|
||||
) {
|
||||
for (material_info, children) in material_infos.iter() {
|
||||
println!("here");
|
||||
let model_file_name = format!(
|
||||
"{}_materials_library.{}",
|
||||
&material_info.source, &blueprints_config.format
|
||||
|
@ -157,7 +151,7 @@ pub(crate) fn materials_inject2(
|
|||
.material_library_cache
|
||||
.contains_key(&material_full_path)
|
||||
{
|
||||
info!("material is cached, retrieving");
|
||||
debug!("material is cached, retrieving");
|
||||
let material = blueprints_config
|
||||
.material_library_cache
|
||||
.get(&material_full_path)
|
||||
|
@ -165,8 +159,6 @@ pub(crate) fn materials_inject2(
|
|||
material_found = Some(material);
|
||||
}else {
|
||||
let model_handle: Handle<Gltf> = asset_server.load(materials_path.clone());// FIXME: kinda weird now
|
||||
println!("loading material {:?} {}", materials_path, model_handle.id());
|
||||
|
||||
let mat_gltf = assets_gltf
|
||||
.get(model_handle.id())
|
||||
.expect("material should have been preloaded");
|
||||
|
|
|
@ -51,20 +51,6 @@ pub(crate) struct OriginalChildren(pub Vec<Entity>);
|
|||
#[reflect(Component)]
|
||||
pub struct BlueprintsList(pub HashMap<String,Vec<String>>);
|
||||
|
||||
#[derive(Reflect, Default, Debug)]
|
||||
pub(crate) struct BlueprintLoadTracker{
|
||||
pub name: String,
|
||||
pub id: AssetId<Gltf>,
|
||||
pub loaded: bool,
|
||||
pub handle: Handle<Gltf>
|
||||
}
|
||||
#[derive(Component, Default, Debug)]
|
||||
pub(crate) struct BlueprintAssetsToLoad{
|
||||
pub all_loaded: bool,
|
||||
pub asset_infos: Vec<BlueprintLoadTracker>,
|
||||
pub progress: f32
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
pub(crate) struct AssetLoadTracker<T:bevy::prelude::Asset>{
|
||||
pub name: String,
|
||||
|
@ -117,7 +103,7 @@ pub(crate) fn spawn_from_blueprints(
|
|||
) in spawn_placeholders.iter()
|
||||
{
|
||||
debug!(
|
||||
"preparing to spawn {:?} for entity {:?}, id: {:?}, parent:{:?}",
|
||||
"requesting to spawn {:?} for entity {:?}, id: {:?}, parent:{:?}",
|
||||
blupeprint_name.0, name, entity, original_parent
|
||||
);
|
||||
|
||||
|
@ -194,7 +180,7 @@ pub(crate) fn check_for_loaded(
|
|||
}
|
||||
}
|
||||
let progress:f32 = loaded_amount as f32 / total as f32;
|
||||
println!("progress: {}",progress);
|
||||
// println!("progress: {}",progress);
|
||||
assets_to_load.progress = progress;
|
||||
|
||||
if all_loaded {
|
||||
|
@ -242,7 +228,7 @@ pub(crate) fn actually_spawn_stuff(
|
|||
) in spawn_placeholders.iter()
|
||||
{
|
||||
info!(
|
||||
"need to spawn {:?} for entity {:?}, id: {:?}, parent:{:?}",
|
||||
"attempting to spawn {:?} for entity {:?}, id: {:?}, parent:{:?}",
|
||||
blupeprint_name.0, name, entity, original_parent
|
||||
);
|
||||
|
||||
|
@ -254,7 +240,7 @@ pub(crate) fn actually_spawn_stuff(
|
|||
library_override.map_or_else(|| &blueprints_config.library_folder, |l| &l.0);
|
||||
let model_path = Path::new(&library_path).join(Path::new(model_file_name.as_str()));
|
||||
|
||||
info!("attempting to spawn {:?}", model_path);
|
||||
// info!("attempting to spawn {:?}", model_path);
|
||||
let model_handle: Handle<Gltf> = asset_server.load(model_path);// FIXME: kinda weird now
|
||||
|
||||
let gltf = assets_gltf
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use std::any::TypeId;
|
||||
|
||||
use bevy::gltf::Gltf;
|
||||
use bevy::prelude::*;
|
||||
use bevy::scene::SceneInstance;
|
||||
// use bevy::utils::hashbrown::HashSet;
|
||||
|
||||
use super::{AnimationPlayerLink, Animations};
|
||||
use super::{SpawnHere, Spawned};
|
||||
use crate::{BlueprintAssetsToLoad, CopyComponents, InBlueprint, NoInBlueprint, OriginalChildren};
|
||||
use crate::{AssetsToLoad, 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
|
||||
|
@ -89,7 +90,7 @@ pub(crate) fn spawned_blueprint_post_process(
|
|||
commands.entity(original).remove::<SpawnHere>();
|
||||
commands.entity(original).remove::<Spawned>();
|
||||
commands.entity(original).remove::<Handle<Scene>>();
|
||||
commands.entity(original).remove::<BlueprintAssetsToLoad>();// 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::<AssetsToLoad<Gltf>>();// 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(root_entity).despawn_recursive();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue