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 db3e076e52 - Show all commits

View File

@ -3,6 +3,8 @@ import bpy
from . import transfer_functions, asset_suffix from . import transfer_functions, asset_suffix
from pathlib import Path from pathlib import Path
# TODO refactor merge functions into a class based on AssetBuilder class of Asset Pipeline 1
def update_transfer_data_ownership(transfer_data_item, target_obj: bpy.types.Object): def update_transfer_data_ownership(transfer_data_item, target_obj: bpy.types.Object):
transfer_data_ownership = target_obj.transfer_data_ownership transfer_data_ownership = target_obj.transfer_data_ownership
@ -43,6 +45,7 @@ def update_task_layer_objects(
transfer_objs: list[bpy.types.Object], transfer_objs: list[bpy.types.Object],
): ):
# Link new obj to collection # Link new obj to collection
# TODO implement remap ids
for transfer_obj in transfer_objs: for transfer_obj in transfer_objs:
obj_root_name = transfer_obj.name obj_root_name = transfer_obj.name
transfer_obj.name = f"{obj_root_name}" transfer_obj.name = f"{obj_root_name}"
@ -75,37 +78,31 @@ def merge_task_layer(
# Find Obj owned by other Current Task Layer # Find Obj owned by other Current Task Layer
source_transfer_objs = [] source_transfer_objs = []
source_transfer_data = [] transfer_data = []
for obj in source_col.objects: for obj in source_col.objects:
if obj.asset_id_owner not in local_tls: if obj.asset_id_owner not in local_tls:
source_transfer_objs.append(obj) source_transfer_objs.append(obj)
# Find Transfer-Data in other Task Layers # Find Transfer-Data in other Task Layers
for item in obj.transfer_data_ownership: for item in obj.transfer_data_ownership:
if item.owner not in local_tls: if item.owner not in local_tls:
source_transfer_data.append(item) transfer_data.append(item)
update_task_layer_objects(target_col, source_transfer_objs) update_task_layer_objects(target_col, source_transfer_objs)
local_objs = [] local_objs = []
local_transfer_data = []
for obj in local_col.objects: for obj in local_col.objects:
if obj.asset_id_owner in local_tls: if obj.asset_id_owner in local_tls:
local_objs.append(obj) local_objs.append(obj)
# Find Transfer-Data in other Task Layers # Find Transfer-Data in other Task Layers
for item in obj.transfer_data_ownership: for item in obj.transfer_data_ownership:
if item.owner in local_tls: if item.owner in local_tls:
local_transfer_data.append(item) transfer_data.append(item)
update_task_layer_objects(target_col, local_objs) update_task_layer_objects(target_col, local_objs)
apply_transfer_data( apply_transfer_data(
context, context,
source_transfer_data, transfer_data,
target_col, target_col,
) )
apply_transfer_data(
context,
local_transfer_data,
target_col,
) # TODO test if only one list of transfer data is needed
bpy.ops.outliner.orphans_purge( bpy.ops.outliner.orphans_purge(
do_local_ids=True, do_linked_ids=False, do_recursive=True do_local_ids=True, do_linked_ids=False, do_recursive=True
) )