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.
9 changed files with 168 additions and 159 deletions
Showing only changes of commit 26bdbcb3af - Show all commits

View File

@ -53,8 +53,8 @@ TRANSFER_DATA_TYPES_ENUM_ITEMS = [
for i, tup in enumerate(TRANSFER_DATA_TYPES.items()) for i, tup in enumerate(TRANSFER_DATA_TYPES.items())
] ]
MATERIAL_TRANSFER_INFO_NAME = "All Material Slots" MATERIAL_TRANSFER_DATA_ITEM_NAME = "All Material Slots"
PARENT_TRANSFER_INFO_NAME = "Parent Relationship" PARENT_TRANSFER_DATA_ITEM_NAME = "Parent Relationship"
PUBLISH_TYPES = [ PUBLISH_TYPES = [
( (

View File

@ -129,41 +129,41 @@ class AssetTransferMapping:
return coll_map return coll_map
def _get_transfer_data_map_item(self, obj, target_obj, transfer_info): def _get_transfer_data_map_item(self, obj, target_obj, transfer_data_item):
temp_transfer_data = bpy.context.scene.asset_pipeline.temp_transfer_data temp_transfer_data = bpy.context.scene.asset_pipeline.temp_transfer_data
temp_info_index = len(temp_transfer_data) temp_transfer_data_item_index = len(temp_transfer_data)
temp_info = transfer_data_add_entry( temp_transfer_data_item = transfer_data_add_entry(
transfer_data=temp_transfer_data, transfer_data=temp_transfer_data,
name=transfer_info.name, name=transfer_data_item.name,
td_type_key=transfer_info.type, td_type_key=transfer_data_item.type,
task_layer_name=transfer_info.owner, task_layer_name=transfer_data_item.owner,
) )
map_item = { map_item = {
'transfer_info_index': temp_info_index, 'transfer_data_item_index': temp_transfer_data_item_index,
'source_obj': obj, 'source_obj': obj,
'target_obj': target_obj, 'target_obj': target_obj,
} }
# Names of each map item need to be unique # Names of each map item need to be unique
# below name avoids name conflicts between different types # below name avoids name conflicts between different types
name = transfer_info.name + '_' + transfer_info.type + obj.name name = transfer_data_item.name + '_' + transfer_data_item.type + obj.name
return name, map_item return name, map_item
def _check_transfer_data_conflict(self, obj, transfer_info): def _check_transfer_data_conflict(self, obj, transfer_data_item):
other_obj = bpy.data.objects.get(get_target_name(obj.name)) other_obj = bpy.data.objects.get(get_target_name(obj.name))
check_transfer_info = None check_transfer_data_item = None
if not other_obj: if not other_obj:
return return
for other_transfer_info in other_obj.transfer_data_ownership: for other_transfer_data_item in other_obj.transfer_data_ownership:
if ( if (
other_transfer_info.type == transfer_info.type other_transfer_data_item.type == transfer_data_item.type
and other_transfer_info.name == transfer_info.name and other_transfer_data_item.name == transfer_data_item.name
): ):
check_transfer_info = other_transfer_info check_transfer_data_item = other_transfer_data_item
if check_transfer_info is None: if check_transfer_data_item is None:
return return
if check_transfer_info.owner != transfer_info.owner: if check_transfer_data_item.owner != transfer_data_item.owner:
self.conflict_trasnfer_data.append(transfer_info) self.conflict_trasnfer_data.append(transfer_data_item)
print("CONFLICT FOUND") print("CONFLICT FOUND")
return True return True
@ -177,29 +177,29 @@ class AssetTransferMapping:
objs = [source_obj, target_obj] objs = [source_obj, target_obj]
for obj in objs: for obj in objs:
if obj.name.endswith(constants.LOCAL_SUFFIX): if obj.name.endswith(constants.LOCAL_SUFFIX):
for transfer_info in obj.transfer_data_ownership: for transfer_data_item in obj.transfer_data_ownership:
if transfer_info.owner in self._local_tls: if transfer_data_item.owner in self._local_tls:
conflict = self._check_transfer_data_conflict( conflict = self._check_transfer_data_conflict(
obj, transfer_info obj, transfer_data_item
) )
if not conflict: if not conflict:
name, map_item = self._get_transfer_data_map_item( name, map_item = self._get_transfer_data_map_item(
obj, target_obj, transfer_info obj, target_obj, transfer_data_item
) )
transfer_data_map[name] = map_item transfer_data_map[name] = map_item
if obj.name.endswith(constants.EXTERNAL_SUFFIX): if obj.name.endswith(constants.EXTERNAL_SUFFIX):
for transfer_info in obj.transfer_data_ownership: for transfer_data_item in obj.transfer_data_ownership:
if ( if (
transfer_info.owner not in self._local_tls transfer_data_item.owner not in self._local_tls
and transfer_info.owner != "NONE" and transfer_data_item.owner != "NONE"
): ):
conflict = self._check_transfer_data_conflict( conflict = self._check_transfer_data_conflict(
obj, transfer_info obj, transfer_data_item
) )
if not conflict: if not conflict:
name, map_item = self._get_transfer_data_map_item( name, map_item = self._get_transfer_data_map_item(
obj, target_obj, transfer_info obj, target_obj, transfer_data_item
) )
transfer_data_map[name] = map_item transfer_data_map[name] = map_item
return transfer_data_map return transfer_data_map

View File

@ -32,10 +32,10 @@ def ownership_transfer_data_cleanup(
""" """
transfer_data = obj.transfer_data_ownership transfer_data = obj.transfer_data_ownership
to_remove = [] to_remove = []
for transfer_info in transfer_data: for transfer_data_item in transfer_data:
if transfer_info.owner == task_layer_name: if transfer_data_item.owner == task_layer_name:
if transfer_data_is_missing(transfer_info): if transfer_data_is_missing(transfer_data_item):
to_remove.append(transfer_info.name) to_remove.append(transfer_data_item.name)
for name in to_remove: for name in to_remove:
transfer_data.remove(transfer_data.keys().index(name)) transfer_data.remove(transfer_data.keys().index(name))
@ -84,10 +84,13 @@ def ownership_set(temp_transfer_data: bpy.types.CollectionProperty) -> None:
temp_transfer_data (bpy.types.CollectionProperty): Collection property containing newly found temp_transfer_data (bpy.types.CollectionProperty): Collection property containing newly found
data and the object that contains this data. data and the object that contains this data.
""" """
for transfer_info in temp_transfer_data: for transfer_data_item in temp_transfer_data:
transfer_data = transfer_info.obj.transfer_data_ownership transfer_data = transfer_data_item.obj.transfer_data_ownership
transfer_data_add_entry( transfer_data_add_entry(
transfer_data, transfer_info.name, transfer_info.type, transfer_info.owner transfer_data,
transfer_data_item.name,
transfer_data_item.type,
transfer_data_item.owner,
) )

View File

@ -105,74 +105,76 @@ def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
for name in transfer_data_map: for name in transfer_data_map:
temp_transfer_data = context.scene.asset_pipeline.temp_transfer_data temp_transfer_data = context.scene.asset_pipeline.temp_transfer_data
transfer_data = transfer_data_map[name] transfer_data = transfer_data_map[name]
transfer_info = temp_transfer_data[transfer_data.get('transfer_info_index')] transfer_data_item = temp_transfer_data[
transfer_data.get('transfer_data_item_index')
]
target_obj = transfer_data.get('target_obj') target_obj = transfer_data.get('target_obj')
source_obj = transfer_data.get('source_obj') source_obj = transfer_data.get('source_obj')
if target_obj is None: if target_obj is None:
print(f"Failed to Transfer data for {transfer_info.id_data.name}") print(f"Failed to Transfer data for {transfer_data_item.id_data.name}")
continue continue
if transfer_info is None: if transfer_data_item is None:
continue continue
if source_obj != target_obj: if source_obj != target_obj:
if transfer_info.type == constants.VERTEX_GROUP_KEY: if transfer_data_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(
context=context, context=context,
vertex_group_name=transfer_info.name, vertex_group_name=transfer_data_item.name,
target_obj=target_obj, target_obj=target_obj,
source_obj=source_obj, source_obj=source_obj,
) )
# if transfer_info.type == constants.VERTEX_COLOR_KEY: # if transfer_data_item.type == constants.VERTEX_COLOR_KEY:
# transfer_functions.transfer_vertex_color( # transfer_functions.transfer_vertex_color(
# vertex_color_name=transfer_info.name, # vertex_color_name=transfer_data_item.name,
# target_obj=target_obj, # target_obj=target_obj,
# source_obj=source_obj, # source_obj=source_obj,
# ) # )
if transfer_info.type == constants.MODIFIER_KEY: if transfer_data_item.type == constants.MODIFIER_KEY:
print(f"Transfering Data {constants.MODIFIER_KEY}: {name}") print(f"Transfering Data {constants.MODIFIER_KEY}: {name}")
transfer_functions.transfer_modifier( transfer_functions.transfer_modifier(
modifier_name=transfer_info.name, modifier_name=transfer_data_item.name,
target_obj=target_obj, target_obj=target_obj,
source_obj=source_obj, source_obj=source_obj,
) )
if transfer_info.type == constants.CONSTRAINT_KEY: if transfer_data_item.type == constants.CONSTRAINT_KEY:
transfer_functions.transfer_constraint( transfer_functions.transfer_constraint(
constraint_name=transfer_info.name, constraint_name=transfer_data_item.name,
target_obj=target_obj, target_obj=target_obj,
source_obj=source_obj, source_obj=source_obj,
) )
if transfer_info.type == constants.MATERIAL_SLOT_KEY: if transfer_data_item.type == constants.MATERIAL_SLOT_KEY:
print(f"Transfering Data {constants.MATERIAL_SLOT_KEY}: {name}") print(f"Transfering Data {constants.MATERIAL_SLOT_KEY}: {name}")
transfer_functions.transfer_material_slots( transfer_functions.transfer_material_slots(
target_obj=target_obj, target_obj=target_obj,
source_obj=source_obj, source_obj=source_obj,
) )
# if transfer_info.type == constants.UV_LAYERS_KEY: # if transfer_data_item.type == constants.UV_LAYERS_KEY:
# transfer_functions.transfer_uv_layer( # transfer_functions.transfer_uv_layer(
# target_obj=target_obj, # target_obj=target_obj,
# source_obj=source_obj, # source_obj=source_obj,
# uv_name=transfer_info.name, # uv_name=transfer_data_item.name,
# ) # )
if transfer_info.type == constants.SHAPE_KEY_KEY: if transfer_data_item.type == constants.SHAPE_KEY_KEY:
transfer_functions.transfer_shape_key( transfer_functions.transfer_shape_key(
context=context, context=context,
target_obj=target_obj, target_obj=target_obj,
source_obj=source_obj, source_obj=source_obj,
shape_key_name=transfer_info.name, shape_key_name=transfer_data_item.name,
) )
if transfer_info.type == constants.ATTRIBUTE_KEY: if transfer_data_item.type == constants.ATTRIBUTE_KEY:
transfer_functions.transfer_attribute( transfer_functions.transfer_attribute(
target_obj=target_obj, target_obj=target_obj,
source_obj=source_obj, source_obj=source_obj,
attribute_name=transfer_info.name, attribute_name=transfer_data_item.name,
) )
if transfer_info.type == constants.PARENT_KEY: if transfer_data_item.type == constants.PARENT_KEY:
transfer_functions.transfer_parent( transfer_functions.transfer_parent(
target_obj=target_obj, target_obj=target_obj,
source_obj=source_obj, source_obj=source_obj,
) )
copy_transfer_data_ownership( copy_transfer_data_ownership(
transfer_data_item=transfer_info, transfer_data_item=transfer_data_item,
target_obj=target_obj, target_obj=target_obj,
) )

View File

@ -3,9 +3,9 @@ from bpy import context
from ..naming import get_basename from ..naming import get_basename
from ..drivers import find_drivers, copy_driver from ..drivers import find_drivers, copy_driver
from .transfer_util import ( from .transfer_util import (
transfer_info_clean, transfer_data_clean,
transfer_info_is_missing, transfer_data_item_is_missing,
transfer_info_init, transfer_data_item_init,
check_transfer_data_entry, check_transfer_data_entry,
) )
from ... import constants from ... import constants
@ -19,21 +19,21 @@ import numpy as np
# VERTEX GROUPS # VERTEX GROUPS
def vertex_groups_clean(obj): def vertex_groups_clean(obj):
transfer_info_clean( transfer_data_clean(
obj=obj, data_list=obj.vertex_groups, td_type_key=constants.VERTEX_GROUP_KEY obj=obj, data_list=obj.vertex_groups, td_type_key=constants.VERTEX_GROUP_KEY
) )
def vertex_group_is_missing(transfer_info): def vertex_group_is_missing(transfer_data_item):
return transfer_info_is_missing( return transfer_data_item_is_missing(
transfer_info=transfer_info, transfer_data_item=transfer_data_item,
td_type_key=constants.VERTEX_GROUP_KEY, td_type_key=constants.VERTEX_GROUP_KEY,
data_list=transfer_info.id_data.vertex_groups, data_list=transfer_data_item.id_data.vertex_groups,
) )
def init_vertex_groups(scene, obj): def init_vertex_groups(scene, obj):
transfer_info_init( transfer_data_item_init(
scene=scene, scene=scene,
obj=obj, obj=obj,
data_list=obj.vertex_groups, data_list=obj.vertex_groups,
@ -85,25 +85,25 @@ def transfer_vertex_group(
def vertex_colors_clean(obj): def vertex_colors_clean(obj):
if not obj.type == "MESH": if not obj.type == "MESH":
return return
transfer_info_clean( transfer_data_clean(
obj=obj, obj=obj,
data_list=obj.data.vertex_colors, data_list=obj.data.vertex_colors,
td_type_key=constants.VERTEX_COLOR_KEY, td_type_key=constants.VERTEX_COLOR_KEY,
) )
def vertex_color_is_missing(transfer_info): def vertex_color_is_missing(transfer_data_item):
return transfer_info_is_missing( return transfer_data_item_is_missing(
transfer_info=transfer_info, transfer_data_item=transfer_data_item,
td_type_key=constants.VERTEX_COLOR_KEY, td_type_key=constants.VERTEX_COLOR_KEY,
data_list=transfer_info.id_data.vertex_colors, data_list=transfer_data_item.id_data.vertex_colors,
) )
def init_vertex_colors(scene, obj): def init_vertex_colors(scene, obj):
if not obj.type == "MESH": if not obj.type == "MESH":
return return
transfer_info_init( transfer_data_item_init(
scene=scene, scene=scene,
obj=obj, obj=obj,
data_list=obj.data.vertex_colors, data_list=obj.data.vertex_colors,
@ -137,23 +137,23 @@ def transfer_vertex_color(
def uv_layer_clean(obj): def uv_layer_clean(obj):
if not obj.type == "MESH": if not obj.type == "MESH":
return return
transfer_info_clean( transfer_data_clean(
obj=obj, data_list=obj.data.uv_layers, td_type_key=constants.UV_LAYERS_KEY obj=obj, data_list=obj.data.uv_layers, td_type_key=constants.UV_LAYERS_KEY
) )
def uv_layer_is_missing(transfer_info): def uv_layer_is_missing(transfer_data_item):
return transfer_info_is_missing( return transfer_data_item_is_missing(
transfer_info=transfer_info, transfer_data_item=transfer_data_item,
td_type_key=constants.UV_LAYERS_KEY, td_type_key=constants.UV_LAYERS_KEY,
data_list=transfer_info.id_data.data.uv_layers, data_list=transfer_data_item.id_data.data.uv_layers,
) )
def init_uv_layers(scene, obj): def init_uv_layers(scene, obj):
if not obj.type == "MESH": if not obj.type == "MESH":
return return
transfer_info_init( transfer_data_item_init(
scene=scene, scene=scene,
obj=obj, obj=obj,
data_list=obj.data.uv_layers, data_list=obj.data.uv_layers,
@ -185,21 +185,21 @@ def transfer_uv_layer(source_obj, target_obj, uv_name):
# MODIFIERS # MODIFIERS
def modifiers_clean(obj): def modifiers_clean(obj):
transfer_info_clean( transfer_data_clean(
obj=obj, data_list=obj.modifiers, td_type_key=constants.MODIFIER_KEY obj=obj, data_list=obj.modifiers, td_type_key=constants.MODIFIER_KEY
) )
def modifier_is_missing(transfer_info): def modifier_is_missing(transfer_data_item):
return transfer_info_is_missing( return transfer_data_item_is_missing(
transfer_info=transfer_info, transfer_data_item=transfer_data_item,
td_type_key=constants.MODIFIER_KEY, td_type_key=constants.MODIFIER_KEY,
data_list=transfer_info.id_data.modifiers, data_list=transfer_data_item.id_data.modifiers,
) )
def init_modifiers(scene, obj): def init_modifiers(scene, obj):
transfer_info_init( transfer_data_item_init(
scene=scene, scene=scene,
obj=obj, obj=obj,
data_list=obj.modifiers, data_list=obj.modifiers,
@ -270,21 +270,21 @@ def transfer_modifier(modifier_name, target_obj, source_obj):
# CONSTRAINTS # CONSTRAINTS
def constraints_clean(obj): def constraints_clean(obj):
transfer_info_clean( transfer_data_clean(
obj=obj, data_list=obj.constraints, td_type_key=constants.CONSTRAINT_KEY obj=obj, data_list=obj.constraints, td_type_key=constants.CONSTRAINT_KEY
) )
def constraint_is_missing(transfer_info): def constraint_is_missing(transfer_data_item):
return transfer_info_is_missing( return transfer_data_item_is_missing(
transfer_info=transfer_info, transfer_data_item=transfer_data_item,
td_type_key=constants.CONSTRAINT_KEY, td_type_key=constants.CONSTRAINT_KEY,
data_list=transfer_info.id_data.constraints, data_list=transfer_data_item.id_data.constraints,
) )
def init_constraints(scene, obj): def init_constraints(scene, obj):
transfer_info_init( transfer_data_item_init(
scene=scene, scene=scene,
obj=obj, obj=obj,
data_list=obj.constraints, data_list=obj.constraints,
@ -344,11 +344,11 @@ def transfer_constraint(constraint_name, target_obj, source_obj):
# MATERIAL SLOT # MATERIAL SLOT
def material_slots_clean(obj): def material_slots_clean(obj):
# Material slots cannot use generic transfer_info_clean() function # Material slots cannot use generic transfer_data_clean() function
matches = check_transfer_data_entry( matches = check_transfer_data_entry(
obj.transfer_data_ownership, obj.transfer_data_ownership,
constants.MATERIAL_TRANSFER_INFO_NAME, constants.MATERIAL_TRANSFER_DATA_ITEM_NAME,
constants.MATERIAL_SLOT_KEY, constants.MATERIAL_SLOT_KEY,
) )
@ -360,10 +360,10 @@ def material_slots_clean(obj):
obj.data.materials.clear() obj.data.materials.clear()
def material_slots_is_missing(transfer_info): def material_slots_is_missing(transfer_data_item):
if ( if (
transfer_info.type == constants.MATERIAL_SLOT_KEY transfer_data_item.type == constants.MATERIAL_SLOT_KEY
and len(transfer_info.id_data.material_slots) == 0 and len(transfer_data_item.id_data.material_slots) == 0
): ):
return True return True
@ -371,14 +371,14 @@ def material_slots_is_missing(transfer_info):
def init_material_slots(scene, obj): def init_material_slots(scene, obj):
task_layer_key = scene.asset_pipeline.task_layer_name task_layer_key = scene.asset_pipeline.task_layer_name
td_type_key = constants.MATERIAL_SLOT_KEY td_type_key = constants.MATERIAL_SLOT_KEY
name = constants.MATERIAL_TRANSFER_INFO_NAME name = constants.MATERIAL_TRANSFER_DATA_ITEM_NAME
transfer_data = obj.transfer_data_ownership transfer_data = obj.transfer_data_ownership
# Only Execute if Material Slots exist on object # Only Execute if Material Slots exist on object
if len(obj.material_slots) == 0: if len(obj.material_slots) == 0:
return return
matches = check_transfer_data_entry(transfer_data, name, td_type_key) matches = check_transfer_data_entry(transfer_data, name, td_type_key)
# Only add new ownership transfer_info if vertex group doesn't have an owner # Only add new ownership transfer_data_item if vertex group doesn't have an owner
if len(matches) == 0: if len(matches) == 0:
scene.asset_pipeline.add_temp_transfer_data( scene.asset_pipeline.add_temp_transfer_data(
name=name, name=name,
@ -468,16 +468,16 @@ def shape_keys_clean(obj):
obj.shape_key_remove(shape_key) obj.shape_key_remove(shape_key)
def shape_key_is_missing(transfer_info): def shape_key_is_missing(transfer_data_item):
if not transfer_info.type == constants.SHAPE_KEY_KEY: if not transfer_data_item.type == constants.SHAPE_KEY_KEY:
return return
obj = transfer_info.id_data obj = transfer_data_item.id_data
if obj.type != 'MESH': if obj.type != 'MESH':
return return
if not obj.data.shape_keys: if not obj.data.shape_keys:
return True return True
return transfer_info_is_missing( return transfer_data_item_is_missing(
transfer_info=transfer_info, transfer_data_item=transfer_data_item,
td_type_key=constants.SHAPE_KEY_KEY, td_type_key=constants.SHAPE_KEY_KEY,
data_list=obj.data.shape_keys.key_blocks, data_list=obj.data.shape_keys.key_blocks,
) )
@ -497,7 +497,7 @@ def init_shape_keys(scene, obj):
f'Shape Key "{kb.name}" must be ordered after its base shape "{kb.relative_key.name}" on object "{obj.name}".' f'Shape Key "{kb.name}" must be ordered after its base shape "{kb.relative_key.name}" on object "{obj.name}".'
) )
transfer_info_init( transfer_data_item_init(
scene=scene, scene=scene,
obj=obj, obj=obj,
data_list=obj.data.shape_keys.key_blocks, data_list=obj.data.shape_keys.key_blocks,
@ -611,15 +611,15 @@ def attribute_clean(obj):
obj.data.attributes.remove(attribute) obj.data.attributes.remove(attribute)
def attribute_is_missing(transfer_info): def attribute_is_missing(transfer_data_item):
obj = transfer_info.id_data obj = transfer_data_item.id_data
if obj.type != "MESH": if obj.type != "MESH":
return return
attributes = attributes_get_editable(obj.data.attributes) attributes = attributes_get_editable(obj.data.attributes)
attribute_names = [attribute.name for attribute in attributes] attribute_names = [attribute.name for attribute in attributes]
if ( if (
transfer_info.type == constants.ATTRIBUTE_KEY transfer_data_item.type == constants.ATTRIBUTE_KEY
and not transfer_info["name"] in attribute_names and not transfer_data_item["name"] in attribute_names
): ):
return True return True
@ -631,7 +631,7 @@ def init_attributes(scene, obj):
task_layer_key = scene.asset_pipeline.task_layer_name task_layer_key = scene.asset_pipeline.task_layer_name
td_type_key = constants.ATTRIBUTE_KEY td_type_key = constants.ATTRIBUTE_KEY
for atttribute in attributes_get_editable(obj.data.attributes): for atttribute in attributes_get_editable(obj.data.attributes):
# Only add new ownership transfer_info if vertex group doesn't have an owner # Only add new ownership transfer_data_item if vertex group doesn't have an owner
matches = check_transfer_data_entry(transfer_data, atttribute.name, td_type_key) matches = check_transfer_data_entry(transfer_data, atttribute.name, td_type_key)
if len(matches) == 0: if len(matches) == 0:
scene.asset_pipeline.add_temp_transfer_data( scene.asset_pipeline.add_temp_transfer_data(
@ -675,7 +675,7 @@ def transfer_attribute(
def parent_clean(obj): def parent_clean(obj):
matches = check_transfer_data_entry( matches = check_transfer_data_entry(
obj.transfer_data_ownership, obj.transfer_data_ownership,
get_basename(constants.PARENT_TRANSFER_INFO_NAME), get_basename(constants.PARENT_TRANSFER_DATA_ITEM_NAME),
constants.PARENT_KEY, constants.PARENT_KEY,
) )
@ -686,10 +686,10 @@ def parent_clean(obj):
print("Cleaning Parent Relationship") print("Cleaning Parent Relationship")
def parent_is_missing(transfer_info): def parent_is_missing(transfer_data_item):
if ( if (
transfer_info.type == constants.PARENT_KEY transfer_data_item.type == constants.PARENT_KEY
and transfer_info.id_data.parent == None and transfer_data_item.id_data.parent == None
): ):
return True return True
@ -697,14 +697,14 @@ def parent_is_missing(transfer_info):
def init_parent(scene, obj): def init_parent(scene, obj):
task_layer_key = scene.asset_pipeline.task_layer_name task_layer_key = scene.asset_pipeline.task_layer_name
td_type_key = constants.PARENT_KEY td_type_key = constants.PARENT_KEY
name = constants.PARENT_TRANSFER_INFO_NAME name = constants.PARENT_TRANSFER_DATA_ITEM_NAME
transfer_data = obj.transfer_data_ownership transfer_data = obj.transfer_data_ownership
# Only Execute if Material Slots exist on object # Only Execute if Material Slots exist on object
if obj.parent == None: if obj.parent == None:
return return
matches = check_transfer_data_entry(transfer_data, name, td_type_key) matches = check_transfer_data_entry(transfer_data, name, td_type_key)
# Only add new ownership transfer_info if vertex group doesn't have an owner # Only add new ownership transfer_data_item if vertex group doesn't have an owner
if len(matches) == 0: if len(matches) == 0:
scene.asset_pipeline.add_temp_transfer_data( scene.asset_pipeline.add_temp_transfer_data(
name=name, name=name,

View File

@ -11,9 +11,9 @@ def draw_transfer_data_type(
name, icon = constants.TRANSFER_DATA_TYPES[transfer_data[0].type] name, icon = constants.TRANSFER_DATA_TYPES[transfer_data[0].type]
box = layout.box() box = layout.box()
box.label(text=name, icon=icon) box.label(text=name, icon=icon)
for transfer_info in transfer_data: for transfer_data_item in transfer_data:
owner_tl_ui_name = constants.TASK_LAYER_TYPES[transfer_info.owner] owner_tl_ui_name = constants.TASK_LAYER_TYPES[transfer_data_item.owner]
box.label(text=f"{transfer_info.name}: '{owner_tl_ui_name}'") box.label(text=f"{transfer_data_item.name}: '{owner_tl_ui_name}'")
def draw_transfer_data( def draw_transfer_data(
@ -30,25 +30,25 @@ def draw_transfer_data(
attributes = [] attributes = []
parent = [] parent = []
for transfer_info in transfer_data: for transfer_data_item in transfer_data:
if transfer_info.type == constants.VERTEX_GROUP_KEY: if transfer_data_item.type == constants.VERTEX_GROUP_KEY:
vertex_groups.append(transfer_info) vertex_groups.append(transfer_data_item)
# if transfer_info.type == constants.VERTEX_COLOR_KEY: # if transfer_data_item.type == constants.VERTEX_COLOR_KEY:
# vertex_colors.append(transfer_info) # vertex_colors.append(transfer_data_item)
if transfer_info.type == constants.MATERIAL_SLOT_KEY: if transfer_data_item.type == constants.MATERIAL_SLOT_KEY:
material_slots.append(transfer_info) material_slots.append(transfer_data_item)
if transfer_info.type == constants.MODIFIER_KEY: if transfer_data_item.type == constants.MODIFIER_KEY:
modifiers.append(transfer_info) modifiers.append(transfer_data_item)
if transfer_info.type == constants.CONSTRAINT_KEY: if transfer_data_item.type == constants.CONSTRAINT_KEY:
constraints.append(transfer_info) constraints.append(transfer_data_item)
# if transfer_info.type == constants.UV_LAYERS_KEY: # if transfer_data_item.type == constants.UV_LAYERS_KEY:
# uv_layers.append(transfer_info) # uv_layers.append(transfer_data_item)
if transfer_info.type == constants.SHAPE_KEY_KEY: if transfer_data_item.type == constants.SHAPE_KEY_KEY:
shape_keys.append(transfer_info) shape_keys.append(transfer_data_item)
if transfer_info.type == constants.ATTRIBUTE_KEY: if transfer_data_item.type == constants.ATTRIBUTE_KEY:
attributes.append(transfer_info) attributes.append(transfer_data_item)
if transfer_info.type == constants.PARENT_KEY: if transfer_data_item.type == constants.PARENT_KEY:
parent.append(transfer_info) parent.append(transfer_data_item)
draw_transfer_data_type(layout, vertex_groups) draw_transfer_data_type(layout, vertex_groups)
# draw_transfer_data_type(layout, vertex_colors) # draw_transfer_data_type(layout, vertex_colors)

View File

@ -16,9 +16,9 @@ def check_transfer_data_entry(
set: Returns set of matches where name is found in ownership set: Returns set of matches where name is found in ownership
""" """
existing_items = [ existing_items = [
transfer_info.name transfer_data_item.name
for transfer_info in transfer_data for transfer_data_item in transfer_data
if transfer_info.type == td_type_key if transfer_data_item.type == td_type_key
] ]
return set([key]).intersection(set(existing_items)) return set([key]).intersection(set(existing_items))
@ -37,15 +37,15 @@ def transfer_data_add_entry(
td_type_key (str): Type of transfer data td_type_key (str): Type of transfer data
task_layer_name (str): Name of current task layer task_layer_name (str): Name of current task layer
""" """
transfer_info = transfer_data.add() transfer_data_item = transfer_data.add()
transfer_info.name = name transfer_data_item.name = name
transfer_info.owner = task_layer_name.upper() transfer_data_item.owner = task_layer_name.upper()
transfer_info.type = td_type_key transfer_data_item.type = td_type_key
return transfer_info return transfer_data_item
# TODO Test if Clean and Missing are redudent functions # TODO Test if Clean and Missing are redudent functions
def transfer_info_clean( def transfer_data_clean(
obj: bpy.types.Object, data_list: bpy.types.CollectionProperty, td_type_key: str obj: bpy.types.Object, data_list: bpy.types.CollectionProperty, td_type_key: str
): ):
"""Remove transfer data entries if the corrisponding data doesn't exist """Remove transfer data entries if the corrisponding data doesn't exist
@ -64,19 +64,21 @@ def transfer_info_clean(
data_list.remove(item) data_list.remove(item)
def transfer_info_is_missing( def transfer_data_item_is_missing(
transfer_info, data_list: bpy.types.CollectionProperty, td_type_key: str transfer_data_item, data_list: bpy.types.CollectionProperty, td_type_key: str
) -> bool: ) -> bool:
"""Returns true if a transfer_data_item does not exist """Returns true if a transfer_data_item does not exist
Args: Args:
transfer_info (_type_): Item of Transfer Data transfer_data_item (_type_): Item of Transfer Data
data_list (bpy.types.CollectionProperty): Collection Property containing a type of possible transfer data e.g. obj.modifiers data_list (bpy.types.CollectionProperty): Collection Property containing a type of possible transfer data e.g. obj.modifiers
td_type_key (str): Key for the transfer data type td_type_key (str): Key for the transfer data type
Returns: Returns:
bool: Returns True if transfer_info is missing bool: Returns True if transfer_data_item is missing
""" """
if transfer_info.type == td_type_key and not data_list.get(transfer_info["name"]): if transfer_data_item.type == td_type_key and not data_list.get(
transfer_data_item["name"]
):
return True return True
@ -85,7 +87,7 @@ def transfer_info_is_missing(
""" """
def transfer_info_init( def transfer_data_item_init(
scene: bpy.types.Scene, scene: bpy.types.Scene,
obj: bpy.types.Object, obj: bpy.types.Object,
data_list: bpy.types.CollectionProperty, data_list: bpy.types.CollectionProperty,
@ -102,7 +104,7 @@ def transfer_info_init(
transfer_data = obj.transfer_data_ownership transfer_data = obj.transfer_data_ownership
task_layer_key = scene.asset_pipeline.task_layer_name task_layer_key = scene.asset_pipeline.task_layer_name
for item in data_list: for item in data_list:
# Only add new ownership transfer_info if vertex group doesn't have an owner # Only add new ownership transfer_data_item if vertex group doesn't have an owner
matches = check_transfer_data_entry(transfer_data, item.name, td_type_key) matches = check_transfer_data_entry(transfer_data, item.name, td_type_key)
if len(matches) == 0: if len(matches) == 0:
scene.asset_pipeline.add_temp_transfer_data( scene.asset_pipeline.add_temp_transfer_data(

View File

@ -192,16 +192,18 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
row = layout.row() row = layout.row()
row.prop(self, "expand", text="", icon="COLLAPSEMENU", toggle=False) row.prop(self, "expand", text="", icon="COLLAPSEMENU", toggle=False)
row.label(text="Show New Transfer Data") row.label(text="Show New Transfer Data")
objs = [transfer_info.obj for transfer_info in self._temp_transfer_data] objs = [
transfer_data_item.obj for transfer_data_item in self._temp_transfer_data
]
if not self.expand: if not self.expand:
return return
for obj in set(objs): for obj in set(objs):
obj_ownership = [ obj_ownership = [
transfer_info transfer_data_item
for transfer_info in self._temp_transfer_data for transfer_data_item in self._temp_transfer_data
if transfer_info.obj == obj if transfer_data_item.obj == obj
] ]
box = layout.box() box = layout.box()
box.label(text=obj.name, icon="OBJECT_DATA") box.label(text=obj.name, icon="OBJECT_DATA")

View File

@ -58,11 +58,11 @@ class AssetPipeline(bpy.types.PropertyGroup):
def add_temp_transfer_data(self, name, owner, type, obj): def add_temp_transfer_data(self, name, owner, type, obj):
new_transfer_data = self.temp_transfer_data new_transfer_data = self.temp_transfer_data
transfer_info = new_transfer_data.add() transfer_data_item = new_transfer_data.add()
transfer_info.name = name transfer_data_item.name = name
transfer_info.owner = owner transfer_data_item.owner = owner
transfer_info.type = type transfer_data_item.type = type
transfer_info.obj = obj transfer_data_item.obj = obj
## NEW FILE ## NEW FILE