Asset Pipeline v2 #145
@ -8,7 +8,7 @@ TASK_LAYER_TYPES = {
|
||||
"NONE": "None",
|
||||
"MODEL": "Modeling",
|
||||
"RIG": "Rigging",
|
||||
"SHADE": "Shading"
|
||||
"SHADE": "Shading",
|
||||
}
|
||||
|
||||
# When creating a new asset, start in this task layer's file.
|
||||
@ -29,6 +29,7 @@ MATERIAL_SLOT_KEY = "MATERIAL"
|
||||
UV_LAYERS_KEY = "UV_MAP"
|
||||
SHAPE_KEY_KEY = "SHAPE_KEY"
|
||||
ATTRIBUTE_KEY = "ATTRIBUTE"
|
||||
PARENT_KEY = "PARENT"
|
||||
|
||||
# Information about supported transferable data.
|
||||
# {Key string : ("UI Name", 'ICON')}
|
||||
@ -42,6 +43,7 @@ TRANSFER_DATA_TYPES = {
|
||||
UV_LAYERS_KEY: ("UV Maps", 'GROUP_UVS'),
|
||||
SHAPE_KEY_KEY: ("Shape Key", 'SHAPEKEY_DATA'),
|
||||
ATTRIBUTE_KEY: ("Attribute", 'EVENT_A'),
|
||||
PARENT_KEY: ("Parent", 'FILE_PARENT'),
|
||||
}
|
||||
|
||||
# Convert it to the format that EnumProperty.items wants:
|
||||
@ -52,6 +54,7 @@ TRANSFER_DATA_TYPES_ENUM_ITEMS = [
|
||||
]
|
||||
|
||||
MATERIAL_TRANSFER_INFO_NAME = "All Material Slots"
|
||||
PARENT_TRANSFER_INFO_NAME = "Parent Relationship"
|
||||
|
||||
PUBLISH_TYPES = [
|
||||
(
|
||||
|
@ -33,6 +33,7 @@ def transfer_data_clean(obj):
|
||||
transfer_functions.material_slots_clean(obj)
|
||||
transfer_functions.shape_keys_clean(obj)
|
||||
transfer_functions.attribute_clean(obj)
|
||||
transfer_functions.parent_clean(obj)
|
||||
|
||||
|
||||
def transfer_data_is_missing(transfer_data_item) -> bool:
|
||||
@ -53,6 +54,7 @@ def transfer_data_is_missing(transfer_data_item) -> bool:
|
||||
# or transfer_functions.uv_layer_is_missing(transfer_data_item)
|
||||
or transfer_functions.shape_key_is_missing(transfer_data_item)
|
||||
or transfer_functions.attribute_is_missing(transfer_data_item)
|
||||
or transfer_functions.parent_is_missing(transfer_data_item)
|
||||
)
|
||||
|
||||
|
||||
@ -75,6 +77,7 @@ def init_transfer_data(
|
||||
# transfer_functions.init_uv_layers(scene, obj)
|
||||
transfer_functions.init_shape_keys(scene, obj)
|
||||
transfer_functions.init_attributes(scene, obj)
|
||||
transfer_functions.init_parent(scene, obj)
|
||||
|
||||
|
||||
def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
|
||||
@ -153,6 +156,11 @@ def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
|
||||
source_obj=source_obj,
|
||||
attribute_name=transfer_info.name,
|
||||
)
|
||||
if transfer_info.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,
|
||||
|
@ -431,7 +431,9 @@ def init_shape_keys(scene, obj):
|
||||
if kb.relative_key:
|
||||
base_shape_idx = obj.data.shape_keys.key_blocks.find(kb.relative_key.name)
|
||||
if base_shape_idx > i:
|
||||
raise Exception(f'Shape Key "{kb.name}" must be ordered after its base shape "{kb.relative_key.name}" on object "{obj.name}".')
|
||||
raise Exception(
|
||||
f'Shape Key "{kb.name}" must be ordered after its base shape "{kb.relative_key.name}" on object "{obj.name}".'
|
||||
)
|
||||
|
||||
transfer_core.transfer_info_init(
|
||||
scene, obj, obj.data.shape_keys.key_blocks, constants.SHAPE_KEY_KEY
|
||||
@ -595,3 +597,49 @@ def transfer_attribute(
|
||||
for key in list(keys):
|
||||
target_data = target_attribute.data[index]
|
||||
setattr(target_data, key, getattr(source_data, key))
|
||||
|
||||
|
||||
def parent_clean(obj):
|
||||
transfer_data_list = transfer_core.get_transfer_data_as_names(
|
||||
obj.transfer_data_ownership, constants.PARENT_KEY
|
||||
)
|
||||
|
||||
if transfer_data_list != []:
|
||||
return
|
||||
|
||||
obj.parent = None
|
||||
print("Cleaning Parent Relationship")
|
||||
|
||||
|
||||
def parent_is_missing(transfer_info):
|
||||
if (
|
||||
transfer_info.type == constants.PARENT_KEY
|
||||
and transfer_info.id_data.parent == None
|
||||
):
|
||||
return True
|
||||
|
||||
|
||||
def init_parent(scene, obj):
|
||||
task_layer_key = scene.asset_pipeline.task_layer_name
|
||||
type_key = constants.PARENT_KEY
|
||||
name = constants.PARENT_TRANSFER_INFO_NAME
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
|
||||
# Only Execute if Material Slots exist on object
|
||||
if obj.parent == None:
|
||||
return
|
||||
matches = transfer_core.check_transfer_data_entry(transfer_data, name, type_key)
|
||||
# Only add new ownership transfer_info if vertex group doesn't have an owner
|
||||
if len(matches) == 0:
|
||||
scene.asset_pipeline.add_temp_trasnfer_data(
|
||||
name=name,
|
||||
owner=task_layer_key,
|
||||
type=type_key,
|
||||
obj=obj,
|
||||
)
|
||||
|
||||
|
||||
def transfer_parent(target_obj, source_obj):
|
||||
target_obj.parent = source_obj.parent
|
||||
# TODO Test if this works in all cases
|
||||
target_obj.matrix_parent_inverse = source_obj.parent.matrix_world.inverted()
|
||||
|
@ -28,6 +28,7 @@ def draw_transfer_data(
|
||||
# uv_layers = []
|
||||
shape_keys = []
|
||||
attributes = []
|
||||
parent = []
|
||||
|
||||
for transfer_info in transfer_data:
|
||||
if transfer_info.type == constants.VERTEX_GROUP_KEY:
|
||||
@ -46,6 +47,8 @@ def draw_transfer_data(
|
||||
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)
|
||||
|
||||
draw_transfer_data_type(layout, vertex_groups)
|
||||
# draw_transfer_data_type(layout, vertex_colors)
|
||||
@ -55,3 +58,4 @@ def draw_transfer_data(
|
||||
# draw_transfer_data_type(layout, uv_layers)
|
||||
draw_transfer_data_type(layout, shape_keys)
|
||||
draw_transfer_data_type(layout, attributes)
|
||||
draw_transfer_data_type(layout, parent)
|
||||
|
Loading…
Reference in New Issue
Block a user