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 153120bd9a - Show all commits

View File

@ -3,7 +3,7 @@ import bpy
from . import transfer_functions
def update_transfer_data_ownership(transfer_data_item, target_obj):
def update_transfer_data_ownership(transfer_data_item, target_obj: bpy.types.Object):
transfer_data_ownership = target_obj.transfer_data_ownership
transfer_items_names = [item.name for item in transfer_data_ownership]
if transfer_data_item.name not in transfer_items_names:
@ -14,7 +14,12 @@ def update_transfer_data_ownership(transfer_data_item, target_obj):
new_item.id = transfer_data_item.id
def apply_transfer_data(context, transfer_data_list, target_col, source_task_layer):
def apply_transfer_data(
context: bpy.types.Context,
transfer_data_list,
target_col: bpy.types.Collection,
source_task_layer: str,
):
for item in transfer_data_list:
for target_obj in target_col.objects:
if target_obj.name.split(".")[0] == item.id.name.split(".")[0]:
@ -32,6 +37,28 @@ def apply_transfer_data(context, transfer_data_list, target_col, source_task_lay
)
def update_task_layer_objects(
target_col: bpy.types.Collection,
transfer_objs: list[bpy.types.Object],
target_tl: str,
):
# TODO CHECK WHY MAKE DUPLICATES
# Delete existing root OBJ
for target_obj in target_col.objects:
obj_root_name = target_obj.name.split('.')[0]
for push_obj in transfer_objs:
if f"{obj_root_name}.{target_tl}" in push_obj.name:
bpy.data.objects.remove(target_obj)
# Link new obj to collection
for transfer_obj in transfer_objs:
obj_root_name = transfer_obj.name.split('.')[0]
new_obj = transfer_obj.copy()
new_obj.data = transfer_obj.data.copy()
new_obj.name = f"{obj_root_name}.{target_tl}"
target_col.objects.link(new_obj)
def push_task_layer(
context: bpy.types.Collection,
source_col: bpy.types.Collection,
@ -50,25 +77,7 @@ def push_task_layer(
if item.owner == source_tl:
transfer_data_list.append(item)
# Delete existing root OBJ
for target_obj in target_col.objects:
obj_root_name = target_obj.name.split('.')[0]
for push_obj in transfer_objs:
if f"{obj_root_name}.{target_tl}" in push_obj.name:
bpy.data.objects.remove(target_obj)
# Link new obj to collection
for transfer_obj in transfer_objs:
obj_root_name = transfer_obj.name.split('.')[0]
new_obj = transfer_obj.copy()
new_obj.data = transfer_obj.data.copy()
new_obj.name = f"{obj_root_name}.{target_tl}"
target_col.objects.link(new_obj)
# Cosmetically move the obj for easier organization
# TODO Remove this step
new_obj.location[0] = 0
new_obj.location[2] = 3
update_task_layer_objects(target_col, transfer_objs, target_tl)
# Move transferrable data onto obj owned by others
apply_transfer_data(context, transfer_data_list, target_col, source_tl)
@ -82,32 +91,17 @@ def pull_task_layer(
target_tl: str,
):
# Find Obj owned by other Current Task Layer
pull_objs = []
transfer_objs = []
transfer_data = []
for obj in source_col.objects:
if obj.asset_id_owner != source_tl:
pull_objs.append(obj)
if obj.asset_id_owner != target_tl:
transfer_objs.append(obj)
# Find Transfer-Data in other Task Layers
for item in obj.transfer_data_ownership:
if item.owner != source_tl:
transfer_data.append(item)
# TODO FIX SO I CAN REPLACE OBJ NOT JUST UPDATE IT
# Delete existing root OBJ
# for obj in publish_col.objects:
# obj_root_name = obj.name.split('.')[0]
# for pull_obj in pull_objs:
# if f"{obj_root_name}.{current_task_layer}" == pull_obj.name:
# bpy.data.objects.remove(obj)
# # # Link new obj to collection
# for obj in pull_objs:
# obj_root_name = obj.name.split('.')[0]
# new_obj = obj.copy()
# new_obj.data = obj.data.copy()
# new_obj.name = f"{obj_root_name}.{target_tl}"
# target_col.objects.link(new_obj)
update_task_layer_objects(target_col, transfer_objs, target_tl)
# TODO Move transferrable data onto obj owned by others
apply_transfer_data(context, transfer_data, target_col, source_tl)