feat(Blenvy): removed local assets, as they are useless, renamed AllAssets to BlenvyAssets

This commit is contained in:
kaosat.dev 2024-06-22 13:58:05 +02:00
parent c162c33575
commit ed5dfeb3cd
12 changed files with 22 additions and 66 deletions

View File

@ -20,7 +20,7 @@ pub struct LocalAssets(pub Vec<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 AllAssets(pub Vec<MyAsset>); pub struct BlenvyAssets(pub Vec<MyAsset>);

View File

@ -123,7 +123,7 @@ impl Plugin for BlueprintsPlugin {
.register_type::<Vec<MyAsset>>() .register_type::<Vec<MyAsset>>()
.register_type::<Vec<String>>() .register_type::<Vec<String>>()
.register_type::<LocalAssets>() .register_type::<LocalAssets>()
.register_type::<AllAssets>() .register_type::<BlenvyAssets>()
.register_type::<HashMap<String, Vec<String>>>() .register_type::<HashMap<String, Vec<String>>>()

View File

@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};
use bevy::{gltf::Gltf, prelude::*, utils::hashbrown::HashMap}; use bevy::{gltf::Gltf, prelude::*, utils::hashbrown::HashMap};
use crate::{AllAssets, AssetsToLoad, AssetLoadTracker, BluePrintsConfig, BlueprintAnimations, BlueprintAssetsLoaded, BlueprintAssetsNotLoaded}; use crate::{BlenvyAssets, AssetsToLoad, AssetLoadTracker, BluePrintsConfig, BlueprintAnimations, BlueprintAssetsLoaded, BlueprintAssetsNotLoaded};
/// this is a flag component for our levels/game world /// this is a flag component for our levels/game world
#[derive(Component)] #[derive(Component)]
@ -76,9 +76,9 @@ pub(crate) fn test_thingy(
&BlueprintPath, &BlueprintPath,
Option<&Parent>,*/ Option<&Parent>,*/
Option<&Name>, Option<&Name>,
Option<&AllAssets>, Option<&BlenvyAssets>,
), ),
(Added<AllAssets>), // Added<AllAssets> (Added<BlenvyAssets>), // Added<BlenvyAssets>
>, >,

View File

@ -15,12 +15,7 @@ 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 BlenvyAssets(pub Vec<MyAsset>);
/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
pub struct AllAssets(pub Vec<MyAsset>);

View File

@ -50,26 +50,6 @@ impl Default for BluePrintBundle {
} }
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Default)]
pub enum GltfFormat {
#[default]
GLB,
GLTF,
}
impl fmt::Display for GltfFormat {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
GltfFormat::GLB => {
write!(f, "glb",)
}
GltfFormat::GLTF => {
write!(f, "gltf")
}
}
}
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
/// Plugin for gltf blueprints /// Plugin for gltf blueprints
pub struct BlueprintsPlugin { pub struct BlueprintsPlugin {
@ -112,8 +92,7 @@ impl Plugin for BlueprintsPlugin {
.register_type::<MyAsset>() .register_type::<MyAsset>()
.register_type::<Vec<MyAsset>>() .register_type::<Vec<MyAsset>>()
.register_type::<Vec<String>>() .register_type::<Vec<String>>()
.register_type::<LocalAssets>() .register_type::<BlenvyAssets>()
.register_type::<AllAssets>()
.add_event::<BlueprintEvent>() .add_event::<BlueprintEvent>()

View File

@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};
use bevy::{gltf::Gltf, prelude::*, utils::hashbrown::HashMap}; use bevy::{gltf::Gltf, prelude::*, utils::hashbrown::HashMap};
use crate::{AllAssets, AssetsToLoad, AssetLoadTracker, BlenvyConfig, BlueprintAnimations, BlueprintAssetsLoaded, BlueprintAssetsNotLoaded}; use crate::{BlenvyAssets, AssetsToLoad, AssetLoadTracker, BlenvyConfig, BlueprintAnimations, BlueprintAssetsLoaded, BlueprintAssetsNotLoaded};
/// this is a flag component for our levels/game world /// this is a flag component for our levels/game world
#[derive(Component)] #[derive(Component)]
@ -99,9 +99,9 @@ pub(crate) fn blueprints_prepare_spawn(
&BlueprintPath, &BlueprintPath,
Option<&Parent>,*/ Option<&Parent>,*/
Option<&Name>, Option<&Name>,
Option<&AllAssets>, Option<&BlenvyAssets>,
), ),
(Added<AllAssets>), // Added<AllAssets> (Added<BlenvyAssets>), // Added<BlenvyAssets>
>, >,
@ -111,7 +111,7 @@ pub(crate) fn blueprints_prepare_spawn(
&BlueprintName, &BlueprintName,
&BlueprintPath, &BlueprintPath,
Option<&Parent>, Option<&Parent>,
Option<&AllAssets>, Option<&BlenvyAssets>,
),(Added<BlueprintPath>) ),(Added<BlueprintPath>)
>, >,
mut commands: Commands, mut commands: Commands,

View File

@ -13231,11 +13231,11 @@
"type": "object", "type": "object",
"typeInfo": "Struct" "typeInfo": "Struct"
}, },
"blenvy::blueprints::assets::AllAssets": { "blenvy::blueprints::assets::BlenvyAssets": {
"isComponent": true, "isComponent": true,
"isResource": false, "isResource": false,
"items": false, "items": false,
"long_name": "blenvy::blueprints::assets::AllAssets", "long_name": "blenvy::blueprints::assets::BlenvyAssets",
"prefixItems": [ "prefixItems": [
{ {
"type": { "type": {
@ -13243,23 +13243,7 @@
} }
} }
], ],
"short_name": "AllAssets", "short_name": "BlenvyAssets",
"type": "array",
"typeInfo": "TupleStruct"
},
"blenvy::blueprints::assets::LocalAssets": {
"isComponent": true,
"isResource": false,
"items": false,
"long_name": "blenvy::blueprints::assets::LocalAssets",
"prefixItems": [
{
"type": {
"$ref": "#/$defs/alloc::vec::Vec<blenvy::blueprints::assets::MyAsset>"
}
}
],
"short_name": "LocalAssets",
"type": "array", "type": "array",
"typeInfo": "TupleStruct" "typeInfo": "TupleStruct"
}, },

View File

@ -7,7 +7,7 @@ pub use animation::*;
use std::{collections::HashMap, fs, time::Duration}; use std::{collections::HashMap, fs, time::Duration};
use blenvy::{ use blenvy::{
AllAssets, BlueprintAnimationPlayerLink, BlueprintEvent, BlueprintName, GltfBlueprintsSet, SceneAnimations BlenvyAssets, BlueprintAnimationPlayerLink, BlueprintEvent, BlueprintName, GltfBlueprintsSet, SceneAnimations
}; };
use bevy::{ use bevy::{
@ -39,7 +39,7 @@ fn validate_export(
scene_animations: Query<(Entity, &SceneAnimations)>, scene_animations: Query<(Entity, &SceneAnimations)>,
empties_candidates: Query<(Entity, &Name, &GlobalTransform)>, empties_candidates: Query<(Entity, &Name, &GlobalTransform)>,
assets_list: Query<(Entity, &AllAssets)>, assets_list: Query<(Entity, &BlenvyAssets)>,
root: Query<(Entity, &Name, &Children), (Without<Parent>, With<Children>)>, root: Query<(Entity, &Name, &Children), (Without<Parent>, With<Children>)>,
) { ) {
let animations_found = let animations_found =

View File

@ -1,5 +1,5 @@
use bevy::{gltf::{GltfMaterialExtras, GltfMeshExtras, GltfSceneExtras}, prelude::*}; use bevy::{gltf::{GltfMaterialExtras, GltfMeshExtras, GltfSceneExtras}, prelude::*};
use blenvy::{AllAssets, BlueprintInstanceReady}; use blenvy::{BlenvyAssets, BlueprintInstanceReady};
use crate::BasicTest; use crate::BasicTest;
@ -32,7 +32,7 @@ pub fn get_descendants(
all_children: &Query<&Children>, all_children: &Query<&Children>,
all_names:&Query<&Name>, root: &Entity, all_names:&Query<&Name>, root: &Entity,
nesting: usize, nesting: usize,
to_check: &Query<&BasicTest>//&Query<(&BlueprintInstanceReady, &AllAssets)>, to_check: &Query<&BasicTest>//&Query<(&BlueprintInstanceReady, &BlenvyAssets)>,
) )
-> String -> String
{ {
@ -67,7 +67,7 @@ pub fn draw_hierarchy_debug(
all_children: Query<&Children>, all_children: Query<&Children>,
all_names:Query<&Name>, all_names:Query<&Name>,
to_check: Query<&BasicTest>,//Query<(&BlueprintInstanceReady, &AllAssets)>, to_check: Query<&BasicTest>,//Query<(&BlueprintInstanceReady, &BlenvyAssets)>,
mut display: Query<&mut Text, With<HiearchyDebugTag>>, mut display: Query<&mut Text, With<HiearchyDebugTag>>,
){ ){
let mut hierarchy_display: Vec<String> = vec![]; let mut hierarchy_display: Vec<String> = vec![];

View File

@ -141,6 +141,7 @@ General issues:
- [x] change "assets" tab to "levels"/worlds tab & modify UI accordingly - [x] change "assets" tab to "levels"/worlds tab & modify UI accordingly
- [ ] add option to 'split out' meshes from blueprints ? - [ ] add option to 'split out' meshes from blueprints ?
- [ ] ie considering meshletts etc , it would make sense to keep blueprints seperate from purely mesh gltfs - [ ] ie considering meshletts etc , it would make sense to keep blueprints seperate from purely mesh gltfs
- [ ] remove local assets, useless
- [x] remove 'export_marked_assets' it should be a default setting - [x] remove 'export_marked_assets' it should be a default setting
- [x] disable/ hide asset editing ui for external assets - [x] disable/ hide asset editing ui for external assets

View File

@ -37,8 +37,7 @@ def export_blueprints(blueprints, settings, blueprints_data):
all_assets = [] all_assets = []
auto_assets = [] auto_assets = []
collection["local_assets"] = assets_to_fake_ron([{"name": asset.name, "path": asset.path} for asset in collection.user_assets] + auto_assets) collection["BlenvyAssets"] = assets_to_fake_ron([{"name": asset.name, "path": asset.path} for asset in collection.user_assets] + auto_assets) #all_assets + [{"name": asset.name, "path": asset.path} for asset in collection.user_assets] + auto_assets)
collection["AllAssets"] = assets_to_fake_ron([{"name": asset.name, "path": asset.path} for asset in collection.user_assets]) #all_assets + [{"name": asset.name, "path": asset.path} for asset in collection.user_assets] + auto_assets)
# do the actual export # do the actual export

View File

@ -78,9 +78,7 @@ def export_main_scene(scene, settings, blueprints_data):
materials_exported_path = os.path.join(materials_path, f"{materials_library_name}{export_gltf_extension}") materials_exported_path = os.path.join(materials_path, f"{materials_library_name}{export_gltf_extension}")
material_assets = [{"name": materials_library_name, "path": materials_exported_path}] # we also add the material library as an asset material_assets = [{"name": materials_library_name, "path": materials_exported_path}] # we also add the material library as an asset
scene["BlenvyAssets"] = assets_to_fake_ron(all_assets + [{"name": asset.name, "path": asset.path} for asset in scene.user_assets] + auto_assets + material_assets)
scene["local_assets"] = assets_to_fake_ron([{"name": asset.name, "path": asset.path} for asset in scene.user_assets] + auto_assets + material_assets)
scene["AllAssets"] = assets_to_fake_ron(all_assets + [{"name": asset.name, "path": asset.path} for asset in scene.user_assets] + auto_assets + material_assets)
if export_separate_dynamic_and_static_objects: if export_separate_dynamic_and_static_objects: