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.
3 changed files with 51 additions and 13 deletions
Showing only changes of commit d9c4dd1ad2 - Show all commits

View File

@ -2,12 +2,27 @@ import bpy
from . import asset_suffix, transferable_data from . import asset_suffix, transferable_data
from pathlib import Path from pathlib import Path
from typing import Dict
from .asset_mapping import AssetTransferMapping from .asset_mapping import AssetTransferMapping
from . import constants from . import constants
def get_ownership(local_col: str, task_layer_name: str):
new_transfer_data: Dict[bpy.props.CollectionProperty, str, str, str, str] = {}
for obj in local_col.all_objects:
transferable_data.get_vertex_groups(obj, task_layer_name, new_transfer_data)
transferable_data.get_material_slots(obj, task_layer_name, new_transfer_data)
transferable_data.get_modifiers(obj, task_layer_name, new_transfer_data)
return new_transfer_data
def set_ownership(new_transfer_data):
for data in new_transfer_data:
item = new_transfer_data[data]
transferable_data.transfer_data_add_entry(item[0], item[1], item[2], item[3])
def remap_user(source_datablock: bpy.data, target_datablock: bpy.data): def remap_user(source_datablock: bpy.data, target_datablock: bpy.data):
"""Remap datablock and append name to datablock that has been remapped""" """Remap datablock and append name to datablock that has been remapped"""
print(f"REMAPPING {source_datablock.name} to {target_datablock.name}") print(f"REMAPPING {source_datablock.name} to {target_datablock.name}")

View File

@ -21,14 +21,19 @@ class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
bl_label = 'Update Ownership' bl_label = 'Update Ownership'
def execute(self, context): def execute(self, context):
obj = context.active_object # TODO LOOP OVER ALl COllECTION OBJECTS
# TODO CREATE UI TO CONFIRM NEW OWNERSHIP ITEMS
local_col = bpy.data.collections.get(get_parent_col_name())
if not local_col:
self.report({'ERROR'}, "Top level collection could not be found")
return {'CANCELLED'}
task_layer_name = get_task_layer_name_from_file() task_layer_name = get_task_layer_name_from_file()
if not task_layer_name: if not task_layer_name:
self.report({'ERROR'}, "Current File Name doesn't contain valid task layer") self.report({'ERROR'}, "Current File Name doesn't contain valid task layer")
return {'CANCELLED'} return {'CANCELLED'}
transferable_data.vertex_groups_update(obj, task_layer_name)
transferable_data.modifiers_update(obj, task_layer_name) new_data = core.get_ownership(local_col, task_layer_name)
transferable_data.material_slot_update(obj, task_layer_name) core.set_ownership(new_data)
return {'FINISHED'} return {'FINISHED'}

View File

@ -1,9 +1,12 @@
import bpy import bpy
from . import transfer_functions, asset_suffix from . import transfer_functions, asset_suffix
from typing import Dict
# TODO Consider using transfer mapping here instead of matching suffixes # TODO Consider using transfer mapping here instead of matching suffixes
def update_transfer_data_ownership(transfer_data_item, target_obj: bpy.types.Object): def update_transfer_data_ownership(transfer_data_item, target_obj: bpy.types.Object):
ownership = target_obj.transfer_data_ownership ownership = target_obj.transfer_data_ownership
transfer_items_names = [item.name for item in ownership] transfer_items_names = [item.name for item in ownership]
@ -57,7 +60,7 @@ def transfer_data_add_entry(ownership, name, td_type, task_layer_name):
## FUNCTIONS SPECFIC TO TRANSFER DATA TYPES ## FUNCTIONS SPECFIC TO TRANSFER DATA TYPES
# VERTEX GROUPS # VERTEX GROUPS
def vertex_groups_update(obj, task_layer_name): def get_vertex_groups(obj, task_layer_name, new_transfer_data):
ownership = obj.transfer_data_ownership ownership = obj.transfer_data_ownership
for vertex_group in obj.vertex_groups: for vertex_group in obj.vertex_groups:
# Only add new ownership item if vertex group doesn't have an owner # Only add new ownership item if vertex group doesn't have an owner
@ -65,26 +68,41 @@ def vertex_groups_update(obj, task_layer_name):
ownership, vertex_group.name, "VERTEX_GROUP" ownership, vertex_group.name, "VERTEX_GROUP"
) )
if len(matches) == 0: if len(matches) == 0:
transfer_data_add_entry( # NEED UNIQUE NAME INCASE OF DUPLICATES
ownership, vertex_group.name, "VERTEX_GROUP", task_layer_name name = vertex_group.name + '_' + obj.name
new_transfer_data[name] = (
ownership,
vertex_group.name,
"VERTEX_GROUP",
task_layer_name,
) )
# MODIFIERS # MODIFIERS
def modifiers_update(obj, task_layer_name): def get_modifiers(obj, task_layer_name, new_transfer_data):
ownership = obj.transfer_data_ownership ownership = obj.transfer_data_ownership
for mod in obj.modifiers: for mod in obj.modifiers:
matches = check_transfer_data_entry(ownership, mod.name, "MODIFIER") matches = check_transfer_data_entry(ownership, mod.name, "MODIFIER")
if len(matches) == 0: if len(matches) == 0:
transfer_data_add_entry(ownership, mod.name, "MODIFIER", task_layer_name) name = mod.name + '_' + obj.name
new_transfer_data[name] = (
ownership,
mod.name,
"MODIFIER",
task_layer_name,
)
# MATERIAL SLOT # MATERIAL SLOT
def material_slot_update(obj, task_layer_name): def get_material_slots(obj, task_layer_name, new_transfer_data):
ownership = obj.transfer_data_ownership ownership = obj.transfer_data_ownership
for slot in obj.material_slots: for slot in obj.material_slots:
matches = check_transfer_data_entry(ownership, slot.name, "MATERIAL_SLOT") matches = check_transfer_data_entry(ownership, slot.name, "MATERIAL_SLOT")
if len(matches) == 0: if len(matches) == 0:
transfer_data_add_entry( name = slot.name + '_' + obj.name
ownership, slot.name, "MATERIAL_SLOT", task_layer_name new_transfer_data[name] = (
ownership,
slot.name,
"MATERIAL_SLOT",
task_layer_name,
) )