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.
Showing only changes of commit a82d680c48 - Show all commits

View File

@ -4,7 +4,15 @@ from . import transfer_functions
from .. import constants from .. import constants
def update_transfer_data_ownership(transfer_data_item, target_obj: bpy.types.Object): def copy_transfer_data_ownership(
transfer_data_item, target_obj: bpy.types.Object
) -> None:
"""Copy transfer data item to object if non entry exists
Args:
transfer_data_item (_type_): Item of bpy.types.CollectionProperty from source object
target_obj (bpy.types.Object): Object to add transfer data item to
"""
ownership = target_obj.transfer_data_ownership ownership = target_obj.transfer_data_ownership
transfer_items_names = [item.name for item in ownership] transfer_items_names = [item.name for item in ownership]
if transfer_data_item.name not in transfer_items_names: if transfer_data_item.name not in transfer_items_names:
@ -16,7 +24,17 @@ def update_transfer_data_ownership(transfer_data_item, target_obj: bpy.types.Obj
) )
def apply_transfer_data(context, transfer_data_map): def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
"""Apply all transfer data from transfer data map onto objects.
Copies any transfer data owned by local layer onto objects owned by external layers.
Applies transfer data from external layers onto objects owned by local layers
Transfer_data_map is generated by class 'AssetTransferMapping'
Args:
context (bpy.types.Context): context of .blend file
transfer_data_map: Map generated by class AssetTransferMapping
"""
for name in transfer_data_map: for name in transfer_data_map:
transfer_data = transfer_data_map[name] transfer_data = transfer_data_map[name]
item = transfer_data[0] item = transfer_data[0]
@ -38,18 +56,43 @@ def apply_transfer_data(context, transfer_data_map):
if item.type == constants.MATERIAL_SLOT_KEY: if item.type == constants.MATERIAL_SLOT_KEY:
print(f"Transfering Data {constants.MATERIAL_SLOT_KEY}: {name}") print(f"Transfering Data {constants.MATERIAL_SLOT_KEY}: {name}")
transfer_functions.transfer_material_slot(item, target_obj) transfer_functions.transfer_material_slot(item, target_obj)
update_transfer_data_ownership( copy_transfer_data_ownership(
transfer_data_item=item, transfer_data_item=item,
target_obj=target_obj, target_obj=target_obj,
) )
def check_transfer_data_entry(ownership, key, td_type): def check_transfer_data_entry(
ownership: bpy.types.CollectionProperty, key: str, td_type: str
) -> set:
"""Verifies if transfer data entry exists
Args:
ownership (bpy.types.CollectionProperty): Transfer Data of an object
key (str): Name of item that is being verified
td_type (str): Type of transfer data
Returns:
set: Returns set of matches where name is found in ownership
"""
existing_items = [item.name for item in ownership if item.type == td_type] existing_items = [item.name for item in ownership if item.type == td_type]
return set([key]).intersection(set(existing_items)) return set([key]).intersection(set(existing_items))
def transfer_data_add_entry(ownership, name, td_type, task_layer_name): def transfer_data_add_entry(
ownership: bpy.types.CollectionProperty,
name: str,
td_type: str,
task_layer_name: str,
):
"""Add entry to transfer data ownership
Args:
ownership (bpy.types.CollectionProperty): Transfer Data of an object
name (str): Name of new transfer data item
td_type (str): Type of transfer data
task_layer_name (str): Name of current task layer
"""
item = ownership.add() item = ownership.add()
item.name = name item.name = name
item.owner = task_layer_name.upper() item.owner = task_layer_name.upper()