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 63 additions and 3 deletions
Showing only changes of commit 42d888a732 - Show all commits

View File

@ -14,6 +14,7 @@ TASK_LAYER_NAMES = [item[1] for item in TASK_LAYER_TYPES]
TRANSFER_DATA_TYPES = [
("NONE", "None", ""),
("GROUP_VERTEX", "Vertex Group", ""),
("GROUP_VCOL", "Color Attribute", ""),
("MODIFIER", "Modifier", ""),
("CONSTRAINT", "Constraint", ""),
("MATERIAL", "Material Slot", ""),
@ -22,9 +23,10 @@ TRANSFER_DATA_TYPES = [
TRANSFER_DATA_KEYS = [item[0] for item in TRANSFER_DATA_TYPES]
VERTEX_GROUP_KEY = TRANSFER_DATA_KEYS[1]
MODIFIER_KEY = TRANSFER_DATA_KEYS[2]
CONSTRAINT_KEY = TRANSFER_DATA_KEYS[3]
MATERIAL_SLOT_KEY = TRANSFER_DATA_KEYS[4]
VERTEX_COLOR_KEY = TRANSFER_DATA_KEYS[2]
MODIFIER_KEY = TRANSFER_DATA_KEYS[3]
CONSTRAINT_KEY = TRANSFER_DATA_KEYS[4]
MATERIAL_SLOT_KEY = TRANSFER_DATA_KEYS[5]
PUBLISH_TYPES = [

View File

@ -53,6 +53,7 @@ def get_transfer_data(obj: bpy.types.Object, task_layer_name: str, temp_transfer
transfer_functions.get_material_slots(obj, task_layer_name, temp_transfer_data)
transfer_functions.get_modifiers(obj, task_layer_name, temp_transfer_data)
transfer_functions.get_constraints(obj, task_layer_name, temp_transfer_data)
transfer_functions.get_vertex_colors(obj, task_layer_name, temp_transfer_data)
def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
@ -81,6 +82,12 @@ def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
obj_target=target_obj,
obj_source=item.id_data,
)
if item.type == constants.VERTEX_COLOR_KEY:
transfer_functions.transfer_vertex_colors(
vertex_color_name=item.name,
obj_target=target_obj,
obj_source=item.id_data,
)
if item.type == constants.MODIFIER_KEY:
print(f"Transfering Data {constants.MODIFIER_KEY}: {name}")
transfer_functions.transfer_modifier(item, target_obj)

View File

@ -59,6 +59,53 @@ def transfer_vertex_group(
)
def vertex_color_is_missing(item):
obj = item.id_data
if item.type == constants.VERTEX_COLOR_KEY and not obj.data.vertex_colors.get(
item["name"]
):
return True
def get_vertex_colors(obj, task_layer_name, new_transfer_data):
ownership = obj.transfer_data_ownership
if not obj.type == "MESH":
return
for vertex_color in obj.data.vertex_colors:
# Only add new ownership item if vertex color doesn't have an owner
matches = transfer_core.check_transfer_data_entry(
ownership, vertex_color.name, constants.VERTEX_COLOR_KEY
)
if len(matches) == 0:
item = new_transfer_data.add()
item.name = vertex_color.name
item.owner = task_layer_name
item.type = constants.VERTEX_COLOR_KEY
item.obj = obj
def transfer_vertex_colors(
vertex_color_name: str,
obj_target: bpy.types.Object,
obj_source: bpy.types.Object,
):
old_color = obj_target.data.vertex_colors.get(vertex_color_name)
if old_color:
obj_target.data.vertex_colors.remove(old_color)
transfer_color = obj_source.data.vertex_colors.get(vertex_color_name)
new_color = obj_target.data.vertex_colors.new(
name=transfer_color.name, do_init=False
)
for loop in obj_target.data.loops:
new_color.data[loop.index].color = transfer_color.data[loop.index].color
# ABOVE FOR LOOP IS FOR TOPOLOGY THAT MATCHES
# BELOW COMMENTED OUT CODE IS FOR TOPOLOGY THAT DOESN'T MATCH
# else:
# for vcol_from in obj_source.data.vertex_colors:
# vcol_to = obj_target.data.vertex_colors.new(name=vcol_from.name, do_init=False)
# transfer_corner_data(obj_source, obj_target, vcol_from.data, vcol_to.data, data_suffix = 'color')
# MODIFIERS
def modifiers_is_missing(item):
obj = item.id_data

View File

@ -21,6 +21,7 @@ def draw_transfer_data(
) -> None:
"""Draw UI List of Transfer Data"""
vertex_groups = []
vertex_colors = []
material_slots = []
modifiers = []
constraints = []
@ -28,6 +29,8 @@ def draw_transfer_data(
for item in ownership:
if item.type == constants.VERTEX_GROUP_KEY:
vertex_groups.append(item)
if item.type == constants.VERTEX_COLOR_KEY:
vertex_colors.append(item)
if item.type == constants.MATERIAL_SLOT_KEY:
material_slots.append(item)
if item.type == constants.MODIFIER_KEY:
@ -36,6 +39,7 @@ def draw_transfer_data(
constraints.append(item)
draw_transfer_data_type(layout, vertex_groups)
draw_transfer_data_type(layout, vertex_colors)
draw_transfer_data_type(layout, modifiers)
draw_transfer_data_type(layout, material_slots)
draw_transfer_data_type(layout, constraints)