Skip to content

Commit

Permalink
Merge pull request #84 from ILoveAGoodCrisp/master
Browse files Browse the repository at this point in the history
Ignore node prefixes when getting pose bones during JMA imports
  • Loading branch information
Steven Garcia authored Feb 17, 2024
2 parents c05c893 + d4367f6 commit ab15f61
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion io_scene_halo/file_jma/build_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ def find_valid_armature(context, JMA, obj):

return scene_nodes, valid_armature

def get_pose_bone(arm: bpy.types.Object, node_name: str) -> bpy.types.PoseBone | None:
# Check for exact matches first
for bone in arm.pose.bones:
if bone.name.lower() == node_name.lower():
return bone

# If a bone hasn't been found yet, test whether the node name matches a bone name stripped of prefixes
for bone in arm.pose.bones:
if remove_node_prefix(bone.name).lower() == node_name.lower():
return bone

def build_scene(context, JMA, JMS_A, JMS_B, filepath, game_version, fix_parents, fix_rotations, report):
collection = context.collection
scene = context.scene
Expand Down Expand Up @@ -399,7 +410,7 @@ def build_scene(context, JMA, JMS_A, JMS_B, filepath, game_version, fix_parents,
armature.keyframe_insert('rotation_euler')

for idx, node in enumerate(nodes):
pose_bone = armature.pose.bones.get(node.name)
pose_bone = get_pose_bone(armature, node.name)
if not pose_bone == None:
matrix_scale = Matrix.Scale(frame[idx].scale, 4)
matrix_rotation = frame[idx].rotation.to_matrix().to_4x4()
Expand Down

0 comments on commit ab15f61

Please sign in to comment.