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 44 additions and 36 deletions
Showing only changes of commit 531bfa23a9 - Show all commits

View File

@ -25,21 +25,21 @@ 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): def get_ownership(local_col: str, task_layer_name: str, new_transfer_data):
# TODO Collect ID owners of newly added objects and set during set_ownership # TODO Collect ID owners of newly added objects and set during set_ownership
new_transfer_data: Dict[bpy.props.CollectionProperty, str, str, str, str] = {}
for obj in local_col.all_objects: for obj in local_col.all_objects:
remove_old_ownership(obj, task_layer_name) remove_old_ownership(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 new_transfer_data
def set_ownership(new_transfer_data): def set_ownership(new_transfer_data):
for data in new_transfer_data: for item in new_transfer_data:
item = new_transfer_data[data] ownership = item.obj.transfer_data_ownership
transfer_core.transfer_data_add_entry(item[0], item[1], item[2], item[3]) transfer_core.transfer_data_add_entry(
ownership, item.name, item.type, item.owner
)
def remap_user(source_datablock: bpy.data, target_datablock: bpy.data): def remap_user(source_datablock: bpy.data, target_datablock: bpy.data):

View File

@ -34,6 +34,9 @@ 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):
ownership = context.scene.temp_transfer_data_ownership
ownership.clear()
local_col = bpy.data.collections.get(get_parent_col_name()) local_col = bpy.data.collections.get(get_parent_col_name())
if not local_col: if not local_col:
self.report({'ERROR'}, "Top level collection could not be found") self.report({'ERROR'}, "Top level collection could not be found")
@ -42,7 +45,7 @@ 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'}
self._new_transfer_data = core.get_ownership(local_col, task_layer_name) core.get_ownership(local_col, task_layer_name, ownership)
# Default behaviour is to pull before pushing # Default behaviour is to pull before pushing
if self.push: if self.push:
@ -83,7 +86,8 @@ 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
core.set_ownership(self._new_transfer_data) ownership = context.scene.temp_transfer_data_ownership
core.set_ownership(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

@ -28,10 +28,19 @@ class ASSETOWNERSHIP(bpy.types.PropertyGroup):
) )
classes = ( class TEMP_ASSETOWNERSHIP(bpy.types.PropertyGroup):
ASSETOWNERSHIP, owner: bpy.props.EnumProperty(
ASSET_STATUS, name="Transfer Data Owner",
) items=constants.TASK_LAYER_ITEMS,
)
type: bpy.props.EnumProperty(
name="Transfer Data Type",
items=constants.TRANSFER_DATA_TYPES,
)
obj: bpy.props.PointerProperty(type=bpy.types.Object)
classes = (ASSETOWNERSHIP, ASSET_STATUS, TEMP_ASSETOWNERSHIP)
def register(): def register():
@ -40,6 +49,9 @@ def register():
bpy.types.Object.transfer_data_ownership = bpy.props.CollectionProperty( bpy.types.Object.transfer_data_ownership = bpy.props.CollectionProperty(
type=ASSETOWNERSHIP type=ASSETOWNERSHIP
) )
bpy.types.Scene.temp_transfer_data_ownership = bpy.props.CollectionProperty(
type=TEMP_ASSETOWNERSHIP
)
bpy.types.Scene.asset_status = bpy.props.PointerProperty(type=ASSET_STATUS) bpy.types.Scene.asset_status = bpy.props.PointerProperty(type=ASSET_STATUS)
bpy.types.Object.asset_id_owner = bpy.props.EnumProperty( bpy.types.Object.asset_id_owner = bpy.props.EnumProperty(
name="ID Owner", name="ID Owner",
@ -51,3 +63,4 @@ def unregister():
for i in classes: for i in classes:
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.temp_transfer_data_ownership

View File

@ -24,14 +24,11 @@ def get_vertex_groups(obj, task_layer_name, new_transfer_data):
ownership, vertex_group.name, constants.VERTEX_GROUP_KEY ownership, vertex_group.name, constants.VERTEX_GROUP_KEY
) )
if len(matches) == 0: if len(matches) == 0:
# NEED UNIQUE NAME INCASE OF DUPLICATES item = new_transfer_data.add()
name = vertex_group.name + '_' + obj.name item.name = vertex_group.name
new_transfer_data[name] = ( item.owner = task_layer_name
ownership, item.type = constants.VERTEX_GROUP_KEY
vertex_group.name, item.obj = obj
constants.VERTEX_GROUP_KEY,
task_layer_name,
)
def transfer_vertex_group( def transfer_vertex_group(
@ -76,14 +73,11 @@ def get_modifiers(obj, task_layer_name, new_transfer_data):
ownership, mod.name, constants.MODIFIER_KEY ownership, mod.name, constants.MODIFIER_KEY
) )
if len(matches) == 0: if len(matches) == 0:
# NEED UNIQUE NAME INCASE OF DUPLICATES item = new_transfer_data.add()
name = mod.name + '_' + obj.name item.name = mod.name
new_transfer_data[name] = ( item.owner = task_layer_name
ownership, item.type = constants.MODIFIER_KEY
mod.name, item.obj = obj
constants.MODIFIER_KEY,
task_layer_name,
)
def transfer_modifier(item, obj_target): def transfer_modifier(item, obj_target):
@ -159,14 +153,11 @@ def get_material_slots(obj, task_layer_name, new_transfer_data):
ownership, slot.name, constants.MATERIAL_SLOT_KEY ownership, slot.name, constants.MATERIAL_SLOT_KEY
) )
if len(matches) == 0: if len(matches) == 0:
# NEED UNIQUE NAME INCASE OF DUPLICATES item = new_transfer_data.add()
name = slot.name + '_' + obj.name item.name = slot.name
new_transfer_data[name] = ( item.owner = task_layer_name
ownership, item.type = constants.MATERIAL_SLOT_KEY
slot.name, item.obj = obj
constants.MATERIAL_SLOT_KEY,
task_layer_name,
)
def transfer_material_slot(item, obj_target): def transfer_material_slot(item, obj_target):