PSA Export:

* Actions with no f-curve data will not be automatically selected for export

PSK Export:
* Now enforcing a rule that the mesh's armature modifier must be the last in the stack (if it isn't, mesh skinning will be absent in resultant PSK)
* Fixed a crash that would occur when attempting to attempt to export a mesh with an empty material slot
This commit is contained in:
Colin Basnett
2020-04-12 20:26:55 -07:00
parent 584da89c82
commit c531256e92
3 changed files with 38 additions and 1 deletions

View File

@@ -56,8 +56,9 @@ class PsaExportOperator(Operator, ExportHelper):
row.template_list('PSA_UL_ActionList', 'asd', scene, 'psa_action_list', scene, 'psa_action_list_index', rows=len(context.scene.psa_action_list)) row.template_list('PSA_UL_ActionList', 'asd', scene, 'psa_action_list', scene, 'psa_action_list_index', rows=len(context.scene.psa_action_list))
def is_action_for_armature(self, action): def is_action_for_armature(self, action):
if len(action.fcurves) == 0:
return False
bone_names = [x.name for x in self.armature.data.bones] bone_names = [x.name for x in self.armature.data.bones]
print(bone_names)
for fcurve in action.fcurves: for fcurve in action.fcurves:
match = re.match('pose\.bones\["(.+)"\].\w+', fcurve.data_path) match = re.match('pose\.bones\["(.+)"\].\w+', fcurve.data_path)
if not match: if not match:

View File

@@ -26,6 +26,9 @@ class PskBuilder(object):
armature_modifier = modifiers[0] armature_modifier = modifiers[0]
armature_object = armature_modifier.object armature_object = armature_modifier.object
if object.modifiers[-1] != armature_modifier:
raise RuntimeError('Armature modifier must be the last modifier in the stack')
if armature_object is None: if armature_object is None:
raise RuntimeError('Armature modifier has no linked object') raise RuntimeError('Armature modifier has no linked object')
@@ -97,6 +100,7 @@ class PskBuilder(object):
psk.wedges[f.loops[i]].material_index = f.material_index psk.wedges[f.loops[i]].material_index = f.material_index
# https://github.com/bwrsandman/blender-addons/blob/master/io_export_unreal_psk_psa.py # https://github.com/bwrsandman/blender-addons/blob/master/io_export_unreal_psk_psa.py
# TODO: maybe we should use the EDIT bones instead???
bones = list(armature_object.data.bones) bones = list(armature_object.data.bones)
for bone in bones: for bone in bones:
psk_bone = Psk.Bone() psk_bone = Psk.Bone()

View File

@@ -18,6 +18,38 @@ class PskExportOperator(Operator, ExportHelper):
maxlen=1024, maxlen=1024,
default='') default='')
def invoke(self, context, event):
object = context.view_layer.objects.active
if object.type != 'MESH':
self.report({'ERROR_INVALID_CONTEXT'}, 'The selected object must be a mesh.')
return {'CANCELLED'}
if len(object.data.materials) == 0:
self.report({'ERROR_INVALID_CONTEXT'}, 'Mesh must have at least one material')
return {'CANCELLED'}
# ensure that there is exactly one armature modifier
modifiers = [x for x in object.modifiers if x.type == 'ARMATURE']
if len(modifiers) != 1:
self.report({'ERROR_INVALID_CONTEXT'}, 'Mesh must have one armature modifier')
return {'CANCELLED'}
armature_modifier = modifiers[0]
armature_object = armature_modifier.object
if object.modifiers[-1] != armature_modifier:
self.report({'ERROR_INVALID_CONTEXT'}, 'Armature modifier must be the last modifier in the stack')
return {'CANCELLED'}
if armature_object is None:
self.report({'ERROR_INVALID_CONTEXT'}, 'Armature modifier has no linked object')
return {'CANCELLED'}
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
def execute(self, context): def execute(self, context):
builder = PskBuilder() builder = PskBuilder()
psk = builder.build(context) psk = builder.build(context)