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 61 additions and 55 deletions
Showing only changes of commit bc1f797942 - Show all commits

View File

@ -1,6 +1,6 @@
import bpy
from . import asset_suffix, transferable_data
from . import asset_suffix, transferable_data, transfer_functions
from pathlib import Path
from typing import Dict
from .asset_mapping import AssetTransferMapping
@ -11,9 +11,9 @@ 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)
transfer_functions.get_vertex_groups(obj, task_layer_name, new_transfer_data)
transfer_functions.get_material_slots(obj, task_layer_name, new_transfer_data)
transfer_functions.get_modifiers(obj, task_layer_name, new_transfer_data)
return new_transfer_data

View File

@ -1,6 +1,28 @@
import bpy
from bpy import context
from . import asset_suffix
from . import asset_suffix, transferable_data
## FUNCTIONS SPECFIC TO TRANSFER DATA TYPES
# VERTEX GROUPS
def get_vertex_groups(obj, task_layer_name, new_transfer_data):
ownership = obj.transfer_data_ownership
for vertex_group in obj.vertex_groups:
# Only add new ownership item if vertex group doesn't have an owner
matches = transferable_data.check_transfer_data_entry(
ownership, vertex_group.name, "VERTEX_GROUP"
)
if len(matches) == 0:
# NEED UNIQUE NAME INCASE OF DUPLICATES
name = vertex_group.name + '_' + obj.name
new_transfer_data[name] = (
ownership,
vertex_group.name,
"VERTEX_GROUP",
task_layer_name,
)
def transfer_vertex_group(
@ -31,6 +53,23 @@ def transfer_vertex_group(
)
# MODIFIERS
def get_modifiers(obj, task_layer_name, new_transfer_data):
ownership = obj.transfer_data_ownership
for mod in obj.modifiers:
matches = transferable_data.check_transfer_data_entry(
ownership, mod.name, "MODIFIER"
)
if len(matches) == 0:
name = mod.name + '_' + obj.name
new_transfer_data[name] = (
ownership,
mod.name,
"MODIFIER",
task_layer_name,
)
def transfer_modifier(item, obj_target):
# remove old and sync existing modifiers
obj_source = item.id_data
@ -88,6 +127,23 @@ def transfer_modifier(item, obj_target):
)
# MATERIAL SLOT
def get_material_slots(obj, task_layer_name, new_transfer_data):
ownership = obj.transfer_data_ownership
for slot in obj.material_slots:
matches = transferable_data.check_transfer_data_entry(
ownership, slot.name, "MATERIAL_SLOT"
)
if len(matches) == 0:
name = slot.name + '_' + obj.name
new_transfer_data[name] = (
ownership,
slot.name,
"MATERIAL_SLOT",
task_layer_name,
)
def transfer_material_slot(item, obj_target):
obj_source = item.id_data
if obj_source == obj_target:

View File

@ -56,53 +56,3 @@ def transfer_data_add_entry(ownership, name, td_type, task_layer_name):
item.name = name
item.owner = task_layer_name.upper()
item.type = td_type
## FUNCTIONS SPECFIC TO TRANSFER DATA TYPES
# VERTEX GROUPS
def get_vertex_groups(obj, task_layer_name, new_transfer_data):
ownership = obj.transfer_data_ownership
for vertex_group in obj.vertex_groups:
# Only add new ownership item if vertex group doesn't have an owner
matches = check_transfer_data_entry(
ownership, vertex_group.name, "VERTEX_GROUP"
)
if len(matches) == 0:
# NEED UNIQUE NAME INCASE OF DUPLICATES
name = vertex_group.name + '_' + obj.name
new_transfer_data[name] = (
ownership,
vertex_group.name,
"VERTEX_GROUP",
task_layer_name,
)
# MODIFIERS
def get_modifiers(obj, task_layer_name, new_transfer_data):
ownership = obj.transfer_data_ownership
for mod in obj.modifiers:
matches = check_transfer_data_entry(ownership, mod.name, "MODIFIER")
if len(matches) == 0:
name = mod.name + '_' + obj.name
new_transfer_data[name] = (
ownership,
mod.name,
"MODIFIER",
task_layer_name,
)
# MATERIAL SLOT
def get_material_slots(obj, task_layer_name, new_transfer_data):
ownership = obj.transfer_data_ownership
for slot in obj.material_slots:
matches = check_transfer_data_entry(ownership, slot.name, "MATERIAL_SLOT")
if len(matches) == 0:
name = slot.name + '_' + obj.name
new_transfer_data[name] = (
ownership,
slot.name,
"MATERIAL_SLOT",
task_layer_name,
)