mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-26 21:37:01 +00:00
Compare commits
No commits in common. "c476c05c55ddd5eb61dcb415ed26c06804409c37" and "f561112704ba7531a69e5a7ae8f7f87736f79a80" have entirely different histories.
c476c05c55
...
f561112704
@ -62,9 +62,14 @@ pub enum GltfComponentsSet {
|
||||
#[derive(Clone, Resource)]
|
||||
pub struct GltfComponentsConfig {}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ComponentsFromGltfPlugin {}
|
||||
|
||||
impl Default for ComponentsFromGltfPlugin {
|
||||
fn default() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl Plugin for ComponentsFromGltfPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugins(blender_settings::plugin)
|
||||
|
@ -15,15 +15,16 @@ pub fn ronstring_to_reflect_component(
|
||||
let mut components: Vec<(Box<dyn Reflect>, TypeRegistration)> = Vec::new();
|
||||
// println!("ron_string {:?}", ron_string);
|
||||
for (name, value) in lookup.into_iter() {
|
||||
let parsed_value: String = match value.clone() {
|
||||
let parsed_value: String;
|
||||
match value.clone() {
|
||||
Value::String(str) => {
|
||||
str
|
||||
parsed_value = str;
|
||||
}
|
||||
_ => parsed_value = ron::to_string(&value).unwrap().to_string(),
|
||||
}
|
||||
_ => ron::to_string(&value).unwrap().to_string(),
|
||||
};
|
||||
|
||||
if name.as_str() == "bevy_components" {
|
||||
bevy_components_string_to_components(parsed_value, type_registry, &mut components);
|
||||
bevy_components_string_to_components(parsed_value, type_registry, &mut components)
|
||||
} else {
|
||||
components_string_to_components(
|
||||
name,
|
||||
@ -31,7 +32,7 @@ pub fn ronstring_to_reflect_component(
|
||||
parsed_value,
|
||||
type_registry,
|
||||
&mut components,
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
components
|
||||
@ -94,12 +95,13 @@ fn bevy_components_string_to_components(
|
||||
) {
|
||||
let lookup: HashMap<String, Value> = ron::from_str(&parsed_value).unwrap();
|
||||
for (key, value) in lookup.into_iter() {
|
||||
let parsed_value: String = match value.clone() {
|
||||
let parsed_value: String;
|
||||
match value.clone() {
|
||||
Value::String(str) => {
|
||||
str
|
||||
parsed_value = str;
|
||||
}
|
||||
_ => parsed_value = ron::to_string(&value).unwrap().to_string(),
|
||||
}
|
||||
_ => ron::to_string(&value).unwrap().to_string(),
|
||||
};
|
||||
|
||||
if let Some(type_registration) = type_registry.get_with_type_path(key.as_str()) {
|
||||
debug!("TYPE INFO {:?}", type_registration.type_info());
|
||||
|
@ -17,6 +17,7 @@ pub fn export_types(world: &mut World) {
|
||||
|
||||
let asset_root = world.resource::<AssetRoot>();
|
||||
let registry_save_path = Path::join(&asset_root.0, &config.save_path);
|
||||
println!("registry_save_path {}", registry_save_path.display());
|
||||
let writer = File::create(registry_save_path).expect("should have created schema file");
|
||||
|
||||
let components_to_filter_out = &config.component_filter.clone();
|
||||
@ -28,8 +29,8 @@ pub fn export_types(world: &mut World) {
|
||||
.iter()
|
||||
.filter(|type_info| {
|
||||
let type_id = type_info.type_id();
|
||||
components_to_filter_out.is_allowed_by_id(type_id)
|
||||
&& resources_to_filter_out.is_allowed_by_id(type_id)
|
||||
return components_to_filter_out.is_allowed_by_id(type_id)
|
||||
&& resources_to_filter_out.is_allowed_by_id(type_id);
|
||||
})
|
||||
.map(export_type)
|
||||
.collect::<Map<_, _>>();
|
||||
|
@ -12,8 +12,8 @@ Auto export
|
||||
|
||||
|
||||
- move out some parameters from auto export to a higher level (as they are now used in multiple places)
|
||||
- [x] main/ library scene names
|
||||
- [x] paths
|
||||
- [ ] main/ library scene names
|
||||
- [ ] paths
|
||||
|
||||
Data storage:
|
||||
- for scenes (main scenes)
|
||||
@ -37,7 +37,7 @@ Assets:
|
||||
- QUESTION : do we want to include them in the list of assets per level ?
|
||||
- this would enable pre-loading ALL the assets, but is not ideal in most other cases
|
||||
- so add an option ?
|
||||
- [] the assets of local blueprints
|
||||
- [ ] the assets of local blueprints
|
||||
|
||||
|
||||
Blueprints:
|
||||
|
@ -8,4 +8,4 @@ def absolute_path_from_blend_file(path):
|
||||
blend_file_folder_path = os.path.dirname(blend_file_path)
|
||||
|
||||
# absolute path
|
||||
return os.path.abspath(os.path.join(blend_file_folder_path, path))
|
||||
return os.path.join(blend_file_folder_path, path)
|
||||
|
@ -4,8 +4,6 @@ import os
|
||||
from bpy_extras.io_utils import ImportHelper
|
||||
from bpy.types import Operator
|
||||
|
||||
from ...core.path_helpers import absolute_path_from_blend_file
|
||||
|
||||
class OT_OpenFolderbrowser(Operator, ImportHelper):
|
||||
"""Browse for registry json file"""
|
||||
bl_idname = "generic.open_folderbrowser"
|
||||
@ -40,60 +38,35 @@ class OT_OpenFolderbrowser(Operator, ImportHelper):
|
||||
blend_file_path = bpy.data.filepath
|
||||
# Get the folder
|
||||
blend_file_folder_path = os.path.dirname(blend_file_path)
|
||||
#print("blend_file_folder_path", blend_file_folder_path)
|
||||
print("blend_file_folder_path", blend_file_folder_path)
|
||||
print("new_path", self.directory, self.target_property, operator)
|
||||
|
||||
asset_path_names = ['export_blueprints_path', 'export_levels_path', 'export_materials_path']
|
||||
export_root_path = absolute_path_from_blend_file(operator.export_root_path)
|
||||
asset_path_names = ['export_assets_path', 'export_blueprints_path', 'export_levels_path', 'export_materials_path']
|
||||
export_root_path = operator.export_root_path
|
||||
export_assets_path = operator.export_assets_path
|
||||
export_assets_path_full = absolute_path_from_blend_file(os.path.join(export_root_path, export_assets_path)) #os.path.join(blend_file_folder_path, export_root_path, export_assets_path)
|
||||
#export_root_path_absolute = os.path.join(blend_file_folder_path, export_root_path)
|
||||
export_assets_path_full = os.path.join(blend_file_folder_path, export_root_path, export_assets_path)
|
||||
print("export_assets_path_full", export_assets_path_full)
|
||||
|
||||
#new_root_path = os.path.join(blend_file_folder_path, new_path)
|
||||
if target_path_name == 'export_root_path':
|
||||
new_root_path_relative = os.path.relpath(new_path, blend_file_folder_path)
|
||||
new_root_path_absolute = new_path
|
||||
|
||||
print("new_root_path_relative", new_root_path_relative, new_root_path_absolute)
|
||||
# first change the asset's path
|
||||
old_assets_paths_relative = getattr(operator, "export_assets_path", None)
|
||||
if old_assets_paths_relative is not None:
|
||||
old_assets_paths_absolute = os.path.abspath(os.path.join(export_root_path, old_assets_paths_relative))
|
||||
new_assets_path_relative = os.path.relpath(old_assets_paths_absolute, new_root_path_absolute)
|
||||
new_assets_path_absolute = os.path.abspath(os.path.join(new_root_path_absolute, new_assets_path_relative))
|
||||
|
||||
print("old_assets_paths_absolute", old_assets_paths_absolute)
|
||||
print("new_assets_path_relative", new_assets_path_relative)
|
||||
print("new_assets_path_absolute", new_assets_path_absolute)
|
||||
setattr(operator, "export_assets_path", new_assets_path_relative)
|
||||
|
||||
# we need to change all other relative paths (root => assets => blueprints/levels/materials etc)
|
||||
print("changing root new_path to", self.directory, blend_file_folder_path, new_root_path_relative)
|
||||
# we need to change all other relative paths before setting the new absolute path
|
||||
for path_name in asset_path_names:
|
||||
# get current relative path
|
||||
relative_path = getattr(operator, path_name, None)
|
||||
if relative_path is not None:
|
||||
# and now get absolute path of asset_path
|
||||
# compute 'old' absolute path
|
||||
old_absolute_path = os.path.abspath(os.path.join(export_assets_path_full, relative_path))
|
||||
relative_path = os.path.relpath(old_absolute_path, new_assets_path_absolute)
|
||||
absolute_path = os.path.join(export_assets_path_full, relative_path)
|
||||
print("absolute path for", path_name, absolute_path)
|
||||
relative_path = os.path.relpath(absolute_path, new_path)
|
||||
setattr(operator, path_name, relative_path)
|
||||
|
||||
# store the root path as relative to the current blend file
|
||||
setattr(operator, target_path_name, new_root_path_relative)
|
||||
setattr(operator, target_path_name, new_path)
|
||||
elif target_path_name == 'export_assets_path':
|
||||
new_assets_path_relative = os.path.relpath(new_path, export_root_path)
|
||||
new_assets_path_absolute = new_path
|
||||
# we need to change all other relative paths (root => assets => blueprints/levels/materials etc)
|
||||
for path_name in asset_path_names:
|
||||
# get 'old' relative path
|
||||
relative_path = getattr(operator, path_name, None)
|
||||
if relative_path is not None:
|
||||
# compute 'old' absolute path
|
||||
old_absolute_path = os.path.abspath(os.path.join(export_assets_path_full, relative_path))
|
||||
relative_path = os.path.relpath(old_absolute_path, new_assets_path_absolute)
|
||||
setattr(operator, path_name, relative_path)
|
||||
|
||||
setattr(operator, target_path_name, new_assets_path_relative)
|
||||
pass
|
||||
else:
|
||||
relative_path = os.path.relpath(new_path, export_assets_path_full)
|
||||
setattr(operator, target_path_name, relative_path)
|
||||
|
@ -15,6 +15,7 @@ class SCENE_UL_Blenvy(bpy.types.UIList):
|
||||
# Note: as index and flt_flag are optional arguments, you do not have to use/declare them here if you don't
|
||||
# need them.
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
print("DRAW STUFF", self)
|
||||
ob = data
|
||||
# draw_item must handle the three layout types... Usually 'DEFAULT' and 'COMPACT' can share the same code.
|
||||
if self.layout_type in {'DEFAULT', 'COMPACT'}:
|
||||
|
Loading…
Reference in New Issue
Block a user