Skip to content

Commit

Permalink
Minor update the error check of "Bone Order" panel
Browse files Browse the repository at this point in the history
  • Loading branch information
powroupi committed Jun 19, 2020
1 parent e4da67f commit 5ee36c6
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions mmd_tools/panels/util_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,44 +233,47 @@ def _draw_bone_item(cls, layout, bone_name, pose_bones, vertex_groups, index):

mmd_bone = bone.mmd_bone
count = len(pose_bones)
bone_transform_rank = index + mmd_bone.transform_order*count

r = row_sub.row()
bone_parent = bone.parent
if bone_parent:
bone_parent = bone_parent.name
idx = vertex_groups.get(bone_parent, _DummyVertexGroup).index
if idx is None or (index + mmd_bone.transform_order*count) < (idx + pose_bones[bone_parent].mmd_bone.transform_order*count):
if idx is None or bone_transform_rank < (idx + pose_bones[bone_parent].mmd_bone.transform_order*count):
r.label(text=str(idx), icon='ERROR')
else:
r.label(text=str(idx), icon='FILE_PARENT')
r.label(text=str(idx), icon='INFO' if index < idx else 'FILE_PARENT')
else:
r.label()

r = r.row()
if mmd_bone.has_additional_rotation:
append_bone = mmd_bone.additional_transform_bone
idx = vertex_groups.get(append_bone, _DummyVertexGroup).index
if idx is None or (index + mmd_bone.transform_order*count) < (idx + pose_bones[append_bone].mmd_bone.transform_order*count):
if idx is None or bone_transform_rank < (idx + pose_bones[append_bone].mmd_bone.transform_order*count):
if append_bone:
r.label(text=str(idx), icon='ERROR')
else:
r.label(text=str(idx), icon=ICON_APPEND_MOVE_ROT if mmd_bone.has_additional_location else ICON_APPEND_ROT)
elif mmd_bone.has_additional_location:
append_bone = mmd_bone.additional_transform_bone
idx = vertex_groups.get(append_bone, _DummyVertexGroup).index
if idx is None or (index + mmd_bone.transform_order*count) < (idx + pose_bones[append_bone].mmd_bone.transform_order*count):
if idx is None or bone_transform_rank < (idx + pose_bones[append_bone].mmd_bone.transform_order*count):
if append_bone:
r.label(text=str(idx), icon='ERROR')
else:
r.label(text=str(idx), icon=ICON_APPEND_MOVE)

for idx, b in sorted(((vertex_groups.get(b, _DummyVertexGroup).index, b) for b in cls._IK_MAP.get(hash(bone), ())), key=lambda i: i[0] or 0):
if idx is None or (index + mmd_bone.transform_order*count) > (idx + pose_bones[b].mmd_bone.transform_order*count):
r.prop(pose_bones[b], 'mmd_ik_toggle', text=str(idx), toggle=True, icon='ERROR')
ik_bone = pose_bones[b]
is_ik_chain = (hash(bone) != cls._IK_BONES.get(b))
if idx is None or (is_ik_chain and bone_transform_rank > (idx + ik_bone.mmd_bone.transform_order*count)):
r.prop(ik_bone, 'mmd_ik_toggle', text=str(idx), toggle=True, icon='ERROR')
elif b not in cls._IK_BONES:
r.prop(pose_bones[b], 'mmd_ik_toggle', text=str(idx), toggle=True, icon='QUESTION')
r.prop(ik_bone, 'mmd_ik_toggle', text=str(idx), toggle=True, icon='QUESTION')
else:
r.prop(pose_bones[b], 'mmd_ik_toggle', text=str(idx), toggle=True, icon='LINKED' if hash(bone) != cls._IK_BONES.get(b) else 'HOOK')
r.prop(ik_bone, 'mmd_ik_toggle', text=str(idx), toggle=True, icon='LINKED' if is_ik_chain else 'HOOK')

row = row_sub.row(align=True)
if mmd_bone.transform_after_dynamics:
Expand Down Expand Up @@ -311,7 +314,7 @@ def draw(self, context):
layout.label(text='The armature object of active MMD model can\'t be found', icon='ERROR')
return

bone_order_object = next((i for i in armature.children if 'mmd_bone_order_override' in i.modifiers), None) #TODO consistancy issue
bone_order_object = next((i for i in armature.children if 'mmd_bone_order_override' in i.modifiers), None) #TODO consistency issue
bone_count = MMD_TOOLS_UL_ModelBones.update_bone_tables(armature, bone_order_object)

col = layout.column(align=True)
Expand Down

0 comments on commit 5ee36c6

Please sign in to comment.