Asset Pipeline v2 #145
@ -136,6 +136,7 @@ def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
|
|||||||
)
|
)
|
||||||
if transfer_info.type == constants.SHAPE_KEY_KEY:
|
if transfer_info.type == constants.SHAPE_KEY_KEY:
|
||||||
transfer_functions.transfer_shape_key(
|
transfer_functions.transfer_shape_key(
|
||||||
|
context=context,
|
||||||
target_obj=target_obj,
|
target_obj=target_obj,
|
||||||
source_obj=source_obj,
|
source_obj=source_obj,
|
||||||
shape_key_name=transfer_info.name,
|
shape_key_name=transfer_info.name,
|
||||||
|
@ -321,6 +321,21 @@ def transfer_material_slot(material_slot_name, target_obj, source_obj):
|
|||||||
|
|
||||||
|
|
||||||
# SHAPE KEYS
|
# SHAPE KEYS
|
||||||
|
|
||||||
|
|
||||||
|
def shape_key_set_active(obj, shape_key_name):
|
||||||
|
for index, shape_key in enumerate(obj.data.shape_keys.key_blocks):
|
||||||
|
if shape_key.name == shape_key_name:
|
||||||
|
obj.active_shape_key_index = index
|
||||||
|
|
||||||
|
|
||||||
|
def shape_key_active_move(context, obj, shape_key_name, top=True):
|
||||||
|
move_type = "TOP" if top else "BOTTOM"
|
||||||
|
shape_key_set_active(obj, shape_key_name)
|
||||||
|
with context.temp_override(active_object=obj, object=obj):
|
||||||
|
bpy.ops.object.shape_key_move(type=move_type)
|
||||||
|
|
||||||
|
|
||||||
def shape_key_closest_face_to_point(bm_source, p_target, bvh_tree=None):
|
def shape_key_closest_face_to_point(bm_source, p_target, bvh_tree=None):
|
||||||
if not bvh_tree:
|
if not bvh_tree:
|
||||||
bvh_tree = mathutils.bvhtree.BVHTree.FromBMesh(bm_source)
|
bvh_tree = mathutils.bvhtree.BVHTree.FromBMesh(bm_source)
|
||||||
@ -383,12 +398,14 @@ def init_shap_keys(scene, obj):
|
|||||||
|
|
||||||
|
|
||||||
def transfer_shape_key(
|
def transfer_shape_key(
|
||||||
|
context: bpy.types.Context,
|
||||||
shape_key_name: str,
|
shape_key_name: str,
|
||||||
target_obj: bpy.types.Object,
|
target_obj: bpy.types.Object,
|
||||||
source_obj: bpy.types.Object,
|
source_obj: bpy.types.Object,
|
||||||
):
|
):
|
||||||
# BASIS SHAPE KEY MUST BE PASSED FIRST OTHERWISE THIS WILL ERROR OUT
|
# BASIS SHAPE KEY MUST BE PASSED FIRST OTHERWISE THIS WILL ERROR OUT
|
||||||
sk_source = source_obj.data.shape_keys.key_blocks.get(shape_key_name)
|
sk_source = source_obj.data.shape_keys.key_blocks.get(shape_key_name)
|
||||||
|
print(f"Moving shape key: {shape_key_name}")
|
||||||
|
|
||||||
# TODO Restore Shape Key Index Position after Transfer
|
# TODO Restore Shape Key Index Position after Transfer
|
||||||
|
|
||||||
@ -415,6 +432,7 @@ def transfer_shape_key(
|
|||||||
sk_target.relative_key = target_obj.data.shape_keys.key_blocks[
|
sk_target.relative_key = target_obj.data.shape_keys.key_blocks[
|
||||||
sk_source.relative_key.name
|
sk_source.relative_key.name
|
||||||
]
|
]
|
||||||
|
shape_key_active_move(context, target_obj, shape_key_name)
|
||||||
|
|
||||||
bm_source = bmesh.new()
|
bm_source = bmesh.new()
|
||||||
bm_source.from_mesh(source_obj.data)
|
bm_source.from_mesh(source_obj.data)
|
||||||
|
Loading…
Reference in New Issue
Block a user