diff --git a/TODO.md b/TODO.md index 833f3b0..998ab0c 100644 --- a/TODO.md +++ b/TODO.md @@ -222,7 +222,9 @@ Blender side: - [ ] materials fixes & upgrades - [x] materials do not get exported again if the files are missing, until you change a material - [x] materials do not get exported when a material is added ? + - [ ] if material library is toggled, then changes to materials should not change the blueprints that are using them ? - [ ] 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 - [ ] persist exported materials path in blueprints so that it can be read from library file users - [ ] just like "export_path" write it into each blueprint's collection - [ ] scan for used materials per blueprint ! diff --git a/tools/blenvy/add_ons/auto_export/materials/get_materials_to_export.py b/tools/blenvy/add_ons/auto_export/materials/get_materials_to_export.py index c973165..0a660c1 100644 --- a/tools/blenvy/add_ons/auto_export/materials/get_materials_to_export.py +++ b/tools/blenvy/add_ons/auto_export/materials/get_materials_to_export.py @@ -12,11 +12,9 @@ def get_materials_to_export(changes_per_material, changed_export_parameters, blu all_materials = bpy.data.materials local_materials = [material for material in all_materials if material.library is None] - #and (changed_export_parameters or len(changes_per_material.keys()) > 0 ) - materials_to_export = [] if change_detection and not changed_export_parameters: - changed_materials = [] + changed_materials = [bpy.data.materials[material_name] for material_name in list(changes_per_material.keys())] # first check if all materials have already been exported before (if this is the first time the exporter is run # in your current Blender session for example) @@ -27,5 +25,4 @@ def get_materials_to_export(changes_per_material, changed_export_parameters, blu materials_always_export = [] materials_to_export = list(set(changed_materials + materials_not_on_disk + materials_always_export)) - return materials_to_export diff --git a/tools/blenvy/materials/materials_helpers.py b/tools/blenvy/materials/materials_helpers.py index 79d7ecf..3d93b92 100644 --- a/tools/blenvy/materials/materials_helpers.py +++ b/tools/blenvy/materials/materials_helpers.py @@ -4,14 +4,24 @@ import bpy from pathlib import Path from ..core.helpers_collections import (traverse_tree) -def find_materials_not_on_disk(materials, folder_path, extension): +def find_materials_not_on_disk(materials, materials_path_full, extension): not_found_materials = [] + + current_project_name = Path(bpy.context.blend_data.filepath).stem + materials_library_name = f"{current_project_name}_materials" + materials_exported_path = os.path.join(materials_path_full, f"{materials_library_name}{extension}") + + found = os.path.exists(materials_exported_path) and os.path.isfile(materials_exported_path) for material in materials: - gltf_output_path = os.path.join(folder_path, material.name + extension) + if not found: + not_found_materials.append(material) + + """for material in materials: + gltf_output_path = os.path.join(materials_path_full, material.name + extension) # print("gltf_output_path", gltf_output_path) found = os.path.exists(gltf_output_path) and os.path.isfile(gltf_output_path) if not found: - not_found_materials.append(material) + not_found_materials.append(material)""" return not_found_materials def check_if_material_on_disk(scene_name, folder_path, extension):