Fixed a bug where exported PSKs would always use the mesh data's material instead of the object's material

This commit is contained in:
Colin Basnett
2023-08-18 18:22:16 -07:00
parent 8c74987f5b
commit 560ec8fecd
2 changed files with 4 additions and 3 deletions

View File

@@ -143,7 +143,7 @@ def build_psk(context, options: PskBuildOptions) -> Psk:
for input_mesh_object in input_objects.mesh_objects: for input_mesh_object in input_objects.mesh_objects:
# MATERIALS # MATERIALS
material_indices = [material_names.index(material.name) for material in input_mesh_object.data.materials] material_indices = [material_names.index(material_slot.material.name) for material_slot in input_mesh_object.material_slots]
# MESH DATA # MESH DATA
if options.use_raw_mesh_data: if options.use_raw_mesh_data:

View File

@@ -22,10 +22,11 @@ def populate_material_list(mesh_objects, material_list):
material_names = [] material_names = []
for mesh_object in mesh_objects: for mesh_object in mesh_objects:
for i, material in enumerate(mesh_object.data.materials): for i, material_slot in enumerate(mesh_object.material_slots):
material = material_slot.material
# TODO: put this in the poll arg? # TODO: put this in the poll arg?
if material is None: if material is None:
raise RuntimeError('Material cannot be empty (index ' + str(i) + ')') raise RuntimeError('Material slot cannot be empty (index ' + str(i) + ')')
if material.name not in material_names: if material.name not in material_names:
material_names.append(material.name) material_names.append(material.name)