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 27 additions and 24 deletions
Showing only changes of commit 48fdd9100a - Show all commits

View File

@ -3,6 +3,7 @@ from typing import Dict, Set
from . import util
from . import asset_suffix
from . import constants
class AssetTransferMapping:
@ -90,22 +91,30 @@ class AssetTransferMapping:
coll_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
# Link top most parents.
coll_map[self._local_col] = self._external_col
# coll_map[self._local_col] = self._external_col
# Link up all children.
for s_coll in util.traverse_collection_tree(self._local_col):
# assert source_obj.name.endswith(self._source_merge_coll.suffix)
# Get user facing names for local task layers
local_tl_names = [
item[1] for item in constants.TASK_LAYER_ITEMS if item[0] in self._local_tls
]
# Replace source object suffix with target suffix to get target object.
external_col = asset_suffix.get_target_name(s_coll.name)
t_coll = bpy.data.collections.get(external_col)
if t_coll:
coll_map[s_coll] = t_coll
else:
print(
f"Failed to find match collection {s_coll.name} for {external_col}"
for local_task_layer_col in self._local_col.children:
if (
asset_suffix.get_basename(local_task_layer_col.name)
not in local_tl_names
):
# Replace source object suffix with target suffix to get target object.
external_col_name = asset_suffix.get_target_name(
local_task_layer_col.name
)
self._no_match_source_colls.add(s_coll)
external_col = bpy.data.collections.get(external_col_name)
if external_col:
coll_map[local_task_layer_col] = external_col
else:
print(
f"Failed to find match collection {local_task_layer_col.name} for {external_col_name}"
)
self._no_match_source_colls.add(local_task_layer_col)
all_tgt_colls = set(self._external_col.children_recursive)
all_tgt_colls.add(self._external_col)

View File

@ -46,18 +46,17 @@ def merge_task_layer(
local_col = bpy.data.collections[f"{col_base_name}.{local_suffix}"]
external_col = bpy.data.collections[f"{col_base_name}.{external_suffix}"]
# TODO Make sure we preserve the collection hirearchies instead of having one flat col
# TODO Consider re-adding the TARGET collection
map = AssetTransferMapping(local_col, external_col, local_tls)
# Find Transfer Data
transfer_data = []
for obj in external_col.objects:
for obj in external_col.all_objects:
for item in obj.transfer_data_ownership:
if item.owner not in local_tls:
transfer_data.append(item)
for obj in local_col.objects:
for obj in local_col.all_objects:
for item in obj.transfer_data_ownership:
if item.owner in local_tls:
transfer_data.append(item)
@ -65,18 +64,13 @@ def merge_task_layer(
target_objs = [map.object_map[obj] for obj in map.object_map]
transferable_data.apply_transfer_data(context, transfer_data, target_objs)
for old_obj in map.local_obj_to_remove:
# TODO Support collection hirearchies
local_col.objects.unlink(old_obj)
for new_obj in map.external_obj_to_add:
# TODO Support collection hirearchies
local_col.objects.link(new_obj)
for source_obj in map.object_map:
target_obj = map.object_map[source_obj]
remap_user(source_obj, target_obj)
for col in map.collection_map:
remap_user(col, map.collection_map[col])
bpy.ops.outliner.orphans_purge(
do_local_ids=True, do_linked_ids=False, do_recursive=True
)