Skip to content

Commit

Permalink
Hide horribly broken rig bone selector for now. Remove baked animatio…
Browse files Browse the repository at this point in the history
…n data works again.
  • Loading branch information
thepancake1 committed Jun 19, 2022
1 parent 7b03365 commit 7d2c9ed
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 54 deletions.
60 changes: 30 additions & 30 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,38 +1046,38 @@ def draw(self, context):
layout.prop(obj, "ignores_fenestration_node", text = "Fenestration Node")
layout.prop(obj, "ignores_trim", text = "Trim")

layout.operator("s4animtools.create_bone_selectors", icon='MESH_CUBE', text="Create Bone Selectors")
# layout.operator("s4animtools.create_bone_selectors", icon='MESH_CUBE', text="Create Bone Selectors")
layout.operator("s4animtools.create_finger_ik", icon='MESH_CUBE', text="Create Finger IK")
layout.operator("s4animtools.create_ik_rig", icon='MESH_CUBE', text="Create IK Rig")
layout.prop(obj, "select_slots", text = "Slots")
layout.prop(obj, "select_cas", text = "CAS")
layout.prop(obj, "select_left", text = "Left Side")
layout.prop(obj, "select_middle", text = "Middle")

layout.prop(obj, "select_right", text = "Right Side")
layout.prop(obj, "select_mouth", text = "Mouth")

layout.prop(obj, "select_left_pinky", text = "Left Pinky")
layout.prop(obj, "select_left_ring", text = "Left Ring")
layout.prop(obj, "select_left_middle", text = "Left Middle")
layout.prop(obj, "select_left_index", text = "Left Index")
layout.prop(obj, "select_left_thumb", text = "Left Thumb")
layout.prop(obj, "select_left_fingers", text = "Left Fingers")

layout.prop(obj, "select_left_first_fingers", text = "Left First Fingers")
layout.prop(obj, "select_left_second_fingers", text = "Left Second Fingers")
layout.prop(obj, "select_left_third_fingers", text = "Left Third Fingers")

layout.prop(obj, "select_right_pinky", text = "Right Pinky")
layout.prop(obj, "select_right_ring", text = "Right Ring")
layout.prop(obj, "select_right_middle", text = "Right Middle")
layout.prop(obj, "select_right_index", text = "Right Index")
layout.prop(obj, "select_right_thumb", text = "Right Thumb")
layout.prop(obj, "select_right_fingers", text = "Right Fingers")

layout.prop(obj, "select_right_first_fingers", text = "Right First Fingers")
layout.prop(obj, "select_right_second_fingers", text = "Right Second Fingers")
layout.prop(obj, "select_right_third_fingers", text = "Right Third Fingers")
# layout.prop(obj, "select_slots", text = "Slots")
# layout.prop(obj, "select_cas", text = "CAS")
# layout.prop(obj, "select_left", text = "Left Side")
# layout.prop(obj, "select_middle", text = "Middle")

# layout.prop(obj, "select_right", text = "Right Side")
# layout.prop(obj, "select_mouth", text = "Mouth")

# layout.prop(obj, "select_left_pinky", text = "Left Pinky")
# layout.prop(obj, "select_left_ring", text = "Left Ring")
# layout.prop(obj, "select_left_middle", text = "Left Middle")
# layout.prop(obj, "select_left_index", text = "Left Index")
# layout.prop(obj, "select_left_thumb", text = "Left Thumb")
# layout.prop(obj, "select_left_fingers", text = "Left Fingers")

# layout.prop(obj, "select_left_first_fingers", text = "Left First Fingers")
# layout.prop(obj, "select_left_second_fingers", text = "Left Second Fingers")
# layout.prop(obj, "select_left_third_fingers", text = "Left Third Fingers")

# layout.prop(obj, "select_right_pinky", text = "Right Pinky")
# layout.prop(obj, "select_right_ring", text = "Right Ring")
# layout.prop(obj, "select_right_middle", text = "Right Middle")
# layout.prop(obj, "select_right_index", text = "Right Index")
# layout.prop(obj, "select_right_thumb", text = "Right Thumb")
# layout.prop(obj, "select_right_fingers", text = "Right Fingers")

# layout.prop(obj, "select_right_first_fingers", text = "Right First Fingers")
# layout.prop(obj, "select_right_second_fingers", text = "Right Second Fingers")
# layout.prop(obj, "select_right_third_fingers", text = "Right Third Fingers")

layout = self.layout.row()
layout.operator("s4animtools.copy_baked_animation", icon='MESH_CUBE', text="Copy Baked Animation")
Expand Down
40 changes: 16 additions & 24 deletions ik_baker.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ def execute(self, context):
if old_fc is not None:
obj.animation_data.action.fcurves.remove(old_fc)
data_path = f'pose.bones["{potential_ik_bone.name}"].ik_weight_{idx}'
old_fc = obj.animation_data.action.fcurves.find(data_path)
if old_fc is not None:
obj.animation_data.action.fcurves.remove(old_fc)
s4animtool_OT_bakeik.find_and_remove(data_path, obj)
current_bone_idx = defaultdict(int)

for idx, item in enumerate(get_ik_targets(obj)):
Expand Down Expand Up @@ -182,9 +180,7 @@ def execute(self, context):
target_rig = bpy.data.objects[item.target_obj]

data_path = f'pose.bones["{chain_bone.name}"].ik_weight_{current_bone_idx[chain_bone]}'
old_fc = obj.animation_data.action.fcurves.find(data_path)
if old_fc is not None:
obj.animation_data.action.fcurves.remove(old_fc)
s4animtool_OT_bakeik.find_and_remove(data_path, obj)
fc = obj.animation_data.action.fcurves.new(data_path)


Expand Down Expand Up @@ -224,22 +220,18 @@ def get_bonedata(self, item, obj):

@staticmethod
def remove_IK(obj):
for scn_obj in bpy.data.objects:
split = scn_obj.name.split(" ")
if len(split) >= 2:
if split[0] == obj.name.strip() and split[1] == "IK":
bpy.data.objects.remove(scn_obj, do_unlink=True)

for bone in obj.pose.bones:
for constraint in bone.constraints[:]:
if constraint.type == "COPY_TRANSFORMS":
if constraint.name.startswith("IKFollow"):
bone.constraints.remove(constraint)
bpy.context.view_layer.update()
for fcu in obj.animation_data.action.fcurves[:]:
for bone in obj.pose.bones:
try:

if fcu.data_path.startswith('pose.bones["{}"].constraints["{}'.format(bone.name, "IKFollow")):
obj.animation_data.action.fcurves.remove(fcu)
except:
pass
for weight_idx in range(0, 9):
print(weight_idx)
s4animtool_OT_bakeik.find_and_remove(f'pose.bones["{bone.name}"].ik_weight_{weight_idx}', obj)
for i in range(3):
s4animtool_OT_bakeik.find_and_remove(f'pose.bones["{bone.name}"].ik_pos_{weight_idx}', obj, index=i)
for i in range(4):

s4animtool_OT_bakeik.find_and_remove(f'pose.bones["{bone.name}"].ik_rot_{weight_idx}', obj, index=i)
@staticmethod
def find_and_remove(data_path, obj, index=0):
old_fc = obj.animation_data.action.fcurves.find(data_path, index=index)
if old_fc is not None:
obj.animation_data.action.fcurves.remove(old_fc)

0 comments on commit 7d2c9ed

Please sign in to comment.