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.
2 changed files with 16 additions and 20 deletions
Showing only changes of commit 28f51c2c1d - Show all commits

View File

@ -72,3 +72,6 @@ STAGED_PUBLISH_KEY = PUBLISH_KEYS[1]
LOCAL_SUFFIX = "LOCAL"
EXTERNAL_SUFFIX = "EXTERNAL"
MATERIAL_ATTRIBUTE_NAME = "material_index"

View File

@ -47,6 +47,7 @@ def transfer_vertex_group(
source_obj.vertex_groups.active = source_obj.vertex_groups.get(vertex_group_name)
# TODO Debug crashing / use context.temp_override(object=obj) style
# https://projects.blender.org/blender/blender/issues/112299
context = bpy.context
override = context.copy()
override["selected_editable_objects"] = [target_obj, source_obj]
@ -295,11 +296,7 @@ def material_slots_clean(obj):
if transfer_data_list != []:
return
for mat_slot in obj.material_slots:
index = obj.material_slots.keys().index(mat_slot.name)
obj.active_material_index = index
with context.temp_override(object=obj):
bpy.ops.object.material_slot_remove()
obj.data.materials.clear()
def material_slots_is_missing(transfer_info):
@ -330,25 +327,14 @@ def init_material_slots(scene, obj):
)
def transfer_material_slots(target_obj, source_obj):
# Delete existing material slot if exists
context = bpy.context
# Transfer material slot assignments.
def transfer_material_slots(target_obj: bpy.types.Object, source_obj):
# Delete all material slots of target object.
while len(target_obj.material_slots) > len(source_obj.material_slots):
target_obj.active_material_index = len(source_obj.material_slots)
with context.temp_override(object=target_obj):
bpy.ops.object.material_slot_remove()
target_obj.data.materials.clear()
# Transfer material slots
for idx in range(len(source_obj.material_slots)):
if idx >= len(target_obj.material_slots):
with context.temp_override(object=target_obj):
bpy.ops.object.material_slot_add()
target_obj.data.materials.append(source_obj.material_slots[idx].material)
target_obj.material_slots[idx].link = source_obj.material_slots[idx].link
target_obj.material_slots[idx].material = source_obj.material_slots[
idx
].material
# Transfer active material slot index
target_obj.active_material_index = source_obj.active_material_index
@ -358,6 +344,9 @@ def transfer_material_slots(target_obj, source_obj):
for spl_to, spl_from in zip(target_obj.data.splines, source_obj.data.splines):
spl_to.material_index = spl_from.material_index
if source_obj.data.attributes.get(constants.MATERIAL_ATTRIBUTE_NAME):
transfer_attribute(constants.MATERIAL_ATTRIBUTE_NAME, target_obj, source_obj)
# SHAPE KEYS
@ -515,7 +504,11 @@ def transfer_shape_key(
def attributes_get_editable(attributes):
# TODO replace 'position' HACK with is_required once https://projects.blender.org/blender/blender/pulls/111468 is merged
return [
item for item in attributes if not (item.is_internal or item.name == 'position')
item
for item in attributes
if not (
item.is_internal or item.name == 'position' or item.name == 'material_index'
)
]