From 3961e0b22cf7ae484efe75d5943d6553b8ad451e Mon Sep 17 00:00:00 2001 From: "kaosat.dev" Date: Thu, 27 Jun 2024 09:40:06 +0200 Subject: [PATCH] feat(Blenvy:blender): made it impossible to add or update components that are not in the registry * minor tweaks & cleanups --- tools/blenvy/TODO.md | 24 +++++++++++-------- tools/blenvy/add_ons/auto_export/ui.py | 2 +- .../add_ons/bevy_components/components/ui.py | 8 +++---- .../bevy_components/propGroups/process_map.py | 3 --- .../add_ons/bevy_components/settings.py | 3 ++- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tools/blenvy/TODO.md b/tools/blenvy/TODO.md index 3b5b791..c80e075 100644 --- a/tools/blenvy/TODO.md +++ b/tools/blenvy/TODO.md @@ -171,8 +171,13 @@ Blender side: - [x] in theory, srgba, linearrgba , and hsva should be able to be represented visually - [x] bevy_render::color::Color => bevy_color::color::Color - [x] fix weird issue with hashmaps with enums as values -- [ ] prevent attempting to add unexisting components to targets (ie when using the component search) - +- [x] prevent attempting to add unexisting components to targets (ie when using the component search) + - [x] also for the bulk fix actions +- [ ] hidden objects/collections only semi respected at export + - this is because blueprints are external ? + - [ ] verify based on gltf settings + - [ ] add "Visibility::Hidden" component otherwise + https://devtalk.blender.org/t/how-to-get-render-visibility-for-object/23717 - [ ] inject_export_path_into_internal_blueprints should be called on every asset/blueprint scan !! Not just on export - [ ] undo after a save removes any saved "serialized scene" data ? DIG into this @@ -181,11 +186,9 @@ Blender side: - [ ] disabled components - [ ] blueprint instances as children of blueprint instances - [ ] blueprint instances as children of empties +- [ ] update testing files + -- [ ] hidden objects/collections not respected at export !!!? - - [ ] verify based on gltf settings - - [ ] add "hidden" component otherwise ? - https://devtalk.blender.org/t/how-to-get-render-visibility-for-object/23717 - [ ] add option to 'split out' meshes from blueprints ? - [ ] ie considering meshletts etc , it would make sense to keep blueprints seperate from purely mesh gltfs - [ ] persist exported materials path in blueprints so that it can be read from library file users @@ -195,11 +198,16 @@ Blender side: Bevy Side: - [x] deprecate BlueprintName & BlueprintPath & use BlueprintInfo instead +- [ ] make blueprint instances invisible until spawning is done to avoid "spawn flash"? - [ ] should "blueprint spawned" only be triggered after all its sub blueprints have spawned ? - [ ] simplify testing example: - [x] remove use of rapier physics (or even the whole common boilerplate ?) - [ ] remove/replace bevy editor pls with some native ui to display hierarchies - [x] try out hot reloading +- [ ] add a way of overriding assets for collection instances + - [ ] add a way of visualizing per blueprint instances +- [ ] cleanup all the spurious debug messages +- [ ] fix animation handling - [ ] simplify examples: - [ ] a full fledged demo (including physics & co) - [ ] other examples without interactions or physics @@ -208,9 +216,5 @@ Bevy Side: - [ ] replace all references to the old 2 add-ons with those to Blenvy - [ ] rename repo to "Blenvy" - [ ] do a deprecation release of all bevy_gltf_xxx crates to point at the new Blenvy crate -- [ ] add a way of overriding assets for collection instances - - [ ] add a way of visualizing per blueprint instances -- [ ] cleanup all the spurious debug messages -- [ ] fix animation handling clear && pytest -svv --blender-template ../../testing/bevy_example/art/testing_library.blend --blender-executable /home/ckaos/tools/blender/blender-4.1.0-linux-x64/blender tests/test_bevy_integration_prepare.py && pytest -svv --blender-executable /home/ckaos/tools/blender/blender-4.1.0-linux-x64/blender tests/test_bevy_integration.py \ No newline at end of file diff --git a/tools/blenvy/add_ons/auto_export/ui.py b/tools/blenvy/add_ons/auto_export/ui.py index d41772e..8ab01ba 100644 --- a/tools/blenvy/add_ons/auto_export/ui.py +++ b/tools/blenvy/add_ons/auto_export/ui.py @@ -15,7 +15,7 @@ def draw_settings_ui(layout, auto_export_settings): #op.export_format = 'GLTF_SEPARATE' op.use_selection=True op.will_save_settings=True - op.use_visible=True # Export visible and hidden objects. See Object/Batch Export to skip. + op.use_visible=True op.use_renderable=True op.use_active_collection = True op.use_active_collection_with_nested=True diff --git a/tools/blenvy/add_ons/bevy_components/components/ui.py b/tools/blenvy/add_ons/bevy_components/components/ui.py index 9408a39..ffcc296 100644 --- a/tools/blenvy/add_ons/bevy_components/components/ui.py +++ b/tools/blenvy/add_ons/bevy_components/components/ui.py @@ -209,7 +209,7 @@ def draw_component_ui(layout, object_or_collection, registry, selected_component row = layout.row(align=True) op = row.operator("blenvy.component_add", text="Add", icon="ADD") op.component_type = selected_component - row.enabled = selected_component != '' + row.enabled = selected_component != '' and selected_component in list(registry.type_infos.keys()) layout.separator() @@ -377,7 +377,6 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel): def draw_invalid_items(self, layout, upgreadable_entries): for entry in upgreadable_entries: (status, custom_property, item, item_type) = entry - print("ENTRY", entry) self.draw_invalid_or_unregistered(layout, status, custom_property, item, item_type) def gather_invalid_item_data(self, item, invalid_component_names, items_with_invalid_components, items_with_original_components, original_name, item_type): @@ -428,8 +427,7 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel): layout = self.layout registry = bpy.context.window_manager.components_registry registry_has_type_infos = registry.has_type_infos() - selected_object = context.selected_objects[0] if len(context.selected_objects) > 0 else None - selected_component = bpy.context.window_manager.blenvy.components.component_selector + type_infos = list(registry.type_infos.keys()) row = layout.row() row.label(text= "* Single item actions: Rename / Fix / Upgrade")#"Invalid/ unregistered components") @@ -484,7 +482,7 @@ class BLENVY_PT_component_tools_panel(bpy.types.Panel): operator.original_name = original_name operator.target_name = target_component_name operator.target_items = json.dumps(items_with_original_components) - col.enabled = registry_has_type_infos and original_name != "" and original_name != target_component_name + col.enabled = registry_has_type_infos and original_name != "" and original_name != target_component_name and original_name in type_infos and target_component_name in type_infos else: if hasattr(layout,"progress") : # only for Blender > 4.0 col.progress(factor = components_rename_progress, text=f"updating {components_rename_progress * 100.0:.2f}%") diff --git a/tools/blenvy/add_ons/bevy_components/propGroups/process_map.py b/tools/blenvy/add_ons/bevy_components/propGroups/process_map.py index 7795f65..2b9d261 100644 --- a/tools/blenvy/add_ons/bevy_components/propGroups/process_map.py +++ b/tools/blenvy/add_ons/bevy_components/propGroups/process_map.py @@ -43,14 +43,11 @@ def process_map(registry, definition, update, nesting_long_names=[]): #if the content of the list is a unit type, we need to generate a fake wrapper, otherwise we cannot use layout.prop(group, "propertyName") as there is no propertyName ! if is_value_value_type: - print("WRAPPPER, property group", definition["short_name"]) values_property_group_class = generate_wrapper_propertyGroup(f"{long_name}_values", original_long_name, definition_link, registry, update, nesting_long_names) else: (_, list_content_group_class) = process_component.process_component(registry, value_definition, update, {"nested": True, "long_name": original_long_name}, nesting_long_names) values_property_group_class = list_content_group_class - print("COMPONENT, property group", definition["short_name"], values_property_group_class) - values_collection = CollectionProperty(type=values_property_group_class) values_property_group_pointer = PointerProperty(type=values_property_group_class) diff --git a/tools/blenvy/add_ons/bevy_components/settings.py b/tools/blenvy/add_ons/bevy_components/settings.py index 7e4edf9..739cf38 100644 --- a/tools/blenvy/add_ons/bevy_components/settings.py +++ b/tools/blenvy/add_ons/bevy_components/settings.py @@ -93,7 +93,8 @@ class ComponentsSettings(PropertyGroup): component_selector: StringProperty( - search=add_component_to_ui_list + search=add_component_to_ui_list, + description="component selector: only components present in the registry are accepted" )# type: ignore