more fixes
This commit is contained in:
@@ -5,6 +5,7 @@ from . import bones_skel_struct
|
||||
from . import bones_fingers_struct
|
||||
from . import bones_toes_struct
|
||||
from . import bones_web_struct
|
||||
from . import bones_ik_struct
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +21,7 @@ def modifybone(bone, head_empt, tail_empt, armature, matrixworldinv):
|
||||
allowtail = False
|
||||
alloweditbone = False
|
||||
|
||||
print(f"modifying bone: {edit_bone}")
|
||||
# print(f"modifying bone: {edit_bone}")
|
||||
|
||||
# Fetch world coordinates of the empties
|
||||
if empty_head:
|
||||
@@ -50,7 +51,23 @@ def fixbonestretching(bone, armature):
|
||||
if constaint.type == 'STRETCH_TO':
|
||||
constaint.rest_length = 0.0
|
||||
|
||||
|
||||
|
||||
# Setup IK Bones
|
||||
def setupIKbones(bone, helper_name, armature, matrixworldinv):
|
||||
bpy.context.view_layer.objects.active = armature
|
||||
bpy.ops.object.mode_set(mode='EDIT')
|
||||
|
||||
edit_bone = armature.data.edit_bones.get(bone)
|
||||
helper_empt = bpy.data.objects.get(helper_name)
|
||||
|
||||
if edit_bone:
|
||||
target_length = 0.025
|
||||
direction = (edit_bone.tail - edit_bone.head).normalized()
|
||||
|
||||
empty_pos = helper_empt.matrix_world.translation
|
||||
edit_bone.head = matrixworldinv @ empty_pos
|
||||
edit_bone.tail = edit_bone.head + direction * target_length
|
||||
|
||||
|
||||
|
||||
def startAutoRig():
|
||||
@@ -256,6 +273,17 @@ def startAutoRig():
|
||||
|
||||
|
||||
|
||||
# =========== IK Bones ===========
|
||||
|
||||
bones_ik_data_list = bones_ik_struct.bones_ik_data
|
||||
|
||||
for item in bones_ik_data_list:
|
||||
b_name = item["bone_name"]
|
||||
pos_helper = item["pos_helper"]
|
||||
|
||||
setupIKbones(b_name, pos_helper, new_amt_obj, matrix_world_inv) # Call Setup IK Bone Function
|
||||
|
||||
|
||||
|
||||
# Returns 'helpers' collection to restore hide state prior to bone modification
|
||||
if ishelperscollhidden:
|
||||
|
||||
Reference in New Issue
Block a user