feat(Blenvy:Blender):

* updated & improved & fixed filtering out of custom properties for export that are not components
 * now also for the temporary scenes
 * no more spurious "xxx is not registered" in Bevy for the Blender only custom properties
 * cleanups
This commit is contained in:
kaosat.dev 2024-07-25 10:34:20 +02:00
parent b3c87085de
commit e534917dca
7 changed files with 23 additions and 23 deletions

View File

@ -226,7 +226,7 @@ Blender side:
- [ ] materials_path custom property should be ignored both in the list of fixable component AND on export - [ ] materials_path custom property should be ignored both in the list of fixable component AND on export
- [ ] if we want to add material_infos & others as normal components they should not be editable, so we need another attribute, and adapt the UI for that - [ ] if we want to add material_infos & others as normal components they should not be editable, so we need another attribute, and adapt the UI for that
- [ ] if material library is toggled, then changes to materials should not change the blueprints that are using them ? - [ ] if material library is toggled, then changes to materials should not change the blueprints that are using them => not really: as the name & co might change
- [ ] material assets seem to be added to list regardless of whether material exports are enabled or not - [ ] material assets seem to be added to list regardless of whether material exports are enabled or not
- [ ] review & upgrade overall logic of material libraries, their names & output path - [ ] review & upgrade overall logic of material libraries, their names & output path
- [ ] persist exported materials path in blueprints so that it can be read from library file users - [ ] persist exported materials path in blueprints so that it can be read from library file users
@ -253,6 +253,7 @@ Blender side:
- [x] rename all "main scene xx" to "level scene" - [x] rename all "main scene xx" to "level scene"
- [x] make sure the "add scene" button is not available unless you have actually selected one - [x] make sure the "add scene" button is not available unless you have actually selected one
- [x] make auto export be on by default, however bail out early by detecting if there are any level/blueprint scenes - [x] make auto export be on by default, however bail out early by detecting if there are any level/blueprint scenes
- [x] remove custom components to filter out correctly from exported blueprints list
Bevy Side: Bevy Side:
- [x] deprecate BlueprintName & BlueprintPath & use BlueprintInfo instead - [x] deprecate BlueprintName & BlueprintPath & use BlueprintInfo instead

View File

@ -3,16 +3,7 @@ import bpy
from blenvy.core.object_makers import (make_empty) from blenvy.core.object_makers import (make_empty)
from blenvy.add_ons.bevy_components.utils import is_component_valid_and_enabled from blenvy.add_ons.bevy_components.utils import is_component_valid_and_enabled
from ..constants import custom_properties_to_filter_out from ..constants import custom_properties_to_filter_out
from ..utils import remove_unwanted_custom_properties
def remove_unwanted_custom_properties(object):
to_remove = []
component_names = list(object.keys()) # to avoid 'IDPropertyGroup changed size during iteration' issues
for component_name in component_names:
if not is_component_valid_and_enabled(object, component_name):
to_remove.append(component_name)
for cp in custom_properties_to_filter_out + to_remove:
if cp in object:
del object[cp]
# TODO: rename actions ? # TODO: rename actions ?
# reference https://github.com/KhronosGroup/glTF-Blender-IO/blob/main/addons/io_scene_gltf2/blender/exp/animation/gltf2_blender_gather_action.py#L481 # reference https://github.com/KhronosGroup/glTF-Blender-IO/blob/main/addons/io_scene_gltf2/blender/exp/animation/gltf2_blender_gather_action.py#L481

View File

@ -6,6 +6,9 @@ from .duplicate_object import duplicate_object
from .export_gltf import export_gltf from .export_gltf import export_gltf
from blenvy.core.scene_helpers import add_scene_property from blenvy.core.scene_helpers import add_scene_property
from ..constants import custom_properties_to_filter_out from ..constants import custom_properties_to_filter_out
from ..utils import remove_unwanted_custom_properties
""" """
generates a temporary scene, fills it with data, cleans up after itself generates a temporary scene, fills it with data, cleans up after itself
* named using temp_scene_name * named using temp_scene_name
@ -27,6 +30,9 @@ def generate_temporary_scene_and_export(settings, gltf_export_settings, gltf_out
print("entry in additional data", entry, "value", additional_data[entry], "in", additional_data.name) print("entry in additional data", entry, "value", additional_data[entry], "in", additional_data.name)
temp_scene[entry] = additional_data[entry] temp_scene[entry] = additional_data[entry]
# we remove everything from the black list
remove_unwanted_custom_properties(temp_scene)
# save active scene # save active scene
active_scene = bpy.context.window.scene active_scene = bpy.context.window.scene
# and selected collection # and selected collection

View File

@ -7,5 +7,5 @@ custom_properties_to_filter_out = [
'components_meta', 'Components_meta', 'components_meta', 'Components_meta',
'_combine', 'template', '_combine', 'template',
'Blenvy_scene_type', 'blenvy_scene_type', 'Blenvy_scene_type', 'blenvy_scene_type',
'Materials_path', 'Export_path' 'materials_path', 'export_path',
] ]

View File

@ -58,9 +58,6 @@ def draw_settings_ui(layout, auto_export_settings):
# materials # materials
section.prop(auto_export_settings, "export_materials_library") section.prop(auto_export_settings, "export_materials_library")
section = section.box()
section.enabled = controls_enabled and auto_export_settings.export_materials_library
#section.prop(auto_export_settings, "materials_path")

View File

@ -2,6 +2,18 @@ import posixpath
import bpy import bpy
from pathlib import Path from pathlib import Path
from blenvy.assets.assets_scan import get_blueprint_asset_tree, get_level_scene_assets_tree2 from blenvy.assets.assets_scan import get_blueprint_asset_tree, get_level_scene_assets_tree2
from blenvy.add_ons.bevy_components.utils import is_component_valid_and_enabled
from .constants import custom_properties_to_filter_out
def remove_unwanted_custom_properties(object):
to_remove = []
component_names = list(object.keys()) # to avoid 'IDPropertyGroup changed size during iteration' issues
for component_name in component_names:
if not is_component_valid_and_enabled(object, component_name):
to_remove.append(component_name)
for cp in custom_properties_to_filter_out + to_remove:
if cp in object:
del object[cp]
def assets_to_fake_ron(list_like): def assets_to_fake_ron(list_like):
result = [] result = []

View File

@ -183,13 +183,6 @@ class BlenvyManager(PropertyGroup):
print("setting", setting, settings[setting]) print("setting", setting, settings[setting])
setattr(self, setting, settings[setting]) setattr(self, setting, settings[setting])
except:pass except:pass
"""if "mode" in settings:
self.mode = settings["mode"]
asset_path_names = ['project_root_path', 'assets_path', 'blueprints_path', 'levels_path', 'materials_path']
for asset_path_name in asset_path_names:
if asset_path_name in settings:
setattr(self, asset_path_name, settings[asset_path_name])"""
self.settings_save_enabled = True self.settings_save_enabled = True