Asset Pipeline v2 #145
@ -53,8 +53,8 @@ TRANSFER_DATA_TYPES_ENUM_ITEMS = [
|
||||
for i, tup in enumerate(TRANSFER_DATA_TYPES.items())
|
||||
]
|
||||
|
||||
MATERIAL_TRANSFER_INFO_NAME = "All Material Slots"
|
||||
PARENT_TRANSFER_INFO_NAME = "Parent Relationship"
|
||||
MATERIAL_TRANSFER_DATA_ITEM_NAME = "All Material Slots"
|
||||
PARENT_TRANSFER_DATA_ITEM_NAME = "Parent Relationship"
|
||||
|
||||
PUBLISH_TYPES = [
|
||||
(
|
||||
|
@ -129,41 +129,41 @@ class AssetTransferMapping:
|
||||
|
||||
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_info_index = len(temp_transfer_data)
|
||||
temp_info = transfer_data_add_entry(
|
||||
temp_transfer_data_item_index = len(temp_transfer_data)
|
||||
temp_transfer_data_item = transfer_data_add_entry(
|
||||
transfer_data=temp_transfer_data,
|
||||
name=transfer_info.name,
|
||||
td_type_key=transfer_info.type,
|
||||
task_layer_name=transfer_info.owner,
|
||||
name=transfer_data_item.name,
|
||||
td_type_key=transfer_data_item.type,
|
||||
task_layer_name=transfer_data_item.owner,
|
||||
)
|
||||
|
||||
map_item = {
|
||||
'transfer_info_index': temp_info_index,
|
||||
'transfer_data_item_index': temp_transfer_data_item_index,
|
||||
'source_obj': obj,
|
||||
'target_obj': target_obj,
|
||||
}
|
||||
# Names of each map item need to be unique
|
||||
# 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
|
||||
|
||||
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))
|
||||
check_transfer_info = None
|
||||
check_transfer_data_item = None
|
||||
if not other_obj:
|
||||
return
|
||||
for other_transfer_info in other_obj.transfer_data_ownership:
|
||||
for other_transfer_data_item in other_obj.transfer_data_ownership:
|
||||
if (
|
||||
other_transfer_info.type == transfer_info.type
|
||||
and other_transfer_info.name == transfer_info.name
|
||||
other_transfer_data_item.type == transfer_data_item.type
|
||||
and other_transfer_data_item.name == transfer_data_item.name
|
||||
):
|
||||
check_transfer_info = other_transfer_info
|
||||
if check_transfer_info is None:
|
||||
check_transfer_data_item = other_transfer_data_item
|
||||
if check_transfer_data_item is None:
|
||||
return
|
||||
if check_transfer_info.owner != transfer_info.owner:
|
||||
self.conflict_trasnfer_data.append(transfer_info)
|
||||
if check_transfer_data_item.owner != transfer_data_item.owner:
|
||||
self.conflict_trasnfer_data.append(transfer_data_item)
|
||||
print("CONFLICT FOUND")
|
||||
return True
|
||||
|
||||
@ -177,29 +177,29 @@ class AssetTransferMapping:
|
||||
objs = [source_obj, target_obj]
|
||||
for obj in objs:
|
||||
if obj.name.endswith(constants.LOCAL_SUFFIX):
|
||||
for transfer_info in obj.transfer_data_ownership:
|
||||
if transfer_info.owner in self._local_tls:
|
||||
for transfer_data_item in obj.transfer_data_ownership:
|
||||
if transfer_data_item.owner in self._local_tls:
|
||||
conflict = self._check_transfer_data_conflict(
|
||||
obj, transfer_info
|
||||
obj, transfer_data_item
|
||||
)
|
||||
if not conflict:
|
||||
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
|
||||
|
||||
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 (
|
||||
transfer_info.owner not in self._local_tls
|
||||
and transfer_info.owner != "NONE"
|
||||
transfer_data_item.owner not in self._local_tls
|
||||
and transfer_data_item.owner != "NONE"
|
||||
):
|
||||
conflict = self._check_transfer_data_conflict(
|
||||
obj, transfer_info
|
||||
obj, transfer_data_item
|
||||
)
|
||||
if not conflict:
|
||||
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
|
||||
return transfer_data_map
|
||||
|
@ -32,10 +32,10 @@ def ownership_transfer_data_cleanup(
|
||||
"""
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
to_remove = []
|
||||
for transfer_info in transfer_data:
|
||||
if transfer_info.owner == task_layer_name:
|
||||
if transfer_data_is_missing(transfer_info):
|
||||
to_remove.append(transfer_info.name)
|
||||
for transfer_data_item in transfer_data:
|
||||
if transfer_data_item.owner == task_layer_name:
|
||||
if transfer_data_is_missing(transfer_data_item):
|
||||
to_remove.append(transfer_data_item.name)
|
||||
|
||||
for name in to_remove:
|
||||
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
|
||||
data and the object that contains this data.
|
||||
"""
|
||||
for transfer_info in temp_transfer_data:
|
||||
transfer_data = transfer_info.obj.transfer_data_ownership
|
||||
for transfer_data_item in temp_transfer_data:
|
||||
transfer_data = transfer_data_item.obj.transfer_data_ownership
|
||||
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,
|
||||
)
|
||||
|
||||
|
||||
|
@ -105,74 +105,76 @@ def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
|
||||
for name in transfer_data_map:
|
||||
temp_transfer_data = context.scene.asset_pipeline.temp_transfer_data
|
||||
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')
|
||||
source_obj = transfer_data.get('source_obj')
|
||||
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
|
||||
if transfer_info is None:
|
||||
if transfer_data_item is None:
|
||||
continue
|
||||
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}")
|
||||
transfer_functions.transfer_vertex_group(
|
||||
context=context,
|
||||
vertex_group_name=transfer_info.name,
|
||||
vertex_group_name=transfer_data_item.name,
|
||||
target_obj=target_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(
|
||||
# vertex_color_name=transfer_info.name,
|
||||
# vertex_color_name=transfer_data_item.name,
|
||||
# target_obj=target_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}")
|
||||
transfer_functions.transfer_modifier(
|
||||
modifier_name=transfer_info.name,
|
||||
modifier_name=transfer_data_item.name,
|
||||
target_obj=target_obj,
|
||||
source_obj=source_obj,
|
||||
)
|
||||
if transfer_info.type == constants.CONSTRAINT_KEY:
|
||||
if transfer_data_item.type == constants.CONSTRAINT_KEY:
|
||||
transfer_functions.transfer_constraint(
|
||||
constraint_name=transfer_info.name,
|
||||
constraint_name=transfer_data_item.name,
|
||||
target_obj=target_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}")
|
||||
transfer_functions.transfer_material_slots(
|
||||
target_obj=target_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(
|
||||
# target_obj=target_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(
|
||||
context=context,
|
||||
target_obj=target_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(
|
||||
target_obj=target_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(
|
||||
target_obj=target_obj,
|
||||
source_obj=source_obj,
|
||||
)
|
||||
|
||||
copy_transfer_data_ownership(
|
||||
transfer_data_item=transfer_info,
|
||||
transfer_data_item=transfer_data_item,
|
||||
target_obj=target_obj,
|
||||
)
|
||||
|
@ -3,9 +3,9 @@ from bpy import context
|
||||
from ..naming import get_basename
|
||||
from ..drivers import find_drivers, copy_driver
|
||||
from .transfer_util import (
|
||||
transfer_info_clean,
|
||||
transfer_info_is_missing,
|
||||
transfer_info_init,
|
||||
transfer_data_clean,
|
||||
transfer_data_item_is_missing,
|
||||
transfer_data_item_init,
|
||||
check_transfer_data_entry,
|
||||
)
|
||||
from ... import constants
|
||||
@ -19,21 +19,21 @@ import numpy as np
|
||||
|
||||
# VERTEX GROUPS
|
||||
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
|
||||
)
|
||||
|
||||
|
||||
def vertex_group_is_missing(transfer_info):
|
||||
return transfer_info_is_missing(
|
||||
transfer_info=transfer_info,
|
||||
def vertex_group_is_missing(transfer_data_item):
|
||||
return transfer_data_item_is_missing(
|
||||
transfer_data_item=transfer_data_item,
|
||||
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):
|
||||
transfer_info_init(
|
||||
transfer_data_item_init(
|
||||
scene=scene,
|
||||
obj=obj,
|
||||
data_list=obj.vertex_groups,
|
||||
@ -85,25 +85,25 @@ def transfer_vertex_group(
|
||||
def vertex_colors_clean(obj):
|
||||
if not obj.type == "MESH":
|
||||
return
|
||||
transfer_info_clean(
|
||||
transfer_data_clean(
|
||||
obj=obj,
|
||||
data_list=obj.data.vertex_colors,
|
||||
td_type_key=constants.VERTEX_COLOR_KEY,
|
||||
)
|
||||
|
||||
|
||||
def vertex_color_is_missing(transfer_info):
|
||||
return transfer_info_is_missing(
|
||||
transfer_info=transfer_info,
|
||||
def vertex_color_is_missing(transfer_data_item):
|
||||
return transfer_data_item_is_missing(
|
||||
transfer_data_item=transfer_data_item,
|
||||
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):
|
||||
if not obj.type == "MESH":
|
||||
return
|
||||
transfer_info_init(
|
||||
transfer_data_item_init(
|
||||
scene=scene,
|
||||
obj=obj,
|
||||
data_list=obj.data.vertex_colors,
|
||||
@ -137,23 +137,23 @@ def transfer_vertex_color(
|
||||
def uv_layer_clean(obj):
|
||||
if not obj.type == "MESH":
|
||||
return
|
||||
transfer_info_clean(
|
||||
transfer_data_clean(
|
||||
obj=obj, data_list=obj.data.uv_layers, td_type_key=constants.UV_LAYERS_KEY
|
||||
)
|
||||
|
||||
|
||||
def uv_layer_is_missing(transfer_info):
|
||||
return transfer_info_is_missing(
|
||||
transfer_info=transfer_info,
|
||||
def uv_layer_is_missing(transfer_data_item):
|
||||
return transfer_data_item_is_missing(
|
||||
transfer_data_item=transfer_data_item,
|
||||
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):
|
||||
if not obj.type == "MESH":
|
||||
return
|
||||
transfer_info_init(
|
||||
transfer_data_item_init(
|
||||
scene=scene,
|
||||
obj=obj,
|
||||
data_list=obj.data.uv_layers,
|
||||
@ -185,21 +185,21 @@ def transfer_uv_layer(source_obj, target_obj, uv_name):
|
||||
|
||||
# MODIFIERS
|
||||
def modifiers_clean(obj):
|
||||
transfer_info_clean(
|
||||
transfer_data_clean(
|
||||
obj=obj, data_list=obj.modifiers, td_type_key=constants.MODIFIER_KEY
|
||||
)
|
||||
|
||||
|
||||
def modifier_is_missing(transfer_info):
|
||||
return transfer_info_is_missing(
|
||||
transfer_info=transfer_info,
|
||||
def modifier_is_missing(transfer_data_item):
|
||||
return transfer_data_item_is_missing(
|
||||
transfer_data_item=transfer_data_item,
|
||||
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):
|
||||
transfer_info_init(
|
||||
transfer_data_item_init(
|
||||
scene=scene,
|
||||
obj=obj,
|
||||
data_list=obj.modifiers,
|
||||
@ -270,21 +270,21 @@ def transfer_modifier(modifier_name, target_obj, source_obj):
|
||||
|
||||
# CONSTRAINTS
|
||||
def constraints_clean(obj):
|
||||
transfer_info_clean(
|
||||
transfer_data_clean(
|
||||
obj=obj, data_list=obj.constraints, td_type_key=constants.CONSTRAINT_KEY
|
||||
)
|
||||
|
||||
|
||||
def constraint_is_missing(transfer_info):
|
||||
return transfer_info_is_missing(
|
||||
transfer_info=transfer_info,
|
||||
def constraint_is_missing(transfer_data_item):
|
||||
return transfer_data_item_is_missing(
|
||||
transfer_data_item=transfer_data_item,
|
||||
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):
|
||||
transfer_info_init(
|
||||
transfer_data_item_init(
|
||||
scene=scene,
|
||||
obj=obj,
|
||||
data_list=obj.constraints,
|
||||
@ -344,11 +344,11 @@ def transfer_constraint(constraint_name, target_obj, source_obj):
|
||||
|
||||
# MATERIAL SLOT
|
||||
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(
|
||||
obj.transfer_data_ownership,
|
||||
constants.MATERIAL_TRANSFER_INFO_NAME,
|
||||
constants.MATERIAL_TRANSFER_DATA_ITEM_NAME,
|
||||
constants.MATERIAL_SLOT_KEY,
|
||||
)
|
||||
|
||||
@ -360,10 +360,10 @@ def material_slots_clean(obj):
|
||||
obj.data.materials.clear()
|
||||
|
||||
|
||||
def material_slots_is_missing(transfer_info):
|
||||
def material_slots_is_missing(transfer_data_item):
|
||||
if (
|
||||
transfer_info.type == constants.MATERIAL_SLOT_KEY
|
||||
and len(transfer_info.id_data.material_slots) == 0
|
||||
transfer_data_item.type == constants.MATERIAL_SLOT_KEY
|
||||
and len(transfer_data_item.id_data.material_slots) == 0
|
||||
):
|
||||
return True
|
||||
|
||||
@ -371,14 +371,14 @@ def material_slots_is_missing(transfer_info):
|
||||
def init_material_slots(scene, obj):
|
||||
task_layer_key = scene.asset_pipeline.task_layer_name
|
||||
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
|
||||
|
||||
# Only Execute if Material Slots exist on object
|
||||
if len(obj.material_slots) == 0:
|
||||
return
|
||||
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:
|
||||
scene.asset_pipeline.add_temp_transfer_data(
|
||||
name=name,
|
||||
@ -468,16 +468,16 @@ def shape_keys_clean(obj):
|
||||
obj.shape_key_remove(shape_key)
|
||||
|
||||
|
||||
def shape_key_is_missing(transfer_info):
|
||||
if not transfer_info.type == constants.SHAPE_KEY_KEY:
|
||||
def shape_key_is_missing(transfer_data_item):
|
||||
if not transfer_data_item.type == constants.SHAPE_KEY_KEY:
|
||||
return
|
||||
obj = transfer_info.id_data
|
||||
obj = transfer_data_item.id_data
|
||||
if obj.type != 'MESH':
|
||||
return
|
||||
if not obj.data.shape_keys:
|
||||
return True
|
||||
return transfer_info_is_missing(
|
||||
transfer_info=transfer_info,
|
||||
return transfer_data_item_is_missing(
|
||||
transfer_data_item=transfer_data_item,
|
||||
td_type_key=constants.SHAPE_KEY_KEY,
|
||||
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}".'
|
||||
)
|
||||
|
||||
transfer_info_init(
|
||||
transfer_data_item_init(
|
||||
scene=scene,
|
||||
obj=obj,
|
||||
data_list=obj.data.shape_keys.key_blocks,
|
||||
@ -611,15 +611,15 @@ def attribute_clean(obj):
|
||||
obj.data.attributes.remove(attribute)
|
||||
|
||||
|
||||
def attribute_is_missing(transfer_info):
|
||||
obj = transfer_info.id_data
|
||||
def attribute_is_missing(transfer_data_item):
|
||||
obj = transfer_data_item.id_data
|
||||
if obj.type != "MESH":
|
||||
return
|
||||
attributes = attributes_get_editable(obj.data.attributes)
|
||||
attribute_names = [attribute.name for attribute in attributes]
|
||||
if (
|
||||
transfer_info.type == constants.ATTRIBUTE_KEY
|
||||
and not transfer_info["name"] in attribute_names
|
||||
transfer_data_item.type == constants.ATTRIBUTE_KEY
|
||||
and not transfer_data_item["name"] in attribute_names
|
||||
):
|
||||
return True
|
||||
|
||||
@ -631,7 +631,7 @@ def init_attributes(scene, obj):
|
||||
task_layer_key = scene.asset_pipeline.task_layer_name
|
||||
td_type_key = constants.ATTRIBUTE_KEY
|
||||
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)
|
||||
if len(matches) == 0:
|
||||
scene.asset_pipeline.add_temp_transfer_data(
|
||||
@ -675,7 +675,7 @@ def transfer_attribute(
|
||||
def parent_clean(obj):
|
||||
matches = check_transfer_data_entry(
|
||||
obj.transfer_data_ownership,
|
||||
get_basename(constants.PARENT_TRANSFER_INFO_NAME),
|
||||
get_basename(constants.PARENT_TRANSFER_DATA_ITEM_NAME),
|
||||
constants.PARENT_KEY,
|
||||
)
|
||||
|
||||
@ -686,10 +686,10 @@ def parent_clean(obj):
|
||||
print("Cleaning Parent Relationship")
|
||||
|
||||
|
||||
def parent_is_missing(transfer_info):
|
||||
def parent_is_missing(transfer_data_item):
|
||||
if (
|
||||
transfer_info.type == constants.PARENT_KEY
|
||||
and transfer_info.id_data.parent == None
|
||||
transfer_data_item.type == constants.PARENT_KEY
|
||||
and transfer_data_item.id_data.parent == None
|
||||
):
|
||||
return True
|
||||
|
||||
@ -697,14 +697,14 @@ def parent_is_missing(transfer_info):
|
||||
def init_parent(scene, obj):
|
||||
task_layer_key = scene.asset_pipeline.task_layer_name
|
||||
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
|
||||
|
||||
# Only Execute if Material Slots exist on object
|
||||
if obj.parent == None:
|
||||
return
|
||||
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:
|
||||
scene.asset_pipeline.add_temp_transfer_data(
|
||||
name=name,
|
||||
|
@ -11,9 +11,9 @@ def draw_transfer_data_type(
|
||||
name, icon = constants.TRANSFER_DATA_TYPES[transfer_data[0].type]
|
||||
box = layout.box()
|
||||
box.label(text=name, icon=icon)
|
||||
for transfer_info in transfer_data:
|
||||
owner_tl_ui_name = constants.TASK_LAYER_TYPES[transfer_info.owner]
|
||||
box.label(text=f"{transfer_info.name}: '{owner_tl_ui_name}'")
|
||||
for transfer_data_item in transfer_data:
|
||||
owner_tl_ui_name = constants.TASK_LAYER_TYPES[transfer_data_item.owner]
|
||||
box.label(text=f"{transfer_data_item.name}: '{owner_tl_ui_name}'")
|
||||
|
||||
|
||||
def draw_transfer_data(
|
||||
@ -30,25 +30,25 @@ def draw_transfer_data(
|
||||
attributes = []
|
||||
parent = []
|
||||
|
||||
for transfer_info in transfer_data:
|
||||
if transfer_info.type == constants.VERTEX_GROUP_KEY:
|
||||
vertex_groups.append(transfer_info)
|
||||
# if transfer_info.type == constants.VERTEX_COLOR_KEY:
|
||||
# vertex_colors.append(transfer_info)
|
||||
if transfer_info.type == constants.MATERIAL_SLOT_KEY:
|
||||
material_slots.append(transfer_info)
|
||||
if transfer_info.type == constants.MODIFIER_KEY:
|
||||
modifiers.append(transfer_info)
|
||||
if transfer_info.type == constants.CONSTRAINT_KEY:
|
||||
constraints.append(transfer_info)
|
||||
# if transfer_info.type == constants.UV_LAYERS_KEY:
|
||||
# uv_layers.append(transfer_info)
|
||||
if transfer_info.type == constants.SHAPE_KEY_KEY:
|
||||
shape_keys.append(transfer_info)
|
||||
if transfer_info.type == constants.ATTRIBUTE_KEY:
|
||||
attributes.append(transfer_info)
|
||||
if transfer_info.type == constants.PARENT_KEY:
|
||||
parent.append(transfer_info)
|
||||
for transfer_data_item in transfer_data:
|
||||
if transfer_data_item.type == constants.VERTEX_GROUP_KEY:
|
||||
vertex_groups.append(transfer_data_item)
|
||||
# if transfer_data_item.type == constants.VERTEX_COLOR_KEY:
|
||||
# vertex_colors.append(transfer_data_item)
|
||||
if transfer_data_item.type == constants.MATERIAL_SLOT_KEY:
|
||||
material_slots.append(transfer_data_item)
|
||||
if transfer_data_item.type == constants.MODIFIER_KEY:
|
||||
modifiers.append(transfer_data_item)
|
||||
if transfer_data_item.type == constants.CONSTRAINT_KEY:
|
||||
constraints.append(transfer_data_item)
|
||||
# if transfer_data_item.type == constants.UV_LAYERS_KEY:
|
||||
# uv_layers.append(transfer_data_item)
|
||||
if transfer_data_item.type == constants.SHAPE_KEY_KEY:
|
||||
shape_keys.append(transfer_data_item)
|
||||
if transfer_data_item.type == constants.ATTRIBUTE_KEY:
|
||||
attributes.append(transfer_data_item)
|
||||
if transfer_data_item.type == constants.PARENT_KEY:
|
||||
parent.append(transfer_data_item)
|
||||
|
||||
draw_transfer_data_type(layout, vertex_groups)
|
||||
# draw_transfer_data_type(layout, vertex_colors)
|
||||
|
@ -16,9 +16,9 @@ def check_transfer_data_entry(
|
||||
set: Returns set of matches where name is found in ownership
|
||||
"""
|
||||
existing_items = [
|
||||
transfer_info.name
|
||||
for transfer_info in transfer_data
|
||||
if transfer_info.type == td_type_key
|
||||
transfer_data_item.name
|
||||
for transfer_data_item in transfer_data
|
||||
if transfer_data_item.type == td_type_key
|
||||
]
|
||||
return set([key]).intersection(set(existing_items))
|
||||
|
||||
@ -37,15 +37,15 @@ def transfer_data_add_entry(
|
||||
td_type_key (str): Type of transfer data
|
||||
task_layer_name (str): Name of current task layer
|
||||
"""
|
||||
transfer_info = transfer_data.add()
|
||||
transfer_info.name = name
|
||||
transfer_info.owner = task_layer_name.upper()
|
||||
transfer_info.type = td_type_key
|
||||
return transfer_info
|
||||
transfer_data_item = transfer_data.add()
|
||||
transfer_data_item.name = name
|
||||
transfer_data_item.owner = task_layer_name.upper()
|
||||
transfer_data_item.type = td_type_key
|
||||
return transfer_data_item
|
||||
|
||||
|
||||
# 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
|
||||
):
|
||||
"""Remove transfer data entries if the corrisponding data doesn't exist
|
||||
@ -64,19 +64,21 @@ def transfer_info_clean(
|
||||
data_list.remove(item)
|
||||
|
||||
|
||||
def transfer_info_is_missing(
|
||||
transfer_info, data_list: bpy.types.CollectionProperty, td_type_key: str
|
||||
def transfer_data_item_is_missing(
|
||||
transfer_data_item, data_list: bpy.types.CollectionProperty, td_type_key: str
|
||||
) -> bool:
|
||||
"""Returns true if a transfer_data_item does not exist
|
||||
|
||||
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
|
||||
td_type_key (str): Key for the transfer data type
|
||||
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
|
||||
|
||||
|
||||
@ -85,7 +87,7 @@ def transfer_info_is_missing(
|
||||
"""
|
||||
|
||||
|
||||
def transfer_info_init(
|
||||
def transfer_data_item_init(
|
||||
scene: bpy.types.Scene,
|
||||
obj: bpy.types.Object,
|
||||
data_list: bpy.types.CollectionProperty,
|
||||
@ -102,7 +104,7 @@ def transfer_info_init(
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
task_layer_key = scene.asset_pipeline.task_layer_name
|
||||
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)
|
||||
if len(matches) == 0:
|
||||
scene.asset_pipeline.add_temp_transfer_data(
|
||||
|
@ -192,16 +192,18 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
|
||||
row = layout.row()
|
||||
row.prop(self, "expand", text="", icon="COLLAPSEMENU", toggle=False)
|
||||
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:
|
||||
return
|
||||
|
||||
for obj in set(objs):
|
||||
obj_ownership = [
|
||||
transfer_info
|
||||
for transfer_info in self._temp_transfer_data
|
||||
if transfer_info.obj == obj
|
||||
transfer_data_item
|
||||
for transfer_data_item in self._temp_transfer_data
|
||||
if transfer_data_item.obj == obj
|
||||
]
|
||||
box = layout.box()
|
||||
box.label(text=obj.name, icon="OBJECT_DATA")
|
||||
|
@ -58,11 +58,11 @@ class AssetPipeline(bpy.types.PropertyGroup):
|
||||
|
||||
def add_temp_transfer_data(self, name, owner, type, obj):
|
||||
new_transfer_data = self.temp_transfer_data
|
||||
transfer_info = new_transfer_data.add()
|
||||
transfer_info.name = name
|
||||
transfer_info.owner = owner
|
||||
transfer_info.type = type
|
||||
transfer_info.obj = obj
|
||||
transfer_data_item = new_transfer_data.add()
|
||||
transfer_data_item.name = name
|
||||
transfer_data_item.owner = owner
|
||||
transfer_data_item.type = type
|
||||
transfer_data_item.obj = obj
|
||||
|
||||
## NEW FILE
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user