Asset Pipeline v2 #145
@ -60,6 +60,9 @@ class AssetTransferMapping:
|
||||
"""
|
||||
object_map: Dict[bpy.types.Object, bpy.types.Object] = {}
|
||||
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 local_obj.asset_id_owner in self._local_tls:
|
||||
external_obj = self._get_external_object(local_obj)
|
||||
@ -124,7 +127,7 @@ class AssetTransferMapping:
|
||||
|
||||
for obj in self._external_col.all_objects:
|
||||
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
|
||||
target_obj_name = asset_suffix.get_target_name(obj.name)
|
||||
target_obj = self._local_col.all_objects.get(target_obj_name)
|
||||
|
@ -11,7 +11,7 @@ from . import constants
|
||||
# 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
|
||||
to_remove = []
|
||||
for item in ownership:
|
||||
@ -27,15 +27,27 @@ def remove_old_ownership(obj, task_layer_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:
|
||||
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_material_slots(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:
|
||||
ownership = item.obj.transfer_data_ownership
|
||||
transfer_core.transfer_data_add_entry(
|
||||
|
@ -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"""
|
||||
|
||||
_temp_ownership = None
|
||||
_invalid_objs = []
|
||||
|
||||
save: bpy.props.BoolProperty(
|
||||
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):
|
||||
self._temp_ownership = context.scene.temp_transfer_data_ownership
|
||||
self._temp_ownership.clear()
|
||||
self._invalid_objs.clear()
|
||||
|
||||
local_col = context.scene.asset_status.asset_collection
|
||||
if not local_col:
|
||||
@ -41,7 +43,12 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
|
||||
if not task_layer_name:
|
||||
self.report({'ERROR'}, "Current File Name doesn't contain valid task layer")
|
||||
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
|
||||
if self.push:
|
||||
@ -56,6 +63,13 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
|
||||
row.prop(self, "pull")
|
||||
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:
|
||||
layout.label(text="No New Transfer Data found")
|
||||
else:
|
||||
@ -72,7 +86,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
|
||||
def execute(self, context: bpy.types.Context):
|
||||
# Find current task Layer
|
||||
ownership = context.scene.temp_transfer_data_ownership
|
||||
core.set_ownership(ownership)
|
||||
core.ownership_set(ownership)
|
||||
current_file = Path(bpy.data.filepath)
|
||||
task_layer_name = core.get_task_layer_name_from_file()
|
||||
if not task_layer_name:
|
||||
|
@ -21,6 +21,9 @@ def apply_transfer_data(context, transfer_data_map):
|
||||
transfer_data = transfer_data_map[name]
|
||||
item = transfer_data[0]
|
||||
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:
|
||||
print(f"Transfering Data {constants.VERTEX_GROUP_KEY}: {name}")
|
||||
transfer_functions.transfer_vertex_group(
|
||||
|
Loading…
Reference in New Issue
Block a user