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 39 additions and 7 deletions
Showing only changes of commit ce36223e29 - Show all commits

View File

@ -60,6 +60,9 @@ class AssetTransferMapping:
""" """
object_map: Dict[bpy.types.Object, bpy.types.Object] = {} object_map: Dict[bpy.types.Object, bpy.types.Object] = {}
for local_obj in self._local_col.all_objects: for local_obj in self._local_col.all_objects:
# Skip items with no owner
if local_obj.asset_id_owner == "NONE":
continue
# IF ITEM IS OWNED BY LOCAL TASK LAYERS # IF ITEM IS OWNED BY LOCAL TASK LAYERS
if local_obj.asset_id_owner in self._local_tls: if local_obj.asset_id_owner in self._local_tls:
external_obj = self._get_external_object(local_obj) external_obj = self._get_external_object(local_obj)
@ -124,7 +127,7 @@ class AssetTransferMapping:
for obj in self._external_col.all_objects: for obj in self._external_col.all_objects:
for item in obj.transfer_data_ownership: for item in obj.transfer_data_ownership:
if item.owner not in self._local_tls: if item.owner not in self._local_tls and item.owner != "NONE":
name = item.name + '_' + obj.name name = item.name + '_' + obj.name
target_obj_name = asset_suffix.get_target_name(obj.name) target_obj_name = asset_suffix.get_target_name(obj.name)
target_obj = self._local_col.all_objects.get(target_obj_name) target_obj = self._local_col.all_objects.get(target_obj_name)

View File

@ -11,7 +11,7 @@ from . import constants
# TODO Add UI to warn about un-assigned objects # TODO Add UI to warn about un-assigned objects
def remove_old_ownership(obj, task_layer_name): def ownership_cleanup(obj, task_layer_name):
ownership = obj.transfer_data_ownership ownership = obj.transfer_data_ownership
to_remove = [] to_remove = []
for item in ownership: for item in ownership:
@ -27,15 +27,27 @@ def remove_old_ownership(obj, task_layer_name):
ownership.remove(ownership.keys().index(name)) ownership.remove(ownership.keys().index(name))
def get_ownership(local_col: str, task_layer_name: str, new_transfer_data): def ownership_get(local_col: str, task_layer_name: str, new_transfer_data):
invalid_objs = []
task_layer_col_name = get_enum_item(constants.TASK_LAYER_ITEMS, task_layer_name)[1]
task_layer_col = local_col.children.get(task_layer_col_name)
for obj in local_col.all_objects: for obj in local_col.all_objects:
remove_old_ownership(obj, task_layer_name) # Mark Asset ID Owner for objects in the current task layers collection
if obj.asset_id_owner == "NONE" and obj in list(task_layer_col.all_objects):
obj.asset_id_owner = task_layer_name
# Skip items that have no owner
if obj.asset_id_owner == "NONE":
invalid_objs.append(obj)
continue
ownership_cleanup(obj, task_layer_name)
transfer_functions.get_vertex_groups(obj, task_layer_name, new_transfer_data) transfer_functions.get_vertex_groups(obj, task_layer_name, new_transfer_data)
transfer_functions.get_material_slots(obj, task_layer_name, new_transfer_data) transfer_functions.get_material_slots(obj, task_layer_name, new_transfer_data)
transfer_functions.get_modifiers(obj, task_layer_name, new_transfer_data) transfer_functions.get_modifiers(obj, task_layer_name, new_transfer_data)
return invalid_objs
def set_ownership(new_transfer_data):
def ownership_set(new_transfer_data):
for item in new_transfer_data: for item in new_transfer_data:
ownership = item.obj.transfer_data_ownership ownership = item.obj.transfer_data_ownership
transfer_core.transfer_data_add_entry( transfer_core.transfer_data_add_entry(

View File

@ -12,6 +12,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
bl_description = """Push and or Pull data from Published file. Will prompt with a list of new data found before pushing""" bl_description = """Push and or Pull data from Published file. Will prompt with a list of new data found before pushing"""
_temp_ownership = None _temp_ownership = None
_invalid_objs = []
save: bpy.props.BoolProperty( save: bpy.props.BoolProperty(
name="Save Current File", name="Save Current File",
@ -32,6 +33,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
def invoke(self, context: bpy.types.Context, event: bpy.types.Event): def invoke(self, context: bpy.types.Context, event: bpy.types.Event):
self._temp_ownership = context.scene.temp_transfer_data_ownership self._temp_ownership = context.scene.temp_transfer_data_ownership
self._temp_ownership.clear() self._temp_ownership.clear()
self._invalid_objs.clear()
local_col = context.scene.asset_status.asset_collection local_col = context.scene.asset_status.asset_collection
if not local_col: if not local_col:
@ -41,7 +43,12 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
if not task_layer_name: if not task_layer_name:
self.report({'ERROR'}, "Current File Name doesn't contain valid task layer") self.report({'ERROR'}, "Current File Name doesn't contain valid task layer")
return {'CANCELLED'} return {'CANCELLED'}
core.get_ownership(local_col, task_layer_name, self._temp_ownership)
self._invalid_objs = core.ownership_get(
local_col,
task_layer_name,
self._temp_ownership,
)
# Default behaviour is to pull before pushing # Default behaviour is to pull before pushing
if self.push: if self.push:
@ -56,6 +63,13 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
row.prop(self, "pull") row.prop(self, "pull")
row.prop(self, "save") row.prop(self, "save")
if len(self._invalid_objs) != 0:
box = layout.box()
box.alert = True
box.label(text="Sync will clear Invalid Objects:", icon="ERROR")
for obj in self._invalid_objs:
box.label(text=obj.name, icon="OBJECT_DATA")
if len(self._temp_ownership) == 0: if len(self._temp_ownership) == 0:
layout.label(text="No New Transfer Data found") layout.label(text="No New Transfer Data found")
else: else:
@ -72,7 +86,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
def execute(self, context: bpy.types.Context): def execute(self, context: bpy.types.Context):
# Find current task Layer # Find current task Layer
ownership = context.scene.temp_transfer_data_ownership ownership = context.scene.temp_transfer_data_ownership
core.set_ownership(ownership) core.ownership_set(ownership)
current_file = Path(bpy.data.filepath) current_file = Path(bpy.data.filepath)
task_layer_name = core.get_task_layer_name_from_file() task_layer_name = core.get_task_layer_name_from_file()
if not task_layer_name: if not task_layer_name:

View File

@ -21,6 +21,9 @@ def apply_transfer_data(context, transfer_data_map):
transfer_data = transfer_data_map[name] transfer_data = transfer_data_map[name]
item = transfer_data[0] item = transfer_data[0]
target_obj = transfer_data[1] target_obj = transfer_data[1]
if target_obj is None:
print(f"Failed to Transfer data for {item.id_data.name}")
continue
if item.type == constants.VERTEX_GROUP_KEY: if item.type == constants.VERTEX_GROUP_KEY:
print(f"Transfering Data {constants.VERTEX_GROUP_KEY}: {name}") print(f"Transfering Data {constants.VERTEX_GROUP_KEY}: {name}")
transfer_functions.transfer_vertex_group( transfer_functions.transfer_vertex_group(