chore(): cleanups, clippy etc
This commit is contained in:
parent
877c29b63c
commit
fa4386a185
|
@ -1,7 +1,7 @@
|
|||
use std::path::Path;
|
||||
|
||||
use bevy::{
|
||||
asset::{AssetId, AssetServer, Assets, Handle},
|
||||
asset::{AssetServer, Assets, Handle},
|
||||
ecs::{
|
||||
component::Component,
|
||||
entity::Entity,
|
||||
|
@ -11,7 +11,7 @@ use bevy::{
|
|||
},
|
||||
gltf::Gltf,
|
||||
hierarchy::{Children, Parent},
|
||||
log::{debug, info},
|
||||
log::debug,
|
||||
pbr::StandardMaterial,
|
||||
reflect::Reflect,
|
||||
render::mesh::Mesh,
|
||||
|
@ -66,20 +66,21 @@ 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();
|
||||
let mut asset_infos: Vec<AssetLoadTracker<Gltf>> = vec![];
|
||||
let asset_infos: Vec<AssetLoadTracker<Gltf>> = vec![
|
||||
AssetLoadTracker {
|
||||
name: material_full_path,
|
||||
id: material_file_id,
|
||||
loaded: false,
|
||||
handle: material_file_handle.clone(),
|
||||
}
|
||||
];
|
||||
|
||||
asset_infos.push(AssetLoadTracker {
|
||||
name: material_full_path,
|
||||
id: material_file_id,
|
||||
loaded: false,
|
||||
handle: material_file_handle.clone(),
|
||||
});
|
||||
commands
|
||||
.entity(entity)
|
||||
.insert(AssetsToLoad {
|
||||
all_loaded: false,
|
||||
asset_infos: asset_infos,
|
||||
progress: 0.0, //..Default::default()
|
||||
asset_infos,
|
||||
..Default::default()
|
||||
})
|
||||
.insert(BlueprintMaterialAssetsNotLoaded);
|
||||
/**/
|
||||
|
|
|
@ -52,17 +52,24 @@ pub struct BlueprintsList(pub HashMap<String, Vec<String>>);
|
|||
|
||||
#[derive(Default, Debug)]
|
||||
pub(crate) struct AssetLoadTracker<T: bevy::prelude::Asset> {
|
||||
#[allow(dead_code)]
|
||||
pub name: String,
|
||||
pub id: AssetId<T>,
|
||||
pub loaded: bool,
|
||||
#[allow(dead_code)]
|
||||
pub handle: Handle<T>,
|
||||
}
|
||||
#[derive(Component, Default, Debug)]
|
||||
#[derive(Component, Debug)]
|
||||
pub(crate) struct AssetsToLoad<T: bevy::prelude::Asset> {
|
||||
pub all_loaded: bool,
|
||||
pub asset_infos: Vec<AssetLoadTracker<T>>,
|
||||
pub progress: f32,
|
||||
}
|
||||
impl <T: bevy::prelude::Asset>Default for AssetsToLoad<T> {
|
||||
fn default() -> Self {
|
||||
Self { all_loaded: Default::default(), asset_infos: Default::default(), progress: Default::default() }
|
||||
}
|
||||
}
|
||||
|
||||
/// flag component
|
||||
#[derive(Component)]
|
||||
|
@ -118,17 +125,17 @@ pub(crate) fn prepare_blueprints(
|
|||
id: model_id,
|
||||
loaded: false,
|
||||
handle: model_handle.clone(),
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
// if not all assets are already loaded, inject a component to signal that we need them to be loaded
|
||||
if asset_infos.len() > 0 {
|
||||
if !asset_infos.is_empty() {
|
||||
commands
|
||||
.entity(entity)
|
||||
.insert(AssetsToLoad {
|
||||
all_loaded: false,
|
||||
asset_infos: asset_infos,
|
||||
progress: 0.0, //..Default::default()
|
||||
asset_infos,
|
||||
..Default::default()
|
||||
})
|
||||
.insert(BlueprintAssetsNotLoaded);
|
||||
} else {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use bevy::{prelude::*, utils::hashbrown::HashMap};
|
||||
use bevy::prelude::*;
|
||||
use bevy_gltf_blueprints::{
|
||||
BluePrintBundle, BlueprintName, BlueprintsList, GameWorldTag, Library, SpawnHere,
|
||||
BluePrintBundle, BlueprintName, GameWorldTag,
|
||||
};
|
||||
use bevy_gltf_worlflow_examples_common_rapier::{assets::GameAssets, GameState, InAppRunning};
|
||||
use bevy_gltf_worlflow_examples_common_rapier::{GameState, InAppRunning};
|
||||
|
||||
use bevy_rapier3d::prelude::Velocity;
|
||||
use rand::Rng;
|
||||
|
|
Loading…
Reference in New Issue