Fixed issue where some bones was not being renamed
This commit is contained in:
+16
-16
@@ -743,17 +743,17 @@ non_standard_mappings = {
|
|||||||
'left_arm': [
|
'left_arm': [
|
||||||
'mixamorig:LeftArm', 'mixamorig_LeftArm',
|
'mixamorig:LeftArm', 'mixamorig_LeftArm',
|
||||||
'ORG-upper_arm.L', 'upper_arm.L',
|
'ORG-upper_arm.L', 'upper_arm.L',
|
||||||
'lShldrBend', 'lShldrTwist', 'lArm'
|
'lShldrBend', 'lShldrTwist', 'lArm', 'UpperArm.L'
|
||||||
],
|
],
|
||||||
'left_elbow': [
|
'left_elbow': [
|
||||||
'mixamorig:LeftForeArm', 'mixamorig_LeftForeArm',
|
'mixamorig:LeftForeArm', 'mixamorig_LeftForeArm',
|
||||||
'ORG-forearm.L', 'forearm.L',
|
'ORG-forearm.L', 'forearm.L',
|
||||||
'lForearmBend', 'lElbow', 'lForeArm'
|
'lForearmBend', 'lElbow', 'lForeArm', 'LowerArm.L'
|
||||||
],
|
],
|
||||||
'left_wrist': [
|
'left_wrist': [
|
||||||
'mixamorig:LeftHand', 'mixamorig_LeftHand',
|
'mixamorig:LeftHand', 'mixamorig_LeftHand',
|
||||||
'ORG-hand.L', 'hand.L',
|
'ORG-hand.L', 'hand.L',
|
||||||
'lHand', 'lWrist'
|
'lHand', 'lWrist', 'Hand.L'
|
||||||
],
|
],
|
||||||
|
|
||||||
'right_shoulder': [
|
'right_shoulder': [
|
||||||
@@ -764,59 +764,59 @@ non_standard_mappings = {
|
|||||||
'right_arm': [
|
'right_arm': [
|
||||||
'mixamorig:RightArm', 'mixamorig_RightArm',
|
'mixamorig:RightArm', 'mixamorig_RightArm',
|
||||||
'ORG-upper_arm.R', 'upper_arm.R',
|
'ORG-upper_arm.R', 'upper_arm.R',
|
||||||
'rShldrBend', 'rShldrTwist', 'rArm'
|
'rShldrBend', 'rShldrTwist', 'rArm', 'UpperArm.R'
|
||||||
],
|
],
|
||||||
'right_elbow': [
|
'right_elbow': [
|
||||||
'mixamorig:RightForeArm', 'mixamorig_RightForeArm',
|
'mixamorig:RightForeArm', 'mixamorig_RightForeArm',
|
||||||
'ORG-forearm.R', 'forearm.R',
|
'ORG-forearm.R', 'forearm.R',
|
||||||
'rForearmBend', 'rElbow', 'rForeArm'
|
'rForearmBend', 'rElbow', 'rForeArm', 'LowerArm.R'
|
||||||
],
|
],
|
||||||
'right_wrist': [
|
'right_wrist': [
|
||||||
'mixamorig:RightHand', 'mixamorig_RightHand',
|
'mixamorig:RightHand', 'mixamorig_RightHand',
|
||||||
'ORG-hand.R', 'hand.R',
|
'ORG-hand.R', 'hand.R',
|
||||||
'rHand', 'rWrist'
|
'rHand', 'rWrist', 'Hand.R'
|
||||||
],
|
],
|
||||||
|
|
||||||
'left_leg': [
|
'left_leg': [
|
||||||
'mixamorig:LeftUpLeg', 'mixamorig_LeftUpLeg',
|
'mixamorig:LeftUpLeg', 'mixamorig_LeftUpLeg',
|
||||||
'ORG-thigh.L', 'thigh.L',
|
'ORG-thigh.L', 'thigh.L',
|
||||||
'lThighBend', 'lThigh'
|
'lThighBend', 'lThigh', 'UpperLeg.L'
|
||||||
],
|
],
|
||||||
'left_knee': [
|
'left_knee': [
|
||||||
'mixamorig:LeftLeg', 'mixamorig_LeftLeg',
|
'mixamorig:LeftLeg', 'mixamorig_LeftLeg',
|
||||||
'ORG-shin.L', 'shin.L',
|
'ORG-shin.L', 'shin.L',
|
||||||
'lShin', 'lKnee', 'lLeg'
|
'lShin', 'lKnee', 'lLeg', 'LowerLeg.L'
|
||||||
],
|
],
|
||||||
'left_ankle': [
|
'left_ankle': [
|
||||||
'mixamorig:LeftFoot', 'mixamorig_LeftFoot',
|
'mixamorig:LeftFoot', 'mixamorig_LeftFoot',
|
||||||
'ORG-foot.L', 'foot.L',
|
'ORG-foot.L', 'foot.L',
|
||||||
'lFoot', 'lAnkle'
|
'lFoot', 'lAnkle', 'Foot.L'
|
||||||
],
|
],
|
||||||
'left_toe': [
|
'left_toe': [
|
||||||
'mixamorig:LeftToeBase', 'mixamorig_LeftToeBase',
|
'mixamorig:LeftToeBase', 'mixamorig_LeftToeBase',
|
||||||
'ORG-toe.L', 'toe.L',
|
'ORG-toe.L', 'toe.L',
|
||||||
'lToe'
|
'lToe', 'Toes.L'
|
||||||
],
|
],
|
||||||
|
|
||||||
'right_leg': [
|
'right_leg': [
|
||||||
'mixamorig:RightUpLeg', 'mixamorig_RightUpLeg',
|
'mixamorig:RightUpLeg', 'mixamorig_RightUpLeg',
|
||||||
'ORG-thigh.R', 'thigh.R',
|
'ORG-thigh.R', 'thigh.R',
|
||||||
'rThighBend', 'rThigh'
|
'rThighBend', 'rThigh', 'UpperLeg.R'
|
||||||
],
|
],
|
||||||
'right_knee': [
|
'right_knee': [
|
||||||
'mixamorig:RightLeg', 'mixamorig_RightLeg',
|
'mixamorig:RightLeg', 'mixamorig_RightLeg',
|
||||||
'ORG-shin.R', 'shin.R',
|
'ORG-shin.R', 'shin.R',
|
||||||
'rShin', 'rKnee', 'rLeg'
|
'rShin', 'rKnee', 'rLeg', 'LowerLeg.R'
|
||||||
],
|
],
|
||||||
'right_ankle': [
|
'right_ankle': [
|
||||||
'mixamorig:RightFoot', 'mixamorig_RightFoot',
|
'mixamorig:RightFoot', 'mixamorig_RightFoot',
|
||||||
'ORG-foot.R', 'foot.R',
|
'ORG-foot.R', 'foot.R',
|
||||||
'rFoot', 'rAnkle'
|
'rFoot', 'rAnkle', 'Foot.R'
|
||||||
],
|
],
|
||||||
'right_toe': [
|
'right_toe': [
|
||||||
'mixamorig:RightToeBase', 'mixamorig_RightToeBase',
|
'mixamorig:RightToeBase', 'mixamorig_RightToeBase',
|
||||||
'ORG-toe.R', 'toe.R',
|
'ORG-toe.R', 'toe.R',
|
||||||
'rToe'
|
'rToe', 'Toes.R'
|
||||||
],
|
],
|
||||||
|
|
||||||
'thumb_1_l': [
|
'thumb_1_l': [
|
||||||
@@ -982,12 +982,12 @@ non_standard_mappings = {
|
|||||||
'left_eye': [
|
'left_eye': [
|
||||||
'mixamorig:LeftEye', 'mixamorig_LeftEye',
|
'mixamorig:LeftEye', 'mixamorig_LeftEye',
|
||||||
'ORG-eye.L', 'eye.L',
|
'ORG-eye.L', 'eye.L',
|
||||||
'lEye'
|
'lEye', 'Eye.L'
|
||||||
],
|
],
|
||||||
'right_eye': [
|
'right_eye': [
|
||||||
'mixamorig:RightEye', 'mixamorig_RightEye',
|
'mixamorig:RightEye', 'mixamorig_RightEye',
|
||||||
'ORG-eye.R', 'eye.R',
|
'ORG-eye.R', 'eye.R',
|
||||||
'rEye'
|
'rEye', 'Eye.R'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ from ...core.dictionaries import (
|
|||||||
bone_hierarchy,
|
bone_hierarchy,
|
||||||
acceptable_bone_names,
|
acceptable_bone_names,
|
||||||
acceptable_bone_hierarchy,
|
acceptable_bone_hierarchy,
|
||||||
non_standard_mappings
|
non_standard_mappings,
|
||||||
|
reverse_bone_lookup,
|
||||||
|
simplify_bonename
|
||||||
)
|
)
|
||||||
|
|
||||||
class AvatarToolkit_OT_StandardizeArmature(Operator):
|
class AvatarToolkit_OT_StandardizeArmature(Operator):
|
||||||
@@ -134,17 +136,14 @@ class AvatarToolkit_OT_StandardizeArmature(Operator):
|
|||||||
existing_standard_bones.add(bone.name)
|
existing_standard_bones.add(bone.name)
|
||||||
logger.debug(f"Found existing standard bone: {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] = {}
|
name_mapping: Dict[str, str] = {}
|
||||||
for category, standard_name in standard_bones.items():
|
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
|
# Skip if this standard bone already exists
|
||||||
if standard_name in existing_standard_bones:
|
if standard_name not in existing_standard_bones:
|
||||||
continue
|
name_mapping[simplified_name] = standard_name
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# First pass: identify bones to rename
|
# First pass: identify bones to rename
|
||||||
bones_to_rename: Dict[str, str] = {}
|
bones_to_rename: Dict[str, str] = {}
|
||||||
@@ -155,20 +154,14 @@ class AvatarToolkit_OT_StandardizeArmature(Operator):
|
|||||||
if original_name in standard_bones.values():
|
if original_name in standard_bones.values():
|
||||||
continue
|
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):
|
|
||||||
|
|
||||||
|
# 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:
|
if original_name != standard_name:
|
||||||
bones_to_rename[original_name] = standard_name
|
bones_to_rename[original_name] = standard_name
|
||||||
logger.debug(f"Identified bone to rename: {original_name} -> {standard_name}")
|
logger.debug(f"Identified bone to rename: {original_name} -> {standard_name}")
|
||||||
break
|
|
||||||
|
|
||||||
# Special case for spine/chest hierarchy
|
# 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
|
# If we don't have an upper chest, don't rename chest to upper chest because it will break hierarchy
|
||||||
|
|||||||
Reference in New Issue
Block a user