fix(Blenvy:Blender): fixes & tweaks to materials export
* fixed missing internals * fixed/changed logic of finding existing material files * minor related fixes * likely last set of fixes with current materials system before switching to one material file per material
This commit is contained in:
parent
4a72ed68bf
commit
4586273e37
2
TODO.md
2
TODO.md
|
@ -222,7 +222,9 @@ Blender side:
|
||||||
- [ ] materials fixes & upgrades
|
- [ ] 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 again if the files are missing, until you change a material
|
||||||
- [x] materials do not get exported when a material is added ?
|
- [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
|
- [ ] 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
|
- [ ] 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
|
- [ ] just like "export_path" write it into each blueprint's collection
|
||||||
- [ ] scan for used materials per blueprint !
|
- [ ] scan for used materials per blueprint !
|
||||||
|
|
|
@ -12,11 +12,9 @@ def get_materials_to_export(changes_per_material, changed_export_parameters, blu
|
||||||
|
|
||||||
all_materials = bpy.data.materials
|
all_materials = bpy.data.materials
|
||||||
local_materials = [material for material in all_materials if material.library is None]
|
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 = []
|
materials_to_export = []
|
||||||
if change_detection and not changed_export_parameters:
|
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
|
# 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)
|
# 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_always_export = []
|
||||||
materials_to_export = list(set(changed_materials + materials_not_on_disk + materials_always_export))
|
materials_to_export = list(set(changed_materials + materials_not_on_disk + materials_always_export))
|
||||||
|
|
||||||
|
|
||||||
return materials_to_export
|
return materials_to_export
|
||||||
|
|
|
@ -4,14 +4,24 @@ import bpy
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from ..core.helpers_collections import (traverse_tree)
|
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 = []
|
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:
|
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)
|
# print("gltf_output_path", gltf_output_path)
|
||||||
found = os.path.exists(gltf_output_path) and os.path.isfile(gltf_output_path)
|
found = os.path.exists(gltf_output_path) and os.path.isfile(gltf_output_path)
|
||||||
if not found:
|
if not found:
|
||||||
not_found_materials.append(material)
|
not_found_materials.append(material)"""
|
||||||
return not_found_materials
|
return not_found_materials
|
||||||
|
|
||||||
def check_if_material_on_disk(scene_name, folder_path, extension):
|
def check_if_material_on_disk(scene_name, folder_path, extension):
|
||||||
|
|
Loading…
Reference in New Issue