Asset Pipeline v2 #145

Closed
Nick Alberelli wants to merge 431 commits from (deleted):feature/asset-pipeline-v2 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 32 additions and 14 deletions
Showing only changes of commit aaf834cd55 - Show all commits

View File

@ -200,10 +200,18 @@ def transfer_data_add_entry(
return transfer_info
def transfer_info_clean(obj, list):
transfer_data = obj.transfer_data_ownership
def get_transfer_data_by_name(transfer_data, td_type):
return [
transfer_info.name
for transfer_info in transfer_data
if transfer_info.type == td_type
]
def transfer_info_clean(obj, list, td_type):
transfer_data_list = get_transfer_data_by_name(obj.transfer_data_ownership, td_type)
for item in list:
if not asset_suffix.get_basename(item.name) in transfer_data.keys():
if not asset_suffix.get_basename(item.name) in transfer_data_list:
list.remove(item)

View File

@ -12,7 +12,9 @@ import numpy as np
# VERTEX GROUPS
def vertex_groups_clean(obj):
transfer_core.transfer_info_clean(obj, obj.vertex_groups)
transfer_core.transfer_info_clean(
obj, obj.vertex_groups, constants.VERTEX_GROUP_KEY
)
def vertex_group_is_missing(transfer_info):
@ -60,7 +62,9 @@ def transfer_vertex_group(
def vertex_colors_clean(obj):
if not obj.type == "MESH":
return
transfer_core.transfer_info_clean(obj, obj.data.vertex_colors)
transfer_core.transfer_info_clean(
obj, obj.data.vertex_colors, constants.VERTEX_COLOR_KEY
)
def vertex_color_is_missing(transfer_info):
@ -103,7 +107,7 @@ def transfer_vertex_color(
def uv_layer_clean(obj):
if not obj.type == "MESH":
return
transfer_core.transfer_info_clean(obj, obj.data.uv_layers)
transfer_core.transfer_info_clean(obj, obj.data.uv_layers, constants.UV_LAYERS_KEY)
def uv_layer_is_missing(transfer_info):
@ -144,7 +148,7 @@ def transfer_uv_layer(source_obj, target_obj, uv_name):
# MODIFIERS
def modifiers_clean(obj):
transfer_core.transfer_info_clean(obj, obj.modifiers)
transfer_core.transfer_info_clean(obj, obj.modifiers, constants.MODIFIER_KEY)
def modifier_is_missing(transfer_info):
@ -213,7 +217,7 @@ def transfer_modifier(modifier_name, target_obj, source_obj):
# CONSTRAINTS
def constraints_clean(obj):
transfer_core.transfer_info_clean(obj, obj.constraints)
transfer_core.transfer_info_clean(obj, obj.constraints, constants.CONSTRAINT_KEY)
def constraint_is_missing(transfer_info):
@ -274,9 +278,11 @@ def transfer_constraint(constraint_name, target_obj, source_obj):
def material_slot_clean(obj):
# Material slots cannot use generic transfer_info_clean() function
context = bpy.context # TODO pass context here
transfer_data = obj.transfer_data_ownership
transfer_data_list = transfer_core.get_transfer_data_by_name(
obj.transfer_data_ownership, constants.MATERIAL_SLOT_KEY
)
for mat_slot in obj.material_slots:
if not asset_suffix.get_basename(mat_slot.name) in transfer_data.keys():
if not asset_suffix.get_basename(mat_slot.name) in transfer_data_list:
index = obj.material_slots.keys().index(mat_slot.name)
obj.active_material_index = index
with context.temp_override(object=obj):
@ -391,13 +397,15 @@ def shape_key_closest_tri_on_face(tris_dict, face, p):
def shape_keys_clean(obj):
if obj.type != "MESH" or obj.data.shape_keys is None:
return
transfer_data = obj.transfer_data_ownership
transfer_data_list = transfer_core.get_transfer_data_by_name(
obj.transfer_data_ownership, constants.SHAPE_KEY_KEY
)
for shape_key in obj.data.shape_keys.key_blocks:
# Move Shape Keys relative to themselves to the top (usually basis key)
if shape_key.relative_key == shape_key:
shape_key_move(bpy.context, obj, shape_key.name)
if not asset_suffix.get_basename(shape_key.name) in transfer_data.keys():
if not asset_suffix.get_basename(shape_key.name) in transfer_data_list:
obj.shape_key_remove(shape_key)
@ -505,9 +513,11 @@ def attribute_clean(obj):
if obj.type != "MESH":
return
attributes = attributes_get_editable(obj.data.attributes)
transfer_data = obj.transfer_data_ownership
transfer_data_list = transfer_core.get_transfer_data_by_name(
obj.transfer_data_ownership, constants.ATTRIBUTE_KEY
)
for item in attributes:
if not asset_suffix.get_basename(item.name) in transfer_data.keys():
if not asset_suffix.get_basename(item.name) in transfer_data_list:
print(f"Cleaning attribute {item.name}")
obj.data.attributes.remove(item)