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 34 additions and 32 deletions
Showing only changes of commit 942427a374 - Show all commits

View File

@ -6,7 +6,6 @@ from .transfer_util import (
transfer_info_clean,
transfer_info_is_missing,
transfer_info_init,
get_transfer_data_as_names, # TODO Replce with check entry
check_transfer_data_entry,
)
from ... import constants
@ -346,13 +345,15 @@ def transfer_constraint(constraint_name, target_obj, source_obj):
# MATERIAL SLOT
def material_slots_clean(obj):
# Material slots cannot use generic transfer_info_clean() function
context = bpy.context
transfer_data_list = get_transfer_data_as_names(
obj.transfer_data_ownership, constants.MATERIAL_SLOT_KEY
matches = check_transfer_data_entry(
obj.transfer_data_ownership,
constants.MATERIAL_TRANSFER_INFO_NAME,
constants.MATERIAL_SLOT_KEY,
)
# Clear Materials if No Transfer Data is Found
if transfer_data_list != []:
if len(matches) != 0:
return
if obj.data and hasattr(obj.data, 'materials'):
@ -454,14 +455,16 @@ def shape_key_closest_tri_on_face(tris_dict, face, p):
def shape_keys_clean(obj):
context = bpy.context
if obj.type != "MESH" or obj.data.shape_keys is None:
return
transfer_data_list = get_transfer_data_as_names(
obj.transfer_data_ownership, constants.SHAPE_KEY_KEY
)
for shape_key in obj.data.shape_keys.key_blocks:
if not get_basename(shape_key.name) in transfer_data_list:
matches = check_transfer_data_entry(
obj.transfer_data_ownership,
get_basename(shape_key.name),
constants.SHAPE_KEY_KEY,
)
if len(matches) == 0:
obj.shape_key_remove(shape_key)
@ -596,13 +599,16 @@ def attribute_clean(obj):
if obj.type != "MESH":
return
attributes = attributes_get_editable(obj.data.attributes)
transfer_data_list = get_transfer_data_as_names(
obj.transfer_data_ownership, constants.ATTRIBUTE_KEY
for attribute in attributes:
matches = check_transfer_data_entry(
obj.transfer_data_ownership,
get_basename(attribute.name),
constants.SHAPE_KEY_KEY,
)
for item in attributes:
if not get_basename(item.name) in transfer_data_list:
print(f"Cleaning attribute {item.name}")
obj.data.attributes.remove(item)
if len(matches) == 0:
print(f"Cleaning attribute {attribute.name}")
obj.data.attributes.remove(attribute)
def attribute_is_missing(transfer_info):
@ -667,11 +673,13 @@ def transfer_attribute(
def parent_clean(obj):
transfer_data_list = get_transfer_data_as_names(
obj.transfer_data_ownership, constants.PARENT_KEY
matches = check_transfer_data_entry(
obj.transfer_data_ownership,
get_basename(constants.PARENT_TRANSFER_INFO_NAME),
constants.SHAPE_KEY_KEY,
)
if transfer_data_list != []:
if len(matches) != 0:
return
obj.parent = None

View File

@ -44,14 +44,6 @@ def transfer_data_add_entry(
return transfer_info
def get_transfer_data_as_names(transfer_data, td_type_key):
return [
transfer_info.name
for transfer_info in transfer_data
if transfer_info.type == td_type_key
]
# TODO Test if Clean and Missing are redudent functions
def transfer_info_clean(
obj: bpy.types.Object, data_list: bpy.types.CollectionProperty, td_type_key: str
@ -62,11 +54,13 @@ def transfer_info_clean(
data_list (bpy.types.CollectionProperty): Collection Property containing a type of possible transfer data e.g. obj.modifiers
td_type_key (str): Key for the transfer data type
"""
transfer_data_list = get_transfer_data_as_names(
obj.transfer_data_ownership, td_type_key
)
for item in data_list:
if not get_basename(item.name) in transfer_data_list:
matches = check_transfer_data_entry(
obj.transfer_data_ownership,
get_basename(item.name),
td_type_key,
)
if len(matches) == 0:
data_list.remove(item)