mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-22 20:00:53 +00:00
chore(Blenvy:Bevy): more cleanups
This commit is contained in:
parent
459bb868e0
commit
70931ee163
@ -7,7 +7,7 @@ use crate::{BluePrintsConfig, BlueprintAnimations};
|
|||||||
/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints
|
/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints
|
||||||
#[derive(Component, Reflect, Default, Debug)]
|
#[derive(Component, Reflect, Default, Debug)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component)]
|
||||||
pub struct MyAsset {
|
pub struct BlueprintAsset {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
}
|
}
|
||||||
@ -15,12 +15,12 @@ pub struct MyAsset {
|
|||||||
/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints
|
/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints
|
||||||
#[derive(Component, Reflect, Default, Debug)]
|
#[derive(Component, Reflect, Default, Debug)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component)]
|
||||||
pub struct LocalAssets(pub Vec<MyAsset>);
|
pub struct LocalAssets(pub Vec<BlueprintAsset>);
|
||||||
|
|
||||||
/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints
|
/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints
|
||||||
#[derive(Component, Reflect, Default, Debug)]
|
#[derive(Component, Reflect, Default, Debug)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component)]
|
||||||
pub struct BlueprintAssets(pub Vec<MyAsset>);
|
pub struct BlueprintAssets(pub Vec<BlueprintAsset>);
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
///
|
///
|
||||||
|
@ -119,8 +119,8 @@ impl Plugin for BlueprintsPlugin {
|
|||||||
.register_type::<HashMap<u32, Vec<String>>>()
|
.register_type::<HashMap<u32, Vec<String>>>()
|
||||||
.register_type::<HashMap<String, HashMap<u32, Vec<String>>>>()
|
.register_type::<HashMap<String, HashMap<u32, Vec<String>>>>()
|
||||||
.add_event::<AnimationMarkerReached>()
|
.add_event::<AnimationMarkerReached>()
|
||||||
.register_type::<MyAsset>()
|
.register_type::<BlueprintAsset>()
|
||||||
.register_type::<Vec<MyAsset>>()
|
.register_type::<Vec<BlueprintAsset>>()
|
||||||
.register_type::<Vec<String>>()
|
.register_type::<Vec<String>>()
|
||||||
.register_type::<LocalAssets>()
|
.register_type::<LocalAssets>()
|
||||||
.register_type::<BlueprintAssets>()
|
.register_type::<BlueprintAssets>()
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
use std::path::{Path, PathBuf};
|
use bevy::{asset::LoadedUntypedAsset, prelude::*};
|
||||||
|
|
||||||
use bevy::{asset::LoadedUntypedAsset, gltf::Gltf, prelude::*, utils::HashMap};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::{BlenvyConfig, BlueprintAnimations};
|
|
||||||
|
|
||||||
/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints
|
/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints
|
||||||
#[derive(Component, Reflect, Default, Debug, Deserialize)]
|
#[derive(Component, Reflect, Default, Debug, Deserialize)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component)]
|
||||||
pub struct MyAsset {
|
pub struct BlueprintAsset {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
}
|
}
|
||||||
@ -18,7 +14,7 @@ pub struct MyAsset {
|
|||||||
#[reflect(Component)]
|
#[reflect(Component)]
|
||||||
pub struct BlueprintAssets {
|
pub struct BlueprintAssets {
|
||||||
/// only this field should get filled in from the Blender side
|
/// only this field should get filled in from the Blender side
|
||||||
pub assets: Vec<MyAsset>,
|
pub assets: Vec<BlueprintAsset>,
|
||||||
/// set to default when deserializing
|
/// set to default when deserializing
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
#[reflect(default)]
|
#[reflect(default)]
|
||||||
@ -31,7 +27,7 @@ pub struct BlueprintAssets {
|
|||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub asset_infos: Vec<AssetLoadTracker>,
|
pub asset_infos: Vec<AssetLoadTracker>,
|
||||||
}
|
}
|
||||||
//(pub Vec<MyAsset>);
|
//(pub Vec<BlueprintAsset>);
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
///
|
///
|
||||||
@ -44,7 +40,7 @@ pub(crate) struct BlueprintAssetsNotLoaded;
|
|||||||
|
|
||||||
/// helper component, for tracking loaded assets's loading state, id , handle etc
|
/// helper component, for tracking loaded assets's loading state, id , handle etc
|
||||||
#[derive(Debug, Reflect)]
|
#[derive(Debug, Reflect)]
|
||||||
pub(crate) struct AssetLoadTracker {
|
pub struct AssetLoadTracker {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use crate::{BlueprintAssetsLoadState, BlueprintAssetsLoaded, BlueprintInfo, SpawnBlueprint};
|
use crate::{BlueprintAssetsLoadState, BlueprintAssetsLoaded, BlueprintInfo, SpawnBlueprint};
|
||||||
use bevy::asset::{AssetEvent, LoadedUntypedAsset};
|
use bevy::asset::AssetEvent;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::scene::SceneInstance;
|
use bevy::scene::SceneInstance;
|
||||||
|
|
||||||
pub(crate) fn react_to_asset_changes(
|
pub(crate) fn react_to_asset_changes(
|
||||||
mut gltf_events: EventReader<AssetEvent<Gltf>>,
|
mut gltf_events: EventReader<AssetEvent<Gltf>>,
|
||||||
mut untyped_events: EventReader<AssetEvent<LoadedUntypedAsset>>,
|
// mut untyped_events: EventReader<AssetEvent<LoadedUntypedAsset>>,
|
||||||
mut blueprint_assets: Query<(
|
mut blueprint_assets: Query<(
|
||||||
Entity,
|
Entity,
|
||||||
Option<&Name>,
|
Option<&Name>,
|
||||||
@ -22,7 +22,7 @@ pub(crate) fn react_to_asset_changes(
|
|||||||
AssetEvent::Modified { id } => {
|
AssetEvent::Modified { id } => {
|
||||||
// React to the image being modified
|
// React to the image being modified
|
||||||
// println!("Modified gltf {:?}", asset_server.get_path(*id));
|
// println!("Modified gltf {:?}", asset_server.get_path(*id));
|
||||||
for (entity, entity_name, blueprint_info, mut assets_to_load, children) in
|
for (entity, entity_name, _blueprint_info, mut assets_to_load, children) in
|
||||||
blueprint_assets.iter_mut()
|
blueprint_assets.iter_mut()
|
||||||
{
|
{
|
||||||
for tracker in assets_to_load.asset_infos.iter_mut() {
|
for tracker in assets_to_load.asset_infos.iter_mut() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use crate::{BlenvyConfig, BlueprintReadyForPostProcess};
|
use crate::BlenvyConfig;
|
||||||
|
|
||||||
#[derive(Component, Reflect, Default, Debug)]
|
#[derive(Component, Reflect, Default, Debug)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component)]
|
||||||
|
@ -16,13 +16,10 @@ pub use materials::*;
|
|||||||
pub mod copy_components;
|
pub mod copy_components;
|
||||||
pub use copy_components::*;
|
pub use copy_components::*;
|
||||||
|
|
||||||
pub mod hot_reload;
|
pub(crate) mod hot_reload;
|
||||||
pub use hot_reload::*;
|
pub(crate) use hot_reload::*;
|
||||||
|
|
||||||
use core::fmt;
|
use bevy::{prelude::*, utils::HashMap};
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use bevy::{prelude::*, render::primitives::Aabb, utils::HashMap};
|
|
||||||
|
|
||||||
use crate::{BlenvyConfig, GltfComponentsSet};
|
use crate::{BlenvyConfig, GltfComponentsSet};
|
||||||
|
|
||||||
@ -112,8 +109,8 @@ impl Plugin for BlueprintsPlugin {
|
|||||||
.register_type::<HashMap<u32, Vec<String>>>()
|
.register_type::<HashMap<u32, Vec<String>>>()
|
||||||
.register_type::<HashMap<String, HashMap<u32, Vec<String>>>>()
|
.register_type::<HashMap<String, HashMap<u32, Vec<String>>>>()
|
||||||
.add_event::<AnimationMarkerReached>()
|
.add_event::<AnimationMarkerReached>()
|
||||||
.register_type::<MyAsset>()
|
.register_type::<BlueprintAsset>()
|
||||||
.register_type::<Vec<MyAsset>>()
|
.register_type::<Vec<BlueprintAsset>>()
|
||||||
.register_type::<Vec<String>>()
|
.register_type::<Vec<String>>()
|
||||||
.register_type::<BlueprintAssets>()
|
.register_type::<BlueprintAssets>()
|
||||||
.register_type::<HashMap<String, Vec<String>>>()
|
.register_type::<HashMap<String, Vec<String>>>()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use bevy::{gltf::Gltf, prelude::*, scene::SceneInstance, utils::hashbrown::HashMap};
|
use bevy::{gltf::Gltf, prelude::*, scene::SceneInstance, utils::hashbrown::HashMap};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
@ -113,7 +113,7 @@ Overview of the Blueprint Spawning process
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pub(crate) fn blueprints_prepare_spawn(
|
pub(crate) fn blueprints_prepare_spawn(
|
||||||
blueprint_instances_to_spawn: Query<(Entity, &BlueprintInfo), (Added<SpawnBlueprint>)>,
|
blueprint_instances_to_spawn: Query<(Entity, &BlueprintInfo), Added<SpawnBlueprint>>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
) {
|
) {
|
||||||
@ -401,8 +401,7 @@ pub(crate) fn blueprints_scenes_spawned(
|
|||||||
all_children: Query<&Children>,
|
all_children: Query<&Children>,
|
||||||
all_parents: Query<&Parent>,
|
all_parents: Query<&Parent>,
|
||||||
|
|
||||||
mut sub_blueprint_trackers: Query<(Entity, &mut SubBlueprintsSpawnTracker, &BlueprintInfo)>,
|
// mut sub_blueprint_trackers: Query<(Entity, &mut SubBlueprintsSpawnTracker, &BlueprintInfo)>,
|
||||||
|
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
|
|
||||||
all_names: Query<&Name>,
|
all_names: Query<&Name>,
|
||||||
@ -511,7 +510,7 @@ pub(crate) fn blueprints_cleanup_spawned_scene(
|
|||||||
>,
|
>,
|
||||||
added_animation_players: Query<(Entity, &Parent), Added<AnimationPlayer>>,
|
added_animation_players: Query<(Entity, &Parent), Added<AnimationPlayer>>,
|
||||||
|
|
||||||
mut sub_blueprint_trackers: Query<(Entity, &mut SubBlueprintsSpawnTracker, &BlueprintInfo)>,
|
mut sub_blueprint_trackers: Query<&mut SubBlueprintsSpawnTracker, With<BlueprintInfo>>,
|
||||||
all_children: Query<&Children>,
|
all_children: Query<&Children>,
|
||||||
|
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
@ -593,9 +592,7 @@ pub(crate) fn blueprints_cleanup_spawned_scene(
|
|||||||
if let Some(track_root) = track_root {
|
if let Some(track_root) = track_root {
|
||||||
let root_name = all_names.get(track_root.0);
|
let root_name = all_names.get(track_root.0);
|
||||||
println!("got some root {:?}", root_name);
|
println!("got some root {:?}", root_name);
|
||||||
if let Ok((s_entity, mut tracker, bp_info)) =
|
if let Ok(mut tracker) = sub_blueprint_trackers.get_mut(track_root.0) {
|
||||||
sub_blueprint_trackers.get_mut(track_root.0)
|
|
||||||
{
|
|
||||||
tracker
|
tracker
|
||||||
.sub_blueprint_instances
|
.sub_blueprint_instances
|
||||||
.entry(original)
|
.entry(original)
|
||||||
|
@ -10,7 +10,7 @@ pub use process_gltfs::*;
|
|||||||
pub mod blender_settings;
|
pub mod blender_settings;
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
ecs::{component::Component, reflect::ReflectComponent, system::Resource},
|
ecs::{component::Component, reflect::ReflectComponent},
|
||||||
prelude::{App, IntoSystemConfigs, Plugin, SystemSet, Update},
|
prelude::{App, IntoSystemConfigs, Plugin, SystemSet, Update},
|
||||||
reflect::Reflect,
|
reflect::Reflect,
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use bevy::log::{debug, warn};
|
use bevy::log::{debug, warn};
|
||||||
use bevy::reflect::serde::{ReflectDeserializer, ReflectSerializer};
|
use bevy::reflect::serde::ReflectDeserializer;
|
||||||
use bevy::reflect::{Reflect, TypeRegistration, TypeRegistry};
|
use bevy::reflect::{Reflect, TypeRegistration, TypeRegistry};
|
||||||
use bevy::utils::HashMap;
|
use bevy::utils::HashMap;
|
||||||
use ron::Value;
|
use ron::Value;
|
||||||
|
@ -250,16 +250,16 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"typeInfo": "List"
|
"typeInfo": "List"
|
||||||
},
|
},
|
||||||
"alloc::vec::Vec<blenvy::blueprints::assets::MyAsset>": {
|
"alloc::vec::Vec<blenvy::blueprints::assets::BlueprintAsset>": {
|
||||||
"isComponent": false,
|
"isComponent": false,
|
||||||
"isResource": false,
|
"isResource": false,
|
||||||
"items": {
|
"items": {
|
||||||
"type": {
|
"type": {
|
||||||
"$ref": "#/$defs/blenvy::blueprints::assets::MyAsset"
|
"$ref": "#/$defs/blenvy::blueprints::assets::BlueprintAsset"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"long_name": "alloc::vec::Vec<blenvy::blueprints::assets::MyAsset>",
|
"long_name": "alloc::vec::Vec<blenvy::blueprints::assets::BlueprintAsset>",
|
||||||
"short_name": "Vec<MyAsset>",
|
"short_name": "Vec<BlueprintAsset>",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"typeInfo": "List"
|
"typeInfo": "List"
|
||||||
},
|
},
|
||||||
@ -13354,6 +13354,31 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"typeInfo": "Struct"
|
"typeInfo": "Struct"
|
||||||
},
|
},
|
||||||
|
"blenvy::blueprints::assets::BlueprintAsset": {
|
||||||
|
"additionalProperties": false,
|
||||||
|
"isComponent": true,
|
||||||
|
"isResource": false,
|
||||||
|
"long_name": "blenvy::blueprints::assets::BlueprintAsset",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": {
|
||||||
|
"$ref": "#/$defs/alloc::string::String"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
"type": {
|
||||||
|
"$ref": "#/$defs/alloc::string::String"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"name",
|
||||||
|
"path"
|
||||||
|
],
|
||||||
|
"short_name": "BlueprintAsset",
|
||||||
|
"type": "object",
|
||||||
|
"typeInfo": "Struct"
|
||||||
|
},
|
||||||
"blenvy::blueprints::assets::BlueprintAssets": {
|
"blenvy::blueprints::assets::BlueprintAssets": {
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"isComponent": true,
|
"isComponent": true,
|
||||||
@ -13362,7 +13387,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"assets": {
|
"assets": {
|
||||||
"type": {
|
"type": {
|
||||||
"$ref": "#/$defs/alloc::vec::Vec<blenvy::blueprints::assets::MyAsset>"
|
"$ref": "#/$defs/alloc::vec::Vec<blenvy::blueprints::assets::BlueprintAsset>"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"loaded": {
|
"loaded": {
|
||||||
@ -13385,31 +13410,6 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"typeInfo": "Struct"
|
"typeInfo": "Struct"
|
||||||
},
|
},
|
||||||
"blenvy::blueprints::assets::MyAsset": {
|
|
||||||
"additionalProperties": false,
|
|
||||||
"isComponent": true,
|
|
||||||
"isResource": false,
|
|
||||||
"long_name": "blenvy::blueprints::assets::MyAsset",
|
|
||||||
"properties": {
|
|
||||||
"name": {
|
|
||||||
"type": {
|
|
||||||
"$ref": "#/$defs/alloc::string::String"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"path": {
|
|
||||||
"type": {
|
|
||||||
"$ref": "#/$defs/alloc::string::String"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"name",
|
|
||||||
"path"
|
|
||||||
],
|
|
||||||
"short_name": "MyAsset",
|
|
||||||
"type": "object",
|
|
||||||
"typeInfo": "Struct"
|
|
||||||
},
|
|
||||||
"blenvy::blueprints::materials::MaterialInfo": {
|
"blenvy::blueprints::materials::MaterialInfo": {
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"isComponent": true,
|
"isComponent": true,
|
||||||
|
Loading…
Reference in New Issue
Block a user