get_unique_materials now preserves the order that the materials were encountered
This commit is contained in:
@@ -52,14 +52,15 @@ class ASE_PG_export(PropertyGroup):
|
|||||||
|
|
||||||
|
|
||||||
def get_unique_materials(mesh_objects: Iterable[Object]) -> List[Material]:
|
def get_unique_materials(mesh_objects: Iterable[Object]) -> List[Material]:
|
||||||
materials = set()
|
materials = []
|
||||||
for mesh_object in mesh_objects:
|
for mesh_object in mesh_objects:
|
||||||
for i, material_slot in enumerate(mesh_object.material_slots):
|
for i, material_slot in enumerate(mesh_object.material_slots):
|
||||||
material = material_slot.material
|
material = material_slot.material
|
||||||
if material is None:
|
if material is None:
|
||||||
raise RuntimeError(f'Material slots cannot be empty ({mesh_object.name}, material slot index {i})')
|
raise RuntimeError(f'Material slots cannot be empty ({mesh_object.name}, material slot index {i})')
|
||||||
materials.add(material)
|
if material not in materials:
|
||||||
return list(materials)
|
materials.append(material)
|
||||||
|
return materials
|
||||||
|
|
||||||
|
|
||||||
def populate_material_list(mesh_objects: Iterable[Object], material_list):
|
def populate_material_list(mesh_objects: Iterable[Object], material_list):
|
||||||
|
|||||||
Reference in New Issue
Block a user