Merge branch 'feature-nla-track-sequence-5x' into blender-4.0
# Conflicts: # io_scene_psk_psa/__init__.py # io_scene_psk_psa/psa/export/operators.py
This commit is contained in:
@@ -88,7 +88,11 @@ def build_psk(context, options: PskBuildOptions) -> Psk:
|
||||
|
||||
for bone in bones:
|
||||
psk_bone = Psk.Bone()
|
||||
psk_bone.name = bytes(bone.name, encoding='windows-1252')
|
||||
try:
|
||||
psk_bone.name = bytes(bone.name, encoding='windows-1252')
|
||||
except UnicodeEncodeError:
|
||||
raise RuntimeError(
|
||||
f'Bone name "{bone.name}" contains characters that cannot be encoded in the Windows-1252 codepage')
|
||||
psk_bone.flags = 0
|
||||
psk_bone.children_count = 0
|
||||
|
||||
@@ -129,14 +133,17 @@ def build_psk(context, options: PskBuildOptions) -> Psk:
|
||||
|
||||
for material_name in material_names:
|
||||
psk_material = Psk.Material()
|
||||
psk_material.name = bytes(material_name, encoding='windows-1252')
|
||||
try:
|
||||
psk_material.name = bytes(material_name, encoding='windows-1252')
|
||||
except UnicodeEncodeError:
|
||||
raise RuntimeError(f'Material name "{material_name}" contains characters that cannot be encoded in the Windows-1252 codepage')
|
||||
psk_material.texture_index = len(psk.materials)
|
||||
psk.materials.append(psk_material)
|
||||
|
||||
for input_mesh_object in input_objects.mesh_objects:
|
||||
|
||||
# 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
|
||||
if options.use_raw_mesh_data:
|
||||
|
||||
@@ -22,10 +22,11 @@ def populate_material_list(mesh_objects, material_list):
|
||||
|
||||
material_names = []
|
||||
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?
|
||||
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:
|
||||
material_names.append(material.name)
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ def import_psk(psk: Psk, context, options: PskImportOptions) -> PskImportResult:
|
||||
# Material already exists, just re-use it.
|
||||
material = bpy.data.materials[material_name]
|
||||
elif is_bdk_addon_loaded() and psk.has_material_references:
|
||||
# Material does not yet exist and we have the BDK addon installed.
|
||||
# Material does not yet exist, and we have the BDK addon installed.
|
||||
# Attempt to load it using BDK addon's operator.
|
||||
material_reference = psk.material_references[material_index]
|
||||
if material_reference and bpy.ops.bdk.link_material(reference=material_reference) == {'FINISHED'}:
|
||||
|
||||
Reference in New Issue
Block a user