Asset Pipeline v2 #145
@ -1,6 +1,6 @@
|
|||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
from . import asset_suffix, transferable_data
|
from . import asset_suffix, transferable_data, transfer_functions
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from .asset_mapping import AssetTransferMapping
|
from .asset_mapping import AssetTransferMapping
|
||||||
@ -11,9 +11,9 @@ from . import constants
|
|||||||
def get_ownership(local_col: str, task_layer_name: str):
|
def get_ownership(local_col: str, task_layer_name: str):
|
||||||
new_transfer_data: Dict[bpy.props.CollectionProperty, str, str, str, str] = {}
|
new_transfer_data: Dict[bpy.props.CollectionProperty, str, str, str, str] = {}
|
||||||
for obj in local_col.all_objects:
|
for obj in local_col.all_objects:
|
||||||
transferable_data.get_vertex_groups(obj, task_layer_name, new_transfer_data)
|
transfer_functions.get_vertex_groups(obj, task_layer_name, new_transfer_data)
|
||||||
transferable_data.get_material_slots(obj, task_layer_name, new_transfer_data)
|
transfer_functions.get_material_slots(obj, task_layer_name, new_transfer_data)
|
||||||
transferable_data.get_modifiers(obj, task_layer_name, new_transfer_data)
|
transfer_functions.get_modifiers(obj, task_layer_name, new_transfer_data)
|
||||||
return new_transfer_data
|
return new_transfer_data
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,28 @@
|
|||||||
import bpy
|
import bpy
|
||||||
from bpy import context
|
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(
|
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):
|
def transfer_modifier(item, obj_target):
|
||||||
# remove old and sync existing modifiers
|
# remove old and sync existing modifiers
|
||||||
obj_source = item.id_data
|
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):
|
def transfer_material_slot(item, obj_target):
|
||||||
obj_source = item.id_data
|
obj_source = item.id_data
|
||||||
if obj_source == obj_target:
|
if obj_source == obj_target:
|
||||||
|
@ -56,53 +56,3 @@ def transfer_data_add_entry(ownership, name, td_type, task_layer_name):
|
|||||||
item.name = name
|
item.name = name
|
||||||
item.owner = task_layer_name.upper()
|
item.owner = task_layer_name.upper()
|
||||||
item.type = td_type
|
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,
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user