Asset Pipeline v2 #145
@ -111,20 +111,20 @@ def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
|
||||
if transfer_info.type == constants.MODIFIER_KEY:
|
||||
print(f"Transfering Data {constants.MODIFIER_KEY}: {name}")
|
||||
transfer_functions.transfer_modifier(
|
||||
transfer_info=transfer_info,
|
||||
modifier_name=transfer_info.name,
|
||||
target_obj=target_obj,
|
||||
source_obj=source_obj,
|
||||
)
|
||||
if transfer_info.type == constants.CONSTRAINT_KEY:
|
||||
transfer_functions.transfer_constraint(
|
||||
transfer_info=transfer_info,
|
||||
constraint_name=transfer_info.name,
|
||||
target_obj=target_obj,
|
||||
source_obj=source_obj,
|
||||
)
|
||||
if transfer_info.type == constants.MATERIAL_SLOT_KEY:
|
||||
print(f"Transfering Data {constants.MATERIAL_SLOT_KEY}: {name}")
|
||||
transfer_functions.transfer_material_slot(
|
||||
transfer_info=transfer_info,
|
||||
material_slot_name=transfer_info.name,
|
||||
target_obj=target_obj,
|
||||
source_obj=source_obj,
|
||||
)
|
||||
|
@ -5,9 +5,6 @@ from .. import asset_suffix, constants
|
||||
|
||||
|
||||
## FUNCTIONS SPECFIC TO TRANSFER DATA TYPES
|
||||
# TODO Remove reliance on transfer_info for 'transfer' functions
|
||||
|
||||
|
||||
def vertex_groups_clean(obj):
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
for vertex_group in obj.vertex_groups:
|
||||
@ -212,15 +209,15 @@ def get_modifiers(obj, task_layer_name, new_transfer_data):
|
||||
transfer_info.obj = obj
|
||||
|
||||
|
||||
def transfer_modifier(transfer_info, target_obj, source_obj):
|
||||
def transfer_modifier(modifier_name, target_obj, source_obj):
|
||||
# remove old and sync existing modifiers
|
||||
old_mod = target_obj.modifiers.get(transfer_info.name)
|
||||
old_mod = target_obj.modifiers.get(modifier_name)
|
||||
if old_mod:
|
||||
target_obj.modifiers.remove(old_mod)
|
||||
|
||||
# transfer new modifiers
|
||||
for i, mod in enumerate(source_obj.modifiers):
|
||||
if mod.name == transfer_info.name:
|
||||
if mod.name == modifier_name:
|
||||
mod_new = target_obj.modifiers.new(mod.name, mod.type)
|
||||
# sort new modifier at correct index (default to beginning of the stack)
|
||||
idx = 0
|
||||
@ -296,15 +293,15 @@ def get_constraints(obj, task_layer_name, new_transfer_data):
|
||||
transfer_info.obj = obj
|
||||
|
||||
|
||||
def transfer_constraint(transfer_info, target_obj, source_obj):
|
||||
def transfer_constraint(constraint_name, target_obj, source_obj):
|
||||
# remove old and sync existing modifiers
|
||||
old_mod = target_obj.constraints.get(transfer_info.name)
|
||||
old_mod = target_obj.constraints.get(constraint_name)
|
||||
if old_mod:
|
||||
target_obj.constraints.remove(old_mod)
|
||||
|
||||
# transfer new modifiers
|
||||
for i, constraint in enumerate(source_obj.constraints):
|
||||
if constraint.name == transfer_info.name:
|
||||
if constraint.name == constraint_name:
|
||||
constraint_new = target_obj.constraints.new(constraint.type)
|
||||
constraint_new.name = constraint.name
|
||||
# sort new modifier at correct index (default to beginning of the stack)
|
||||
@ -361,11 +358,11 @@ def get_material_slots(obj, task_layer_name, new_transfer_data):
|
||||
transfer_info.obj = obj
|
||||
|
||||
|
||||
def transfer_material_slot(transfer_info, target_obj, source_obj):
|
||||
def transfer_material_slot(material_slot_name, target_obj, source_obj):
|
||||
# Delete existing material slot if exists
|
||||
for idx in range(len(source_obj.material_slots)):
|
||||
slot = source_obj.material_slots[idx]
|
||||
if asset_suffix.get_basename(slot.material.name) == transfer_info.name:
|
||||
if asset_suffix.get_basename(slot.material.name) == material_slot_name:
|
||||
target_obj.active_material_index = idx
|
||||
bpy.ops.object.material_slot_remove({"object": target_obj})
|
||||
|
||||
@ -374,7 +371,7 @@ def transfer_material_slot(transfer_info, target_obj, source_obj):
|
||||
for idx in range(len(source_obj.material_slots)):
|
||||
if idx >= len(target_obj.material_slots):
|
||||
slot = source_obj.material_slots[idx]
|
||||
if asset_suffix.get_basename(slot.material.name) == transfer_info.name:
|
||||
if asset_suffix.get_basename(slot.material.name) == material_slot_name:
|
||||
bpy.ops.object.material_slot_add({"object": target_obj})
|
||||
target_obj.material_slots[idx].link = source_obj.material_slots[
|
||||
idx
|
||||
|
Loading…
Reference in New Issue
Block a user