minor fixes
This commit is contained in:
@@ -276,6 +276,7 @@ def blend_bone_list(obj, apply_bones, from_bones, to_bones, target_bone=None, ta
|
||||
if not (new_pbone.bone.connected or (False not in new_pbone.lock_location)):
|
||||
blend_location(new_pbone, from_bone_name, to_bone_name)
|
||||
|
||||
if not (False not in new_pbone.lock_rotation): # TODO. 4D chech?
|
||||
blend_rotation(new_pbone, from_bone_name, to_bone_name)
|
||||
|
||||
|
||||
@@ -364,7 +365,7 @@ def add_pole_target_bone(obj, base_name, name, mode='CROSS'):
|
||||
return poll_name
|
||||
|
||||
|
||||
def generate_rig(context, obj_orig, prefix="ORG-"):
|
||||
def generate_rig(context, obj_orig, prefix="ORG-", META_DEF=True):
|
||||
from collections import OrderedDict
|
||||
|
||||
global_undo = context.user_preferences.edit.global_undo
|
||||
@@ -372,16 +373,21 @@ def generate_rig(context, obj_orig, prefix="ORG-"):
|
||||
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
|
||||
scene = context.scene
|
||||
|
||||
# copy object and data
|
||||
obj_orig.selected = False
|
||||
obj = obj_orig.copy()
|
||||
obj.data = obj_orig.data.copy()
|
||||
scene = context.scene
|
||||
scene.objects.link(obj)
|
||||
scene.objects.active = obj
|
||||
obj.selected = True
|
||||
|
||||
if META_DEF:
|
||||
obj_def = obj_orig.copy()
|
||||
obj_def.data = obj_orig.data.copy()
|
||||
scene.objects.link(obj_def)
|
||||
|
||||
arm = obj.data
|
||||
|
||||
# original name mapping
|
||||
@@ -481,8 +487,21 @@ def generate_rig(context, obj_orig, prefix="ORG-"):
|
||||
if len(result_submod) == 2:
|
||||
blend_bone_list(obj, definition, result_submod[0], result_submod[1])
|
||||
|
||||
# needed to update driver deps
|
||||
# context.scene.update()
|
||||
|
||||
if META_DEF:
|
||||
# for pbone in obj_def.pose.bones:
|
||||
for bone_name, bone_name_new in base_names.items():
|
||||
#pbone_from = bone_name
|
||||
pbone = obj_def.pose.bones[bone_name_new]
|
||||
|
||||
con = pbone.constraints.new('COPY_ROTATION')
|
||||
con.target = obj
|
||||
con.subtarget = bone_name
|
||||
|
||||
if not pbone.bone.connected:
|
||||
con = pbone.constraints.new('COPY_LOCATION')
|
||||
con.target = obj
|
||||
con.subtarget = bone_name
|
||||
|
||||
# Only for demo'ing
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ def ik(obj, bone_definition, base_names):
|
||||
con.weight = 1.0
|
||||
|
||||
con.target = obj
|
||||
con.subtarget = ik.foot
|
||||
con.subtarget = ik_chain.foot
|
||||
|
||||
con.pole_target = obj
|
||||
con.pole_subtarget = ik.knee_target
|
||||
@@ -279,7 +279,7 @@ def fk(obj, bone_definition, base_names):
|
||||
ex.thigh_socket = ex.thigh_socket_e.name
|
||||
ex.thigh_socket_e.tail = ex.thigh_socket_e.head + Vector(0.0, 0.0, ex.thigh_socket_e.length / 4.0)
|
||||
|
||||
ex.thigh_hinge_e = copy_bone_simple(arm, mt_chain.thigh, "MCH-%s_hinge" % base_names[mt_chain.thigh], parent=True)
|
||||
ex.thigh_hinge_e = copy_bone_simple(arm, mt_chain.thigh, "MCH-%s_hinge" % base_names[mt_chain.thigh])
|
||||
ex.thigh_hinge = ex.thigh_hinge_e.name
|
||||
ex.thigh_hinge_e.tail = ex.thigh_hinge_e.head + Vector(0.0, 0.0, mt_chain.thigh_e.head.length)
|
||||
ex.thigh_hinge_e.translate(Vector( - (mt.hips_e.head.x - mt_chain.thigh_e.head.x), 0.0, 0.0))
|
||||
|
||||
@@ -360,7 +360,7 @@ def main(obj, bone_definition, base_names):
|
||||
prop["soft_max"] = 1.0
|
||||
|
||||
prop = rna_idprop_ui_prop_get(mt.ribcage_p, "pivot_slide", create=True)
|
||||
mt.ribcage_p["pivot_slide"] = 0.5
|
||||
mt.ribcage_p["pivot_slide"] = 1.0 / spine_chain_len
|
||||
prop["soft_min"] = 1.0 / spine_chain_len
|
||||
prop["soft_max"] = 1.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user