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.
4 changed files with 55 additions and 2 deletions
Showing only changes of commit c7dd2a87db - Show all commits

View File

@ -44,6 +44,7 @@ class AssetTransferMapping:
self.object_map = self._gen_object_map() self.object_map = self._gen_object_map()
self.collection_map = self._gen_collection_map() self.collection_map = self._gen_collection_map()
self.transfer_data_map = self._gen_transfer_data_map() self.transfer_data_map = self._gen_transfer_data_map()
self.other_id_map = self._gen_other_id_map()
def _get_external_object(self, local_obj): def _get_external_object(self, local_obj):
external_obj_name = asset_suffix.get_target_name( external_obj_name = asset_suffix.get_target_name(
@ -205,3 +206,22 @@ class AssetTransferMapping:
) )
transfer_data_map[name] = map_item transfer_data_map[name] = map_item
return transfer_data_map return transfer_data_map
def _gen_other_id_map(self):
other_id_map: Dict[bpy.types.ID, bpy.types.ID] = {}
for local_id in core.get_other_ids(self._local_col):
external_id_name = asset_suffix.get_target_name(local_id.name)
id_storage = util.get_storage_of_id(local_id)
external_id = id_storage.get(external_id_name)
# TODO Check for conflicts
if (
local_id.asset_id_owner in self._local_tls
and local_id.asset_id_owner != "NONE"
):
if external_id:
other_id_map[external_id] = local_id
else:
if external_id:
other_id_map[local_id] = external_id
return other_id_map

View File

@ -9,6 +9,7 @@ from .asset_mapping import AssetTransferMapping
from . import constants, util from . import constants, util
from rigify.utils.misc import copy_attributes from rigify.utils.misc import copy_attributes
from bpy_extras.id_map_utils import get_id_reference_map, get_all_referenced_ids
def ownership_transfer_data_cleanup( def ownership_transfer_data_cleanup(
@ -192,6 +193,9 @@ def merge_task_layer(
for col in map.collection_map: for col in map.collection_map:
remap_user(col, map.collection_map[col]) remap_user(col, map.collection_map[col])
for id in map.other_id_map:
remap_user(id, map.other_id_map[id])
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
) )
@ -386,3 +390,24 @@ def find_drivers(drivers, target_type, target_name):
if f'{target_type}["{target_name}"]' in driver.data_path: if f'{target_type}["{target_name}"]' in driver.data_path:
found_drivers.append(driver) found_drivers.append(driver)
return found_drivers return found_drivers
def get_other_ids(collection): # TODO find better name
ref_map = get_id_reference_map()
all_ids_of_coll = get_all_referenced_ids(collection, ref_map)
return [
id
for id in all_ids_of_coll
if type(id) == bpy.types.NodeGroup or type(id) == bpy.types.Image
]
def init_other_ids(scene):
other_ids = []
asset_pipe = scene.asset_pipeline
local_col = asset_pipe.asset_collection
for id in get_other_ids(local_col):
if id.asset_id_owner == 'NONE':
id.asset_id_owner = asset_pipe.task_layer_name
other_ids.append(id)
return other_ids

View File

@ -103,6 +103,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
_temp_transfer_data = None _temp_transfer_data = None
_invalid_objs = [] _invalid_objs = []
_other_ids = []
expand: bpy.props.BoolProperty( expand: bpy.props.BoolProperty(
name="Show New Transfer Data", name="Show New Transfer Data",
@ -144,6 +145,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
# TODO Remove Invalid Objs Explicitly, some will be auto removed but not all # TODO Remove Invalid Objs Explicitly, some will be auto removed but not all
self._invalid_objs = core.get_invalid_objects(local_col, context.scene) self._invalid_objs = core.get_invalid_objects(local_col, context.scene)
self._other_ids = core.init_other_ids(context.scene)
# Default behaviour is to pull before pushing # Default behaviour is to pull before pushing
if self.push: if self.push:
@ -165,6 +167,12 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
for obj in self._invalid_objs: for obj in self._invalid_objs:
box.label(text=obj.name, icon="OBJECT_DATA") box.label(text=obj.name, icon="OBJECT_DATA")
if len(self._other_ids) != 0:
box = layout.box()
box.label(text="New 'Other IDs' found")
for id in self._other_ids:
box.label(text=id.name)
if len(self._temp_transfer_data) == 0: if len(self._temp_transfer_data) == 0:
layout.label(text="No New Transfer Data found") layout.label(text="No New Transfer Data found")
else: else:

View File

@ -92,7 +92,7 @@ def register():
type=AssetTransferData type=AssetTransferData
) )
bpy.types.Scene.asset_pipeline = bpy.props.PointerProperty(type=AssetPipeline) bpy.types.Scene.asset_pipeline = bpy.props.PointerProperty(type=AssetPipeline)
bpy.types.Object.asset_id_owner = bpy.props.EnumProperty( bpy.types.ID.asset_id_owner = bpy.props.EnumProperty(
name="ID Owner", name="ID Owner",
items=constants.TASK_LAYER_TYPES_ENUM_ITEMS, items=constants.TASK_LAYER_TYPES_ENUM_ITEMS,
) )
@ -103,4 +103,4 @@ def unregister():
bpy.utils.unregister_class(i) bpy.utils.unregister_class(i)
del bpy.types.Object.transfer_data_ownership del bpy.types.Object.transfer_data_ownership
del bpy.types.Scene.asset_pipeline del bpy.types.Scene.asset_pipeline
del bpy.types.Object.asset_id_owner del bpy.types.ID.asset_id_owner