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))
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
new_transfer_data: Dict[bpy.props.CollectionProperty, str, str, str, str] = {}
for obj in local_col.all_objects:
remove_old_ownership(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 new_transfer_data
def set_ownership(new_transfer_data):
for data in new_transfer_data:
item = new_transfer_data[data]
transfer_core.transfer_data_add_entry(item[0], item[1], item[2], item[3])
for item in new_transfer_data:
ownership = item.obj.transfer_data_ownership
transfer_core.transfer_data_add_entry(
ownership, item.name, item.type, item.owner
)
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):
ownership = context.scene.temp_transfer_data_ownership
ownership.clear()
local_col = bpy.data.collections.get(get_parent_col_name())
if not local_col:
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:
self.report({'ERROR'}, "Current File Name doesn't contain valid task layer")
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
if self.push:
@ -83,7 +86,8 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
def execute(self, context: bpy.types.Context):
# 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)
task_layer_name = core.get_task_layer_name_from_file()
if not task_layer_name:

View File

@ -28,10 +28,19 @@ class ASSETOWNERSHIP(bpy.types.PropertyGroup):
)
classes = (
ASSETOWNERSHIP,
ASSET_STATUS,
class TEMP_ASSETOWNERSHIP(bpy.types.PropertyGroup):
owner: bpy.props.EnumProperty(
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():
@ -40,6 +49,9 @@ def register():
bpy.types.Object.transfer_data_ownership = bpy.props.CollectionProperty(
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.Object.asset_id_owner = bpy.props.EnumProperty(
name="ID Owner",
@ -51,3 +63,4 @@ def unregister():
for i in classes:
bpy.utils.unregister_class(i)
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
)
if len(matches) == 0:
# NEED UNIQUE NAME INCASE OF DUPLICATES
name = vertex_group.name + '_' + obj.name
new_transfer_data[name] = (
ownership,
vertex_group.name,
constants.VERTEX_GROUP_KEY,
task_layer_name,
)
item = new_transfer_data.add()
item.name = vertex_group.name
item.owner = task_layer_name
item.type = constants.VERTEX_GROUP_KEY
item.obj = obj
def transfer_vertex_group(
@ -76,14 +73,11 @@ def get_modifiers(obj, task_layer_name, new_transfer_data):
ownership, mod.name, constants.MODIFIER_KEY
)
if len(matches) == 0:
# NEED UNIQUE NAME INCASE OF DUPLICATES
name = mod.name + '_' + obj.name
new_transfer_data[name] = (
ownership,
mod.name,
constants.MODIFIER_KEY,
task_layer_name,
)
item = new_transfer_data.add()
item.name = mod.name
item.owner = task_layer_name
item.type = constants.MODIFIER_KEY
item.obj = obj
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
)
if len(matches) == 0:
# NEED UNIQUE NAME INCASE OF DUPLICATES
name = slot.name + '_' + obj.name
new_transfer_data[name] = (
ownership,
slot.name,
constants.MATERIAL_SLOT_KEY,
task_layer_name,
)
item = new_transfer_data.add()
item.name = slot.name
item.owner = task_layer_name
item.type = constants.MATERIAL_SLOT_KEY
item.obj = obj
def transfer_material_slot(item, obj_target):