Asset Pipeline v2 #145
@ -200,10 +200,18 @@ def transfer_data_add_entry(
|
|||||||
return transfer_info
|
return transfer_info
|
||||||
|
|
||||||
|
|
||||||
def transfer_info_clean(obj, list):
|
def get_transfer_data_by_name(transfer_data, td_type):
|
||||||
transfer_data = obj.transfer_data_ownership
|
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:
|
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)
|
list.remove(item)
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,9 @@ import numpy as np
|
|||||||
|
|
||||||
# VERTEX GROUPS
|
# VERTEX GROUPS
|
||||||
def vertex_groups_clean(obj):
|
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):
|
def vertex_group_is_missing(transfer_info):
|
||||||
@ -60,7 +62,9 @@ def transfer_vertex_group(
|
|||||||
def vertex_colors_clean(obj):
|
def vertex_colors_clean(obj):
|
||||||
if not obj.type == "MESH":
|
if not obj.type == "MESH":
|
||||||
return
|
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):
|
def vertex_color_is_missing(transfer_info):
|
||||||
@ -103,7 +107,7 @@ def transfer_vertex_color(
|
|||||||
def uv_layer_clean(obj):
|
def uv_layer_clean(obj):
|
||||||
if not obj.type == "MESH":
|
if not obj.type == "MESH":
|
||||||
return
|
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):
|
def uv_layer_is_missing(transfer_info):
|
||||||
@ -144,7 +148,7 @@ def transfer_uv_layer(source_obj, target_obj, uv_name):
|
|||||||
|
|
||||||
# MODIFIERS
|
# MODIFIERS
|
||||||
def modifiers_clean(obj):
|
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):
|
def modifier_is_missing(transfer_info):
|
||||||
@ -213,7 +217,7 @@ def transfer_modifier(modifier_name, target_obj, source_obj):
|
|||||||
|
|
||||||
# CONSTRAINTS
|
# CONSTRAINTS
|
||||||
def constraints_clean(obj):
|
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):
|
def constraint_is_missing(transfer_info):
|
||||||
@ -274,9 +278,11 @@ def transfer_constraint(constraint_name, target_obj, source_obj):
|
|||||||
def material_slot_clean(obj):
|
def material_slot_clean(obj):
|
||||||
# Material slots cannot use generic transfer_info_clean() function
|
# Material slots cannot use generic transfer_info_clean() function
|
||||||
context = bpy.context # TODO pass context here
|
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:
|
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)
|
index = obj.material_slots.keys().index(mat_slot.name)
|
||||||
obj.active_material_index = index
|
obj.active_material_index = index
|
||||||
with context.temp_override(object=obj):
|
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):
|
def shape_keys_clean(obj):
|
||||||
if obj.type != "MESH" or obj.data.shape_keys is None:
|
if obj.type != "MESH" or obj.data.shape_keys is None:
|
||||||
return
|
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:
|
for shape_key in obj.data.shape_keys.key_blocks:
|
||||||
# Move Shape Keys relative to themselves to the top (usually basis key)
|
# Move Shape Keys relative to themselves to the top (usually basis key)
|
||||||
if shape_key.relative_key == shape_key:
|
if shape_key.relative_key == shape_key:
|
||||||
shape_key_move(bpy.context, obj, shape_key.name)
|
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)
|
obj.shape_key_remove(shape_key)
|
||||||
|
|
||||||
|
|
||||||
@ -505,9 +513,11 @@ def attribute_clean(obj):
|
|||||||
if obj.type != "MESH":
|
if obj.type != "MESH":
|
||||||
return
|
return
|
||||||
attributes = attributes_get_editable(obj.data.attributes)
|
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:
|
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}")
|
print(f"Cleaning attribute {item.name}")
|
||||||
obj.data.attributes.remove(item)
|
obj.data.attributes.remove(item)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user