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