Asset Pipeline v2 #145
@ -25,10 +25,12 @@ class AssetTransferMapping:
|
||||
external_coll: bpy.types.Collection,
|
||||
local_tls: Set[str],
|
||||
):
|
||||
self._local_col = local_coll
|
||||
self._local_top_col = local_coll
|
||||
self._external_col = external_coll
|
||||
self._local_tls = local_tls
|
||||
|
||||
self.external_col_to_remove: Set[bpy.types.Object] = set()
|
||||
self.external_col_to_add: Set[bpy.types.Object] = set()
|
||||
self.external_obj_to_add: Set[bpy.types.Object] = set()
|
||||
self._no_match_source_objs: Set[bpy.types.Object] = set()
|
||||
|
||||
@ -67,7 +69,7 @@ class AssetTransferMapping:
|
||||
target collection. Uses suffixes to match them up.
|
||||
"""
|
||||
object_map: Dict[bpy.types.Object, bpy.types.Object] = {}
|
||||
for local_obj in self._local_col.all_objects:
|
||||
for local_obj in self._local_top_col.all_objects:
|
||||
# Skip items with no owner
|
||||
if local_obj.asset_id_owner == "NONE":
|
||||
continue
|
||||
@ -84,7 +86,7 @@ class AssetTransferMapping:
|
||||
|
||||
# Find new objects to add to local_col
|
||||
for external_obj in self._external_col.all_objects:
|
||||
local_col_objs = self._local_col.all_objects
|
||||
local_col_objs = self._local_top_col.all_objects
|
||||
obj = local_col_objs.get(get_target_name(external_obj.name))
|
||||
if not obj and external_obj.asset_id_owner not in self._local_tls:
|
||||
self.external_obj_to_add.add(external_obj)
|
||||
@ -103,19 +105,35 @@ class AssetTransferMapping:
|
||||
if tl_key in self._local_tls
|
||||
]
|
||||
|
||||
for local_task_layer_col in self._local_col.children:
|
||||
if get_basename(local_task_layer_col.name) not in local_tl_names:
|
||||
for local_task_layer_col in self._local_top_col.children:
|
||||
if local_task_layer_col.asset_id_owner not in self._local_tls:
|
||||
# Replace source object suffix with target suffix to get target object.
|
||||
external_col_name = get_target_name(local_task_layer_col.name)
|
||||
external_col = bpy.data.collections.get(external_col_name)
|
||||
if external_col:
|
||||
coll_map[local_task_layer_col] = external_col
|
||||
local_col = bpy.data.collections.get(external_col_name)
|
||||
if local_col:
|
||||
coll_map[local_task_layer_col] = local_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)
|
||||
|
||||
external_top_col_name = get_target_name(self._local_top_col.name)
|
||||
external_top_col = bpy.data.collections.get(external_top_col_name)
|
||||
|
||||
# TODO Refactor
|
||||
for external_col in external_top_col.children:
|
||||
local_col_name = get_target_name(external_col.name)
|
||||
local_col = bpy.data.collections.get(local_col_name)
|
||||
if not local_col and external_col.asset_id_owner not in self._local_tls:
|
||||
self.external_col_to_add.add(external_col)
|
||||
|
||||
for local_col in self._local_top_col.children:
|
||||
external_col_name = get_target_name(local_col.name)
|
||||
external_col = bpy.data.collections.get(external_col_name)
|
||||
if not external_col and local_col.asset_id_owner not in self._local_tls:
|
||||
self.external_col_to_remove.add(local_col)
|
||||
|
||||
all_tgt_colls = set(self._external_col.children_recursive)
|
||||
all_tgt_colls.add(self._external_col)
|
||||
match_target_colls = set([coll for coll in coll_map.values()])
|
||||
@ -194,7 +212,7 @@ class AssetTransferMapping:
|
||||
|
||||
def _gen_shared_id_map(self):
|
||||
shared_id_map: Dict[bpy.types.ID, bpy.types.ID] = {}
|
||||
for local_id in get_shared_ids(self._local_col):
|
||||
for local_id in get_shared_ids(self._local_top_col):
|
||||
external_id_name = get_target_name(local_id.name)
|
||||
id_storage = get_storage_of_id(local_id)
|
||||
external_id = id_storage.get(external_id_name)
|
||||
|
@ -75,6 +75,9 @@ def ownership_get(
|
||||
continue
|
||||
ownership_transfer_data_cleanup(obj, task_layer_key)
|
||||
init_transfer_data(scene, obj)
|
||||
for col in asset_pipe.asset_collection.children:
|
||||
if col.asset_id_owner == "NONE":
|
||||
col.asset_id_owner = task_layer_key
|
||||
|
||||
|
||||
def ownership_set(temp_transfer_data: bpy.types.CollectionProperty) -> None:
|
||||
@ -204,6 +207,12 @@ def merge_task_layer(
|
||||
for col in map.collection_map:
|
||||
remap_user(col, map.collection_map[col])
|
||||
|
||||
for col in map.external_col_to_add:
|
||||
local_col.children.link(col)
|
||||
|
||||
for col in map.external_col_to_remove:
|
||||
local_col.children.unlink(col)
|
||||
|
||||
for id in map.shared_id_map:
|
||||
remap_user(id, map.shared_id_map[id])
|
||||
|
||||
|
@ -83,7 +83,9 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
|
||||
continue
|
||||
col_name = get_task_layer_col_name(task_layer_key)
|
||||
bpy.data.collections.new(col_name)
|
||||
asset_col.children.link(bpy.data.collections.get(col_name))
|
||||
new_col = bpy.data.collections.get(col_name)
|
||||
asset_col.children.link(new_col)
|
||||
new_col.asset_id_owner = task_layer_key
|
||||
|
||||
starting_file = ""
|
||||
# Create the file for each task layer.
|
||||
|
@ -55,8 +55,15 @@ class ASSETPIPE_ownership_inspector(bpy.types.Panel):
|
||||
if not asset_pipe.is_asset_pipeline_file:
|
||||
layout.label(text="Open valid 'Asset Pipeline' file", icon="ERROR")
|
||||
return
|
||||
|
||||
if context.collection in list(asset_pipe.asset_collection.children):
|
||||
layout.label(
|
||||
text=f"{context.collection.name} : '{context.collection.asset_id_owner}' (Active Collection)",
|
||||
icon="OUTLINER_COLLECTION",
|
||||
)
|
||||
|
||||
if not context.active_object:
|
||||
layout.label(text="Set an Active Object to Inspect")
|
||||
layout.label(text="Set an Active Object to Inspect", icon="OBJECT_DATA")
|
||||
return
|
||||
obj = context.active_object
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
|
Loading…
Reference in New Issue
Block a user