Merge pull request #171 from Yusarina/Current
Fixed case senstive issue and added temp solution for accessories
This commit is contained in:
+60
-20
@@ -10,7 +10,8 @@ from ..core.dictionaries import (
|
|||||||
bone_hierarchy,
|
bone_hierarchy,
|
||||||
finger_hierarchy,
|
finger_hierarchy,
|
||||||
acceptable_bone_hierarchy,
|
acceptable_bone_hierarchy,
|
||||||
acceptable_bone_names
|
acceptable_bone_names,
|
||||||
|
simplify_bonename
|
||||||
)
|
)
|
||||||
from ..core.logging_setup import logger
|
from ..core.logging_setup import logger
|
||||||
|
|
||||||
@@ -104,17 +105,41 @@ def validate_armature(armature: Object, detailed_messages: bool = False) -> Unio
|
|||||||
|
|
||||||
# Non-standard bones check
|
# Non-standard bones check
|
||||||
non_standard_bones = []
|
non_standard_bones = []
|
||||||
required_patterns = [
|
|
||||||
'Hips', 'Spine', 'Chest', 'Neck', 'Head',
|
# Bones to ignore
|
||||||
'Upper', 'Lower', 'Hand', 'Foot', 'Toe',
|
ignore_patterns = [
|
||||||
'Thumb', 'Index', 'Middle', 'Ring', 'Pinky',
|
'tail', 'skirt', 'dress', 'hair', 'ribbon', 'bow', 'hat', 'cap',
|
||||||
'Eye'
|
'butt', 'breast', 'boob', 'chest_', 'belly', 'stomach',
|
||||||
|
'wing', 'fin', 'horn', 'ear_', 'accessory', 'extra',
|
||||||
|
'cloth', 'fabric', 'cape', 'coat', 'jacket', 'shirt',
|
||||||
|
'pants', 'shoe', 'boot', 'sock', 'glove', 'mitten',
|
||||||
|
'belt', 'strap', 'buckle', 'button', 'zipper',
|
||||||
|
'jewel', 'gem', 'ring', 'necklace', 'earring',
|
||||||
|
'flower', 'leaf', 'feather', 'fur', 'scale',
|
||||||
|
'bangs', 'sideburn', 'bell', 'leash', 'ears', 'chain',
|
||||||
|
'headband', 'necklace', 'necktie', 'strapNeck', 'ring',
|
||||||
|
'pin', 'hair',
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Create normalized lookup sets for faster comparison
|
||||||
|
normalized_standard_bones = {simplify_bonename(name) for name in standard_bones.values()}
|
||||||
|
normalized_acceptable_bones = set()
|
||||||
|
for names in acceptable_bone_names.values():
|
||||||
|
normalized_acceptable_bones.update(simplify_bonename(name) for name in names)
|
||||||
|
|
||||||
for bone_name in found_bones:
|
for bone_name in found_bones:
|
||||||
if any(pattern in bone_name for pattern in required_patterns):
|
# Normalize bone name for comparison
|
||||||
is_standard = bone_name in standard_bones.values()
|
normalized_bone_name = simplify_bonename(bone_name)
|
||||||
is_acceptable_bone = any(bone_name in names for names in acceptable_bone_names.values())
|
|
||||||
|
# Check if bone should be ignored (accessory bone)
|
||||||
|
is_ignored = any(pattern in normalized_bone_name for pattern in ignore_patterns)
|
||||||
|
|
||||||
|
if not is_ignored:
|
||||||
|
# Check if bone is in standard or acceptable lists
|
||||||
|
is_standard = normalized_bone_name in normalized_standard_bones
|
||||||
|
is_acceptable_bone = normalized_bone_name in normalized_acceptable_bones
|
||||||
|
|
||||||
if not (is_standard or is_acceptable_bone):
|
if not (is_standard or is_acceptable_bone):
|
||||||
non_standard_bones.append(bone_name)
|
non_standard_bones.append(bone_name)
|
||||||
|
|
||||||
@@ -192,25 +217,28 @@ def validate_symmetry(bones: Dict[str, Bone], base: str, left: str, right: str)
|
|||||||
left_bone_names = set()
|
left_bone_names = set()
|
||||||
right_bone_names = set()
|
right_bone_names = set()
|
||||||
|
|
||||||
|
# Normalize bone names in the bones dict for comparison
|
||||||
|
normalized_bones = {simplify_bonename(name): name for name in bones.keys()}
|
||||||
|
|
||||||
# Add standard bones
|
# Add standard bones
|
||||||
for key, value in standard_bones.items():
|
for key, value in standard_bones.items():
|
||||||
if base in key.lower():
|
if base in key.lower():
|
||||||
if '_l' in key.lower():
|
if '_l' in key.lower():
|
||||||
left_bone_names.add(value)
|
left_bone_names.add(simplify_bonename(value))
|
||||||
elif '_r' in key.lower():
|
elif '_r' in key.lower():
|
||||||
right_bone_names.add(value)
|
right_bone_names.add(simplify_bonename(value))
|
||||||
|
|
||||||
# Add acceptable bones
|
# Add acceptable bones
|
||||||
for key, names in acceptable_bone_names.items():
|
for key, names in acceptable_bone_names.items():
|
||||||
if base in key.lower():
|
if base in key.lower():
|
||||||
if '_l' in key.lower():
|
if '_l' in key.lower():
|
||||||
left_bone_names.update(names)
|
left_bone_names.update(simplify_bonename(name) for name in names)
|
||||||
elif '_r' in key.lower():
|
elif '_r' in key.lower():
|
||||||
right_bone_names.update(names)
|
right_bone_names.update(simplify_bonename(name) for name in names)
|
||||||
|
|
||||||
# Check if at least one pair exists and matches
|
# Check if at least one pair exists and matches
|
||||||
left_exists = any(name in bones for name in left_bone_names)
|
left_exists = any(name in normalized_bones for name in left_bone_names)
|
||||||
right_exists = any(name in bones for name in right_bone_names)
|
right_exists = any(name in normalized_bones for name in right_bone_names)
|
||||||
|
|
||||||
return left_exists == right_exists
|
return left_exists == right_exists
|
||||||
|
|
||||||
@@ -224,22 +252,34 @@ def validate_finger_chain(bones: Dict[str, Bone], chain: Tuple[str, ...]) -> boo
|
|||||||
def check_acceptable_standards(bones: Dict[str, Bone]) -> bool:
|
def check_acceptable_standards(bones: Dict[str, Bone]) -> bool:
|
||||||
"""Check if armature matches acceptable non-standard hierarchy"""
|
"""Check if armature matches acceptable non-standard hierarchy"""
|
||||||
logger.debug("Checking for acceptable standards")
|
logger.debug("Checking for acceptable standards")
|
||||||
|
|
||||||
|
# Create normalized lookup for existing bones
|
||||||
|
normalized_bones = {simplify_bonename(name): name for name in bones.keys()}
|
||||||
|
|
||||||
# Check if bones exist in acceptable list
|
# Check if bones exist in acceptable list
|
||||||
for bone_category, acceptable_names in acceptable_bone_names.items():
|
for bone_category, acceptable_names in acceptable_bone_names.items():
|
||||||
found = False
|
found = False
|
||||||
for name in acceptable_names:
|
for name in acceptable_names:
|
||||||
if name in bones:
|
normalized_name = simplify_bonename(name)
|
||||||
|
if normalized_name in normalized_bones:
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
if not found:
|
if not found:
|
||||||
logger.debug(f"Missing acceptable bone for category: {bone_category}")
|
logger.debug(f"Missing acceptable bone for category: {bone_category}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Validate acceptable hierarchy
|
# Validate acceptable hierarchy using normalized names
|
||||||
for parent, child in acceptable_bone_hierarchy:
|
for parent, child in acceptable_bone_hierarchy:
|
||||||
if parent in bones and child in bones:
|
parent_normalized = simplify_bonename(parent)
|
||||||
if not validate_bone_hierarchy(bones, parent, child):
|
child_normalized = simplify_bonename(child)
|
||||||
logger.debug(f"Invalid acceptable hierarchy: {parent} -> {child}")
|
|
||||||
|
# Find actual bone names from normalized names
|
||||||
|
actual_parent = normalized_bones.get(parent_normalized)
|
||||||
|
actual_child = normalized_bones.get(child_normalized)
|
||||||
|
|
||||||
|
if actual_parent and actual_child:
|
||||||
|
if not validate_bone_hierarchy(bones, actual_parent, actual_child):
|
||||||
|
logger.debug(f"Invalid acceptable hierarchy: {actual_parent} -> {actual_child}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
logger.debug("Armature meets acceptable standards")
|
logger.debug("Armature meets acceptable standards")
|
||||||
|
|||||||
Reference in New Issue
Block a user