From 6f5e7a394d708b2a8457c551248fe57183f9e1bd Mon Sep 17 00:00:00 2001 From: Yusarina Date: Fri, 1 Aug 2025 11:42:09 +0100 Subject: [PATCH 1/2] Updated Dictionary for #164 --- core/dictionaries.py | 272 +++++++++++++++++++++++++------------------ 1 file changed, 160 insertions(+), 112 deletions(-) diff --git a/core/dictionaries.py b/core/dictionaries.py index 8e11fdf..552e832 100644 --- a/core/dictionaries.py +++ b/core/dictionaries.py @@ -372,60 +372,62 @@ standard_bones = { 'head': 'Head', # Arms - 'left_arm': 'UpperArm.L', - 'left_elbow': 'LowerArm.L', - 'left_wrist': 'Hand.L', - 'right_arm': 'UpperArm.R', - 'right_elbow': 'LowerArm.R', - 'right_wrist': 'Hand.R', + 'left_shoulder': 'Shoulder_L', + 'left_arm': 'UpperArm_L', + 'left_elbow': 'LowerArm_L', + 'left_wrist': 'Hand_L', + 'right_shoulder': 'Shoulder_R', + 'right_arm': 'UpperArm_R', + 'right_elbow': 'LowerArm_R', + 'right_wrist': 'Hand_R', # Legs - 'left_leg': 'UpperLeg.L', - 'left_knee': 'LowerLeg.L', - 'left_ankle': 'Foot.L', - 'left_toe': 'Toes.L', - 'right_leg': 'UpperLeg.R', - 'right_knee': 'LowerLeg.R', - 'right_ankle': 'Foot.R', - 'right_toe': 'Toes.R', + 'left_leg': 'UpperLeg_L', + 'left_knee': 'LowerLeg_L', + 'left_ankle': 'Foot_L', + 'left_toe': 'Toe_L', + 'right_leg': 'UpperLeg_R', + 'right_knee': 'LowerLeg_R', + 'right_ankle': 'Foot_R', + 'right_toe': 'Toe_R', # Fingers Left - 'thumb_1_l': 'Thumb1.L', - 'thumb_2_l': 'Thumb2.L', - 'thumb_3_l': 'Thumb3.L', - 'index_1_l': 'Index1.L', - 'index_2_l': 'Index2.L', - 'index_3_l': 'Index3.L', - 'middle_1_l': 'Middle1.L', - 'middle_2_l': 'Middle2.L', - 'middle_3_l': 'Middle3.L', - 'ring_1_l': 'Ring1.L', - 'ring_2_l': 'Ring2.L', - 'ring_3_l': 'Ring3.L', - 'pinkie_1_l': 'Pinky1.L', - 'pinkie_2_l': 'Pinky2.L', - 'pinkie_3_l': 'Pinky3.L', + 'thumb_1_l': 'Thumb_L', + 'thumb_2_l': 'Thumb_L.001', + 'thumb_3_l': 'Thumb_L.002', + 'index_1_l': 'Index_L', + 'index_2_l': 'Index_L.001', + 'index_3_l': 'Index_L.002', + 'middle_1_l': 'Middle_L', + 'middle_2_l': 'Middle_L.001', + 'middle_3_l': 'Middle_L.002', + 'ring_1_l': 'Ring_L', + 'ring_2_l': 'Ring_L.001', + 'ring_3_l': 'Ring_L.002', + 'pinkie_1_l': 'Pinky_L', + 'pinkie_2_l': 'Pinky_L.001', + 'pinkie_3_l': 'Pinky_L.002', # Fingers Right - 'thumb_1_r': 'Thumb1.R', - 'thumb_2_r': 'Thumb2.R', - 'thumb_3_r': 'Thumb3.R', - 'index_1_r': 'Index1.R', - 'index_2_r': 'Index2.R', - 'index_3_r': 'Index3.R', - 'middle_1_r': 'Middle1.R', - 'middle_2_r': 'Middle2.R', - 'middle_3_r': 'Middle3.R', - 'ring_1_r': 'Ring1.R', - 'ring_2_r': 'Ring2.R', - 'ring_3_r': 'Ring3.R', - 'pinkie_1_r': 'Pinky1.R', - 'pinkie_2_r': 'Pinky2.R', - 'pinkie_3_r': 'Pinky3.R', + 'thumb_1_r': 'Thumb_R', + 'thumb_2_r': 'Thumb_R.001', + 'thumb_3_r': 'Thumb_R.002', + 'index_1_r': 'Index_R', + 'index_2_r': 'Index_R.001', + 'index_3_r': 'Index_R.002', + 'middle_1_r': 'Middle_R', + 'middle_2_r': 'Middle_R.001', + 'middle_3_r': 'Middle_R.002', + 'ring_1_r': 'Ring_R', + 'ring_2_r': 'Ring_R.001', + 'ring_3_r': 'Ring_R.002', + 'pinkie_1_r': 'Pinky_R', + 'pinkie_2_r': 'Pinky_R.001', + 'pinkie_3_r': 'Pinky_R.002', # Eyes - 'left_eye': 'Eye.L', - 'right_eye': 'Eye.R' + 'left_eye': 'Eye_L', + 'right_eye': 'Eye_R' } bone_hierarchy = [ @@ -434,46 +436,48 @@ bone_hierarchy = [ ('Chest', 'Chest.Up'), ('Chest.Up', 'Neck'), ('Neck', 'Head'), - ('Head', 'Eye.L'), - ('Head', 'Eye.R'), + ('Head', 'Eye_L'), + ('Head', 'Eye_R'), # Left Arm Chain - ('Chest.Up', 'UpperArm.L'), - ('UpperArm.L', 'LowerArm.L'), - ('LowerArm.L', 'Hand.L'), + ('Chest.Up', 'Shoulder_L'), + ('Shoulder_L', 'UpperArm_L'), + ('UpperArm_L', 'LowerArm_L'), + ('LowerArm_L', 'Hand_L'), # Right Arm Chain - ('Chest.Up', 'UpperArm.R'), - ('UpperArm.R', 'LowerArm.R'), - ('LowerArm.R', 'Hand.R'), + ('Chest.Up', 'Shoulder_R'), + ('Shoulder_R', 'UpperArm_R'), + ('UpperArm_R', 'LowerArm_R'), + ('LowerArm_R', 'Hand_R'), # Left Leg Chain - ('Hips', 'UpperLeg.L'), - ('UpperLeg.L', 'LowerLeg.L'), - ('LowerLeg.L', 'Foot.L'), - ('Foot.L', 'Toes.L'), + ('Hips', 'UpperLeg_L'), + ('UpperLeg_L', 'LowerLeg_L'), + ('LowerLeg_L', 'Foot_L'), + ('Foot_L', 'Toe_L'), # Right Leg Chain - ('Hips', 'UpperLeg.R'), - ('UpperLeg.R', 'LowerLeg.R'), - ('LowerLeg.R', 'Foot.R'), - ('Foot.R', 'Toes.R') + ('Hips', 'UpperLeg_R'), + ('UpperLeg_R', 'LowerLeg_R'), + ('LowerLeg_R', 'Foot_R'), + ('Foot_R', 'Toe_R') ] finger_hierarchy = { 'left': [ - ('Hand.L', 'Thumb1.L', 'Thumb2.L', 'Thumb3.L'), - ('Hand.L', 'Index1.L', 'Index2.L', 'Index3.L'), - ('Hand.L', 'Middle1.L', 'Middle2.L', 'Middle3.L'), - ('Hand.L', 'Ring1.L', 'Ring2.L', 'Ring3.L'), - ('Hand.L', 'Pinky1.L', 'Pinky2.L', 'Pinky3.L') + ('Hand_L', 'Thumb_L', 'Thumb_L.001', 'Thumb_L.002'), + ('Hand_L', 'Index_L', 'Index_L.001', 'Index_L.002'), + ('Hand_L', 'Middle_L', 'Middle_L.001', 'Middle_L.002'), + ('Hand_L', 'Ring_L', 'Ring_L.001', 'Ring_L.002'), + ('Hand_L', 'Pinky_L', 'Pinky_L.001', 'Pinky_L.002') ], 'right': [ - ('Hand.R', 'Thumb1.R', 'Thumb2.R', 'Thumb3.R'), - ('Hand.R', 'Index1.R', 'Index2.R', 'Index3.R'), - ('Hand.R', 'Middle1.R', 'Middle2.R', 'Middle3.R'), - ('Hand.R', 'Ring1.R', 'Ring2.R', 'Ring3.R'), - ('Hand.R', 'Pinky1.R', 'Pinky2.R', 'Pinky3.R') + ('Hand_R', 'Thumb_R', 'Thumb_R.001', 'Thumb_R.002'), + ('Hand_R', 'Index_R', 'Index_R.001', 'Index_R.002'), + ('Hand_R', 'Middle_R', 'Middle_R.001', 'Middle_R.002'), + ('Hand_R', 'Ring_R', 'Ring_R.001', 'Ring_R.002'), + ('Hand_R', 'Pinky_R', 'Pinky_R.001', 'Pinky_R.002') ] } @@ -506,6 +510,8 @@ acceptable_bone_hierarchy = [ ('Head', 'Eye_R'), ('Head', 'LeftEye'), ('Head', 'RightEye'), + ('Head', 'Eye.L'), + ('Head', 'Eye.R'), # Unity humanoid naming ('Hips', 'Spine'), @@ -516,6 +522,40 @@ acceptable_bone_hierarchy = [ ('Head', 'LeftEye'), ('Head', 'RightEye'), + # Old standard bone hierarchy patterns + ('Chest.Up', 'UpperArm.L'), + ('UpperArm.L', 'LowerArm.L'), + ('LowerArm.L', 'Hand.L'), + ('Chest.Up', 'UpperArm.R'), + ('UpperArm.R', 'LowerArm.R'), + ('LowerArm.R', 'Hand.R'), + ('Hips', 'UpperLeg.L'), + ('UpperLeg.L', 'LowerLeg.L'), + ('LowerLeg.L', 'Foot.L'), + ('Foot.L', 'Toes.L'), + ('Hips', 'UpperLeg.R'), + ('UpperLeg.R', 'LowerLeg.R'), + ('LowerLeg.R', 'Foot.R'), + ('Foot.R', 'Toes.R'), + + # New standard bone hierarchy patterns (with shoulders) + ('Chest.Up', 'Shoulder_L'), + ('Shoulder_L', 'UpperArm_L'), + ('UpperArm_L', 'LowerArm_L'), + ('LowerArm_L', 'Hand_L'), + ('Chest.Up', 'Shoulder_R'), + ('Shoulder_R', 'UpperArm_R'), + ('UpperArm_R', 'LowerArm_R'), + ('LowerArm_R', 'Hand_R'), + ('Hips', 'UpperLeg_L'), + ('UpperLeg_L', 'LowerLeg_L'), + ('LowerLeg_L', 'Foot_L'), + ('Foot_L', 'Toe_L'), + ('Hips', 'UpperLeg_R'), + ('UpperLeg_R', 'LowerLeg_R'), + ('LowerLeg_R', 'Foot_R'), + ('Foot_R', 'Toe_R'), + ] acceptable_bone_names = { @@ -523,54 +563,62 @@ acceptable_bone_names = { 'chest': ['Chest', 'spine1', 'Spine1', 'spine_01', 'SPINE1', 'Spine01'], 'neck': ['Neck', 'neck_01', 'Neck01'], 'head': ['Head', 'head_01', 'Head01'], - 'eye_l': ['Eye_L', 'LeftEye', 'lefteye', 'eye_left', 'EyeLeft'], - 'eye_r': ['Eye_R', 'RightEye', 'righteye', 'eye_right', 'EyeRight'], + 'eye_l': ['Eye_L', 'LeftEye', 'lefteye', 'eye_left', 'EyeLeft', 'Eye.L'], + 'eye_r': ['Eye_R', 'RightEye', 'righteye', 'eye_right', 'EyeRight', 'Eye.R'], - 'shoulder_r': ['Shoulder.R', 'clavicle_r', 'ClavicleRight', 'RightShoulder'], - 'arm_r': ['Arm.R', 'upperarm_r', 'UpperArmRight', 'RightArm'], - 'elbow_r': ['Elbow.R', 'lowerarm_r', 'ForearmRight', 'RightForeArm'], - 'wrist_r': ['Wrist.R', 'hand_r', 'HandRight', 'RightHand'], - 'leg_r': ['Leg.R', 'thigh_r', 'ThighRight', 'RightLeg', 'RightUpLeg'], - 'knee_r': ['Knee.R', 'calf_r', 'CalfRight', 'RightShin', 'RightLowerLeg'], - 'foot_r': ['Foot.R', 'foot_r', 'FootRight', 'RightFoot'], - 'toes_r': ['Toes.R', 'ball_r', 'ToeRight', 'RightToeBase'], + 'shoulder_r': ['Shoulder.R', 'clavicle_r', 'ClavicleRight', 'RightShoulder', 'Shoulder_R'], + 'arm_r': ['Arm.R', 'upperarm_r', 'UpperArmRight', 'RightArm', 'UpperArm.R', 'UpperArm_R'], + 'elbow_r': ['Elbow.R', 'lowerarm_r', 'ForearmRight', 'RightForeArm', 'LowerArm.R', 'LowerArm_R'], + 'wrist_r': ['Wrist.R', 'hand_r', 'HandRight', 'RightHand', 'Hand.R', 'Hand_R'], + 'leg_r': ['Leg.R', 'thigh_r', 'ThighRight', 'RightLeg', 'RightUpLeg', 'UpperLeg.R', 'UpperLeg_R'], + 'knee_r': ['Knee.R', 'calf_r', 'CalfRight', 'RightShin', 'RightLowerLeg', 'LowerLeg.R', 'LowerLeg_R'], + 'foot_r': ['Foot.R', 'foot_r', 'FootRight', 'RightFoot', 'Foot_R'], + 'toes_r': ['Toes.R', 'ball_r', 'ToeRight', 'RightToeBase', 'Toe_R'], - 'shoulder_l': ['Shoulder.L', 'clavicle_l', 'ClavicleLeft', 'LeftShoulder'], - 'arm_l': ['Arm.L', 'upperarm_l', 'UpperArmLeft', 'LeftArm'], - 'elbow_l': ['Elbow.L', 'lowerarm_l', 'ForearmLeft', 'LeftForeArm'], - 'wrist_l': ['Wrist.L', 'hand_l', 'HandLeft', 'LeftHand'], - 'leg_l': ['Leg.L', 'thigh_l', 'ThighLeft', 'LeftLeg', 'LeftUpLeg'], - 'knee_l': ['Knee.L', 'calf_l', 'CalfLeft', 'LeftShin', 'LeftLowerLeg'], - 'foot_l': ['Foot.L', 'foot_l', 'FootLeft', 'LeftFoot'], - 'toes_l': ['Toes.L', 'ball_l', 'ToeLeft', 'LeftToeBase'], + 'shoulder_l': ['Shoulder.L', 'clavicle_l', 'ClavicleLeft', 'LeftShoulder', 'Shoulder_L'], + 'arm_l': ['Arm.L', 'upperarm_l', 'UpperArmLeft', 'LeftArm', 'UpperArm.L', 'UpperArm_L'], + 'elbow_l': ['Elbow.L', 'lowerarm_l', 'ForearmLeft', 'LeftForeArm', 'LowerArm.L', 'LowerArm_L'], + 'wrist_l': ['Wrist.L', 'hand_l', 'HandLeft', 'LeftHand', 'Hand.L', 'Hand_L'], + 'leg_l': ['Leg.L', 'thigh_l', 'ThighLeft', 'LeftLeg', 'LeftUpLeg', 'UpperLeg.L', 'UpperLeg_L'], + 'knee_l': ['Knee.L', 'calf_l', 'CalfLeft', 'LeftShin', 'LeftLowerLeg', 'LowerLeg.L', 'LowerLeg_L'], + 'foot_l': ['Foot.L', 'foot_l', 'FootLeft', 'LeftFoot', 'Foot_L'], + 'toes_l': ['Toes.L', 'ball_l', 'ToeLeft', 'LeftToeBase', 'Toe_L'], # Add finger bones for left hand 'thumb_0_l': ['Thumb0_L'], - 'thumb_1_l': ['Thumb1_L'], - 'thumb_2_l': ['Thumb2_L'], - 'index_1_l': ['IndexFinger1_L'], - 'index_2_l': ['IndexFinger2_L'], - 'index_3_l': ['IndexFinger3_L'], - 'middle_1_l': ['MiddleFinger1_L'], - 'middle_2_l': ['MiddleFinger2_L'], - 'middle_3_l': ['MiddleFinger3_L'], - 'ring_1_l': ['RingFinger1_L'], - 'ring_2_l': ['RingFinger2_L'], - 'ring_3_l': ['RingFinger3_L'], + 'thumb_1_l': ['Thumb1_L', 'Thumb1.L', 'Thumb_L'], + 'thumb_2_l': ['Thumb2_L', 'Thumb2.L', 'Thumb_L.001'], + 'thumb_3_l': ['Thumb3.L', 'Thumb_L.002'], + 'index_1_l': ['IndexFinger1_L', 'Index1.L', 'Index_L'], + 'index_2_l': ['IndexFinger2_L', 'Index2.L', 'Index_L.001'], + 'index_3_l': ['IndexFinger3_L', 'Index3.L', 'Index_L.002'], + 'middle_1_l': ['MiddleFinger1_L', 'Middle1.L', 'Middle_L'], + 'middle_2_l': ['MiddleFinger2_L', 'Middle2.L', 'Middle_L.001'], + 'middle_3_l': ['MiddleFinger3_L', 'Middle3.L', 'Middle_L.002'], + 'ring_1_l': ['RingFinger1_L', 'Ring1.L', 'Ring_L'], + 'ring_2_l': ['RingFinger2_L', 'Ring2.L', 'Ring_L.001'], + 'ring_3_l': ['RingFinger3_L', 'Ring3.L', 'Ring_L.002'], + 'pinky_1_l': ['Pinky1.L', 'Pinky_L'], + 'pinky_2_l': ['Pinky2.L', 'Pinky_L.001'], + 'pinky_3_l': ['Pinky3.L', 'Pinky_L.002'], # Add finger bones for right hand 'thumb_0_r': ['Thumb0_R', 'ThumbO_R'], - 'thumb_1_r': ['Thumb1_R'], - 'thumb_2_r': ['Thumb2_R'], - 'index_1_r': ['IndexFinger1_R'], - 'index_2_r': ['IndexFinger2_R'], - 'index_3_r': ['IndexFinger3_R'], - 'middle_1_r': ['MiddleFinger1_R'], - 'middle_2_r': ['MiddleFinger2_R'], - 'middle_3_r': ['MiddleFinger3_R'], - 'ring_1_r': ['RingFinger1_R'], - 'ring_2_r': ['RingFinger2_R'], - 'ring_3_r': ['RingFinger3_R'], + 'thumb_1_r': ['Thumb1_R', 'Thumb1.R', 'Thumb_R'], + 'thumb_2_r': ['Thumb2_R', 'Thumb2.R', 'Thumb_R.001'], + 'thumb_3_r': ['Thumb3.R', 'Thumb_R.002'], + 'index_1_r': ['IndexFinger1_R', 'Index1.R', 'Index_R'], + 'index_2_r': ['IndexFinger2_R', 'Index2.R', 'Index_R.001'], + 'index_3_r': ['IndexFinger3_R', 'Index3.R', 'Index_R.002'], + 'middle_1_r': ['MiddleFinger1_R', 'Middle1.R', 'Middle_R'], + 'middle_2_r': ['MiddleFinger2_R', 'Middle2.R', 'Middle_R.001'], + 'middle_3_r': ['MiddleFinger3_R', 'Middle3.R', 'Middle_R.002'], + 'ring_1_r': ['RingFinger1_R', 'Ring1.R', 'Ring_R'], + 'ring_2_r': ['RingFinger2_R', 'Ring2.R', 'Ring_R.001'], + 'ring_3_r': ['RingFinger3_R', 'Ring3.R', 'Ring_R.002'], + 'pinky_1_r': ['Pinky1.R', 'Pinky_R'], + 'pinky_2_r': ['Pinky2.R', 'Pinky_R.001'], + 'pinky_3_r': ['Pinky3.R', 'Pinky_R.002'], 'breast_upper_1_l': ['BreastUpper1_L'], 'breast_upper_2_l': ['BreastUpper2_L'], From 8c2c52f882e6e7f722fca09ec20bc935206fa34b Mon Sep 17 00:00:00 2001 From: Yusarina Date: Fri, 1 Aug 2025 12:01:22 +0100 Subject: [PATCH 2/2] Fixed issue where some bones was not being renamed --- core/dictionaries.py | 32 +++++++++---------- functions/tools/standardize_armature.py | 41 ++++++++++--------------- 2 files changed, 33 insertions(+), 40 deletions(-) diff --git a/core/dictionaries.py b/core/dictionaries.py index 552e832..e065c14 100644 --- a/core/dictionaries.py +++ b/core/dictionaries.py @@ -743,17 +743,17 @@ non_standard_mappings = { 'left_arm': [ 'mixamorig:LeftArm', 'mixamorig_LeftArm', 'ORG-upper_arm.L', 'upper_arm.L', - 'lShldrBend', 'lShldrTwist', 'lArm' + 'lShldrBend', 'lShldrTwist', 'lArm', 'UpperArm.L' ], 'left_elbow': [ 'mixamorig:LeftForeArm', 'mixamorig_LeftForeArm', 'ORG-forearm.L', 'forearm.L', - 'lForearmBend', 'lElbow', 'lForeArm' + 'lForearmBend', 'lElbow', 'lForeArm', 'LowerArm.L' ], 'left_wrist': [ 'mixamorig:LeftHand', 'mixamorig_LeftHand', 'ORG-hand.L', 'hand.L', - 'lHand', 'lWrist' + 'lHand', 'lWrist', 'Hand.L' ], 'right_shoulder': [ @@ -764,59 +764,59 @@ non_standard_mappings = { 'right_arm': [ 'mixamorig:RightArm', 'mixamorig_RightArm', 'ORG-upper_arm.R', 'upper_arm.R', - 'rShldrBend', 'rShldrTwist', 'rArm' + 'rShldrBend', 'rShldrTwist', 'rArm', 'UpperArm.R' ], 'right_elbow': [ 'mixamorig:RightForeArm', 'mixamorig_RightForeArm', 'ORG-forearm.R', 'forearm.R', - 'rForearmBend', 'rElbow', 'rForeArm' + 'rForearmBend', 'rElbow', 'rForeArm', 'LowerArm.R' ], 'right_wrist': [ 'mixamorig:RightHand', 'mixamorig_RightHand', 'ORG-hand.R', 'hand.R', - 'rHand', 'rWrist' + 'rHand', 'rWrist', 'Hand.R' ], 'left_leg': [ 'mixamorig:LeftUpLeg', 'mixamorig_LeftUpLeg', 'ORG-thigh.L', 'thigh.L', - 'lThighBend', 'lThigh' + 'lThighBend', 'lThigh', 'UpperLeg.L' ], 'left_knee': [ 'mixamorig:LeftLeg', 'mixamorig_LeftLeg', 'ORG-shin.L', 'shin.L', - 'lShin', 'lKnee', 'lLeg' + 'lShin', 'lKnee', 'lLeg', 'LowerLeg.L' ], 'left_ankle': [ 'mixamorig:LeftFoot', 'mixamorig_LeftFoot', 'ORG-foot.L', 'foot.L', - 'lFoot', 'lAnkle' + 'lFoot', 'lAnkle', 'Foot.L' ], 'left_toe': [ 'mixamorig:LeftToeBase', 'mixamorig_LeftToeBase', 'ORG-toe.L', 'toe.L', - 'lToe' + 'lToe', 'Toes.L' ], 'right_leg': [ 'mixamorig:RightUpLeg', 'mixamorig_RightUpLeg', 'ORG-thigh.R', 'thigh.R', - 'rThighBend', 'rThigh' + 'rThighBend', 'rThigh', 'UpperLeg.R' ], 'right_knee': [ 'mixamorig:RightLeg', 'mixamorig_RightLeg', 'ORG-shin.R', 'shin.R', - 'rShin', 'rKnee', 'rLeg' + 'rShin', 'rKnee', 'rLeg', 'LowerLeg.R' ], 'right_ankle': [ 'mixamorig:RightFoot', 'mixamorig_RightFoot', 'ORG-foot.R', 'foot.R', - 'rFoot', 'rAnkle' + 'rFoot', 'rAnkle', 'Foot.R' ], 'right_toe': [ 'mixamorig:RightToeBase', 'mixamorig_RightToeBase', 'ORG-toe.R', 'toe.R', - 'rToe' + 'rToe', 'Toes.R' ], 'thumb_1_l': [ @@ -982,12 +982,12 @@ non_standard_mappings = { 'left_eye': [ 'mixamorig:LeftEye', 'mixamorig_LeftEye', 'ORG-eye.L', 'eye.L', - 'lEye' + 'lEye', 'Eye.L' ], 'right_eye': [ 'mixamorig:RightEye', 'mixamorig_RightEye', 'ORG-eye.R', 'eye.R', - 'rEye' + 'rEye', 'Eye.R' ] } diff --git a/functions/tools/standardize_armature.py b/functions/tools/standardize_armature.py index e88558d..7d5fdcf 100644 --- a/functions/tools/standardize_armature.py +++ b/functions/tools/standardize_armature.py @@ -13,7 +13,9 @@ from ...core.dictionaries import ( bone_hierarchy, acceptable_bone_names, acceptable_bone_hierarchy, - non_standard_mappings + non_standard_mappings, + reverse_bone_lookup, + simplify_bonename ) class AvatarToolkit_OT_StandardizeArmature(Operator): @@ -134,17 +136,14 @@ class AvatarToolkit_OT_StandardizeArmature(Operator): existing_standard_bones.add(bone.name) logger.debug(f"Found existing standard bone: {bone.name}") - # Build a mapping of non-standard bone names to standard names + # Use the reverse bone lookup that's already built and simplified name_mapping: Dict[str, str] = {} - for category, standard_name in standard_bones.items(): - # Skip if this standard bone already exists - if standard_name in existing_standard_bones: - continue - - # Get all variants for this category - if category in non_standard_mappings: - for variant in non_standard_mappings[category]: - name_mapping[variant.lower()] = standard_name + for simplified_name, category in reverse_bone_lookup.items(): + if category in standard_bones: + standard_name = standard_bones[category] + # Skip if this standard bone already exists + if standard_name not in existing_standard_bones: + name_mapping[simplified_name] = standard_name # First pass: identify bones to rename bones_to_rename: Dict[str, str] = {} @@ -155,20 +154,14 @@ class AvatarToolkit_OT_StandardizeArmature(Operator): if original_name in standard_bones.values(): continue - simplified_name: str = original_name.lower().replace(' ', '').replace('_', '').replace('.', '') + simplified_name: str = simplify_bonename(original_name) - # Check if this bone matches any known pattern - for variant, standard_name in name_mapping.items(): - # More precise matching - exact match or with common separators - if (variant == simplified_name or - variant == original_name.lower() or - f"{variant}_" in simplified_name or - f"{variant}." in simplified_name): - - if original_name != standard_name: - bones_to_rename[original_name] = standard_name - logger.debug(f"Identified bone to rename: {original_name} -> {standard_name}") - break + # Check if this simplified bone name has a standard mapping + if simplified_name in name_mapping: + standard_name = name_mapping[simplified_name] + if original_name != standard_name: + bones_to_rename[original_name] = standard_name + logger.debug(f"Identified bone to rename: {original_name} -> {standard_name}") # Special case for spine/chest hierarchy # If we don't have an upper chest, don't rename chest to upper chest because it will break hierarchy