Asset Pipeline v2 #145
@ -69,12 +69,17 @@ def merge_task_layer(
|
||||
transfer_data,
|
||||
target_col,
|
||||
)
|
||||
|
||||
remap_users(context)
|
||||
|
||||
bpy.ops.outliner.orphans_purge(
|
||||
do_local_ids=True, do_linked_ids=False, do_recursive=True
|
||||
)
|
||||
|
||||
# TODO DEBUG WHY REMAP USERS SOMETIMES REPLACES LOCAL OBJ WITH SOURCE OBJ
|
||||
# ADDING A PURGE BEFORE THIS FIXES IT FOR SOME REASON?
|
||||
remap_users(context)
|
||||
|
||||
# bpy.ops.outliner.orphans_purge(
|
||||
# do_local_ids=True, do_linked_ids=False, do_recursive=True
|
||||
# )
|
||||
asset_suffix.remove_suffix_from_hierarchy(target_col)
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import bpy
|
||||
from bpy import context
|
||||
from . import asset_suffix
|
||||
|
||||
|
||||
def transfer_vertex_group(
|
||||
@ -78,3 +79,45 @@ def transfer_modifier(item, obj_target):
|
||||
{"object": obj_target, "active_object": obj_target},
|
||||
modifier=mod.name,
|
||||
)
|
||||
|
||||
|
||||
def transfer_material_slot(item, obj_target):
|
||||
obj_source = item.id
|
||||
# Delete existing material slot if exists
|
||||
for idx in range(len(obj_source.material_slots)):
|
||||
slot = obj_source.material_slots[idx]
|
||||
if asset_suffix.get_asset_basename(slot.material.name) == item.name:
|
||||
obj_target.active_material_index = idx
|
||||
bpy.ops.object.material_slot_remove({"object": obj_target})
|
||||
|
||||
# Transfer material slots
|
||||
|
||||
for idx in range(len(obj_source.material_slots)):
|
||||
if idx >= len(obj_target.material_slots):
|
||||
slot = obj_source.material_slots[idx]
|
||||
if asset_suffix.get_asset_basename(slot.material.name) == item.name:
|
||||
bpy.ops.object.material_slot_add({"object": obj_target})
|
||||
obj_target.material_slots[idx].link = obj_source.material_slots[
|
||||
idx
|
||||
].link
|
||||
obj_target.material_slots[idx].material = obj_source.material_slots[
|
||||
idx
|
||||
].material
|
||||
|
||||
# Transfer active material slot index
|
||||
obj_target.active_material_index = obj_source.active_material_index
|
||||
|
||||
# Transfer material slot assignments for curve
|
||||
if obj_target.type == "CURVE":
|
||||
for spl_to, spl_from in zip(obj_target.data.splines, obj_source.data.splines):
|
||||
spl_to.material_index = spl_from.material_index
|
||||
|
||||
# TODO MAKE USE_ABLE AGAIN
|
||||
# # Rest of the loop applies only to meshes.
|
||||
# if obj_target.type != "MESH":
|
||||
# continue
|
||||
|
||||
# # Transfer material slot assignments for mesh
|
||||
# for pol_to, pol_from in zip(obj_target.data.polygons, obj_source.data.polygons):
|
||||
# pol_to.material_index = pol_from.material_index
|
||||
# pol_to.use_smooth = pol_from.use_smooth
|
||||
|
@ -33,6 +33,8 @@ def apply_transfer_data(
|
||||
)
|
||||
if item.type == "MODIFIER":
|
||||
transfer_functions.transfer_modifier(item, target_obj)
|
||||
if item.type == "MATERIAL_SLOT":
|
||||
transfer_functions.transfer_material_slot(item, target_obj)
|
||||
update_transfer_data_ownership(
|
||||
transfer_data_item=item,
|
||||
target_obj=target_obj,
|
||||
|
Loading…
Reference in New Issue
Block a user