Asset Pipeline v2 #145
@ -40,7 +40,7 @@ def merge_task_layer(
|
|||||||
external_col = bpy.data.collections[f"{col_base_name}.{external_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 Make sure we preserve the collection hirearchies instead of having one flat col
|
||||||
mapping_task_target = AssetTransferMapping(local_col, external_col, local_tls)
|
map = AssetTransferMapping(local_col, external_col, local_tls)
|
||||||
|
|
||||||
# Find Transfer Data
|
# Find Transfer Data
|
||||||
transfer_data = []
|
transfer_data = []
|
||||||
@ -54,19 +54,19 @@ def merge_task_layer(
|
|||||||
if item.owner in local_tls:
|
if item.owner in local_tls:
|
||||||
transfer_data.append(item)
|
transfer_data.append(item)
|
||||||
|
|
||||||
transferable_data.apply_transfer_data(context, transfer_data, local_col)
|
target_objs = [map.object_map[obj] for obj in map.object_map]
|
||||||
transferable_data.apply_transfer_data(context, transfer_data, external_col)
|
transferable_data.apply_transfer_data(context, transfer_data, target_objs)
|
||||||
|
|
||||||
for old_obj in mapping_task_target.local_obj_to_remove:
|
for old_obj in map.local_obj_to_remove:
|
||||||
# TODO Support collection hirearchies
|
# TODO Support collection hirearchies
|
||||||
local_col.objects.unlink(old_obj)
|
local_col.objects.unlink(old_obj)
|
||||||
|
|
||||||
for new_obj in mapping_task_target.external_obj_to_add:
|
for new_obj in map.external_obj_to_add:
|
||||||
# TODO Support collection hirearchies
|
# TODO Support collection hirearchies
|
||||||
local_col.objects.link(new_obj)
|
local_col.objects.link(new_obj)
|
||||||
|
|
||||||
for source_obj in mapping_task_target._object_map:
|
for source_obj in map.object_map:
|
||||||
target_obj = mapping_task_target._object_map[source_obj]
|
target_obj = map.object_map[source_obj]
|
||||||
datablocks.remap_user(source_obj, target_obj)
|
datablocks.remap_user(source_obj, target_obj)
|
||||||
|
|
||||||
bpy.ops.outliner.orphans_purge(
|
bpy.ops.outliner.orphans_purge(
|
||||||
|
@ -17,10 +17,10 @@ def update_transfer_data_ownership(transfer_data_item, target_obj: bpy.types.Obj
|
|||||||
def apply_transfer_data(
|
def apply_transfer_data(
|
||||||
context: bpy.types.Context,
|
context: bpy.types.Context,
|
||||||
transfer_data_list,
|
transfer_data_list,
|
||||||
target_col: bpy.types.Collection,
|
target_objs: set[bpy.types.Object],
|
||||||
):
|
):
|
||||||
for item in transfer_data_list:
|
for item in transfer_data_list:
|
||||||
for target_obj in target_col.objects:
|
for target_obj in target_objs:
|
||||||
if asset_suffix.get_basename(target_obj.name) == asset_suffix.get_basename(
|
if asset_suffix.get_basename(target_obj.name) == asset_suffix.get_basename(
|
||||||
item.id.name
|
item.id.name
|
||||||
):
|
):
|
||||||
|
Loading…
Reference in New Issue
Block a user