Archived
0
0

snap and switch

This commit is contained in:
2018-10-11 17:36:24 +02:00
committed by Demeter Dzadik
parent 222d481f58
commit 4a798bf9f7
2 changed files with 74 additions and 22 deletions

View File

@@ -1,4 +1,5 @@
import bpy
from bpy.props import BoolProperty
################################# IK/FK SNAPPING OPERATORS ##########################################################
@@ -39,6 +40,10 @@ def keyframe_bones(all_bones, names_to_keyframe):
bone.keyframe_insert("rotation_euler")
bone.keyframe_insert("scale")
def set_prop_and_keyframe(obj, property_name, value):
setattr(obj, property_name, value)
obj.keyframe_insert(property_name)
##### TORSO #####
class Operator_Torso_Snap_IK_FK(bpy.types.Operator):
@@ -411,6 +416,8 @@ class Operator_Arm_L_Snap_IK_FK(bpy.types.Operator):
bl_description = "Prepare seamless switch to FK"
bl_options = {'REGISTER', 'UNDO',}
do_switch: BoolProperty(default=False)
@classmethod
def poll(cls, context):
if not bpy.context.active_object:
@@ -463,6 +470,9 @@ class Operator_Arm_L_Snap_IK_FK(bpy.types.Operator):
keyframe_bones(p_bones, check_bones)
if self.do_switch:
set_prop_and_keyframe(p_bones["properties_arm_L"], "ik_arm_L", 1)
#Quadruped
if arm_data['rig_type'] == 'Quadruped':
@@ -504,6 +514,8 @@ class Operator_Arm_L_Snap_FK_IK(bpy.types.Operator):
bl_description = "Prepare seamless switch to IK"
bl_options = {'REGISTER', 'UNDO',}
do_switch: BoolProperty(default=False)
@classmethod
def poll(cls, context):
if not bpy.context.active_object:
@@ -560,6 +572,9 @@ class Operator_Arm_L_Snap_FK_IK(bpy.types.Operator):
keyframe_bones(p_bones, check_bones)
if self.do_switch:
set_prop_and_keyframe(p_bones["properties_arm_L"], "ik_arm_L", 0)
#Quadruped
if arm_data['rig_type'] == 'Quadruped':
@@ -619,6 +634,8 @@ class Operator_Arm_R_Snap_IK_FK(bpy.types.Operator):
bl_description = "Prepare seamless switch to FK"
bl_options = {'REGISTER', 'UNDO',}
do_switch: BoolProperty(default=False)
@classmethod
def poll(cls, context):
if not bpy.context.active_object:
@@ -671,6 +688,9 @@ class Operator_Arm_R_Snap_IK_FK(bpy.types.Operator):
keyframe_bones(p_bones, check_bones)
if self.do_switch:
set_prop_and_keyframe(p_bones["properties_arm_R"], "ik_arm_R", 1)
#Quadruped
if arm_data['rig_type'] == 'Quadruped':
@@ -712,6 +732,8 @@ class Operator_Arm_R_Snap_FK_IK(bpy.types.Operator):
bl_description = "Prepare seamless switch to IK"
bl_options = {'REGISTER', 'UNDO',}
do_switch: BoolProperty(default=False)
@classmethod
def poll(cls, context):
if not bpy.context.active_object:
@@ -768,6 +790,9 @@ class Operator_Arm_R_Snap_FK_IK(bpy.types.Operator):
keyframe_bones(p_bones, check_bones)
if self.do_switch:
set_prop_and_keyframe(p_bones["properties_arm_R"], "ik_arm_R", 0)
#Quadruped
if arm_data['rig_type'] == 'Quadruped':
@@ -827,6 +852,8 @@ class Operator_Leg_L_Snap_IK_FK(bpy.types.Operator):
bl_description = "Prepare seamless switch to FK"
bl_options = {'REGISTER', 'UNDO',}
do_switch: BoolProperty(default=False)
@classmethod
def poll(cls, context):
if not bpy.context.active_object:
@@ -877,6 +904,9 @@ class Operator_Leg_L_Snap_IK_FK(bpy.types.Operator):
keyframe_bones(p_bones, check_bones)
if self.do_switch:
set_prop_and_keyframe(p_bones["properties_leg_L"], "ik_leg_L", 1)
#Quadruped
if arm_data['rig_type'] == 'Quadruped':
@@ -918,6 +948,8 @@ class Operator_Leg_L_Snap_FK_IK(bpy.types.Operator):
bl_description = "Prepare seamless switch to IK"
bl_options = {'REGISTER', 'UNDO',}
do_switch: BoolProperty(default=False)
@classmethod
def poll(cls, context):
if not bpy.context.active_object:
@@ -984,6 +1016,9 @@ class Operator_Leg_L_Snap_FK_IK(bpy.types.Operator):
keyframe_bones(p_bones, check_bones)
if self.do_switch:
set_prop_and_keyframe(p_bones["properties_leg_L"], "ik_leg_L", 0)
#Quadruped
if arm_data['rig_type'] == 'Quadruped':
@@ -1044,6 +1079,8 @@ class Operator_Leg_R_Snap_IK_FK(bpy.types.Operator):
bl_description = "Prepare seamless switch to FK"
bl_options = {'REGISTER', 'UNDO',}
do_switch: BoolProperty(default=False)
@classmethod
def poll(cls, context):
if not bpy.context.active_object:
@@ -1094,6 +1131,9 @@ class Operator_Leg_R_Snap_IK_FK(bpy.types.Operator):
keyframe_bones(p_bones, check_bones)
if self.do_switch:
set_prop_and_keyframe(p_bones["properties_leg_R"], "ik_leg_R", 1)
#Quadruped
if arm_data['rig_type'] == 'Quadruped':
@@ -1135,6 +1175,8 @@ class Operator_Leg_R_Snap_FK_IK(bpy.types.Operator):
bl_description = "Prepare seamless switch to IK"
bl_options = {'REGISTER', 'UNDO',}
do_switch: BoolProperty(default=False)
@classmethod
def poll(cls, context):
if not bpy.context.active_object:
@@ -1201,6 +1243,9 @@ class Operator_Leg_R_Snap_FK_IK(bpy.types.Operator):
keyframe_bones(p_bones, check_bones)
if self.do_switch:
set_prop_and_keyframe(p_bones["properties_leg_R"], "ik_leg_R", 0)
#Quadruped
if arm_data['rig_type'] == 'Quadruped':
@@ -1249,5 +1294,4 @@ class Operator_Leg_R_Snap_FK_IK(bpy.types.Operator):
keyframe_bones(p_bones, check_bones)
return {"FINISHED"}
return {"FINISHED"}

View File

@@ -2467,38 +2467,46 @@ class BLENRIG_PT_BlenRig_5_Interface(bpy.types.Panel):
if is_selected(arm_l + hand_l) or props.gui_snap_all:
box = col_snap.column()
box.label(text="SNAP ARM LEFT")
col = col_snap.column()
row = col.row()
col2 = row.column()
row.operator("arm_l_snap.fk_ik", text="FK >> IK", icon="NONE")
col2.operator("arm_l_snap.ik_fk", text="IK >> FK", icon="NONE")
row = box.row()
col1 = row.column(align=True)
col1.operator("arm_l_snap.fk_ik", text="FK >> IK")
col1.operator("arm_l_snap.fk_ik", text="Snap and Switch").do_switch = True
col2 = row.column(align=True)
col2.operator("arm_l_snap.ik_fk", text="IK >> FK")
col2.operator("arm_l_snap.ik_fk", text="Snap and Switch").do_switch = True
if is_selected(arm_r + hand_r) or props.gui_snap_all:
box = col_snap.column()
box.label(text="SNAP ARM RIGHT")
col = col_snap.column()
row = col.row()
col2 = row.column()
row.operator("arm_r_snap.fk_ik", text="FK >> IK", icon="NONE")
col2.operator("arm_r_snap.ik_fk", text="IK >> FK", icon="NONE")
row = box.row()
col1 = row.column(align=True)
col1.operator("arm_r_snap.fk_ik", text="FK >> IK")
col1.operator("arm_r_snap.fk_ik", text="Snap and Switch").do_switch = True
col2 = row.column(align=True)
col2.operator("arm_r_snap.ik_fk", text="IK >> FK")
col2.operator("arm_r_snap.ik_fk", text="Snap and Switch").do_switch = True
if is_selected(leg_l + foot_l) or props.gui_snap_all:
box = col_snap.column()
box.label(text="SNAP LEG LEFT")
col = col_snap.column()
row = col.row()
col2 = row.column()
row.operator("leg_l_snap.fk_ik", text="FK >> IK", icon="NONE")
col2.operator("leg_l_snap.ik_fk", text="IK >> FK", icon="NONE")
row = box.row()
col1 = row.column(align=True)
col1.operator("leg_l_snap.fk_ik", text="FK >> IK")
col1.operator("leg_l_snap.fk_ik", text="Snap and Switch").do_switch = True
col2 = row.column(align=True)
col2.operator("leg_l_snap.ik_fk", text="IK >> FK")
col2.operator("leg_l_snap.ik_fk", text="Snap and Switch").do_switch = True
if is_selected(leg_r + foot_r) or props.gui_snap_all:
box = col_snap.column()
box.label(text="SNAP LEG RIGHT")
col = col_snap.column()
row = col.row()
col2 = row.column()
row.operator("leg_r_snap.fk_ik", text="FK >> IK", icon="NONE")
col2.operator("leg_r_snap.ik_fk", text="IK >> FK", icon="NONE")
row = box.row()
col1 = row.column(align=True)
col1.operator("leg_r_snap.fk_ik", text="FK >> IK")
col1.operator("leg_r_snap.fk_ik", text="Snap and Switch").do_switch = True
col2 = row.column(align=True)
col2.operator("leg_r_snap.ik_fk", text="IK >> FK")
col2.operator("leg_r_snap.ik_fk", text="Snap and Switch").do_switch = True
col_snap.separator()
col_snap.separator()