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 62 additions and 17 deletions
Showing only changes of commit e1a2847fb2 - Show all commits

View File

@ -115,6 +115,23 @@ def add_suffix_to_hierarchy(collection: bpy.types.Collection, suffix_base: str)
pass pass
# TODO Cleanup prefix doc strings
def get_name_with_prefix(name: str, prefix: str) -> str:
"""Returns a string with the prefix.
Args:
name (str): Name to add prefix to
prefix (str): Prefix to add to name
Returns:
str: Returns name with prefix
"""
if name.startswith(prefix + "."):
return name
prefix = prefix + "." if prefix != "" else ""
return prefix + name
def get_name_with_asset_prefix(name: str) -> str: def get_name_with_asset_prefix(name: str) -> str:
"""Returns a string with the prefix if it is not already set. """Returns a string with the prefix if it is not already set.
Users can specify a prefix to live on all objects during the Users can specify a prefix to live on all objects during the
@ -127,10 +144,22 @@ def get_name_with_asset_prefix(name: str) -> str:
str: Returns name with prefix str: Returns name with prefix
""" """
asset_pipe = bpy.context.scene.asset_pipeline asset_pipe = bpy.context.scene.asset_pipeline
if name.startswith(asset_pipe.prefix + "."): return get_name_with_prefix(name, asset_pipe.prefix)
return name
prefix = asset_pipe.prefix + "." if asset_pipe.prefix != "" else ""
return prefix + name def get_name_with_task_layer_prefix(name: str) -> str:
"""Returns a string with the prefix if it is not already set.
Users can specify a prefix to live on all objects during the
asset creation process. This prefix is stored in the scene.
Args:
name (str): Name to add prefix to
Returns:
str: Returns name with prefix
"""
asset_pipe = bpy.context.scene.asset_pipeline
return get_name_with_prefix(name, asset_pipe.task_layer_name)
def get_task_layer_col_name(task_layer_key) -> str: def get_task_layer_col_name(task_layer_key) -> str:

View File

@ -1,6 +1,6 @@
import bpy import bpy
from bpy import context from bpy import context
from ..naming import get_basename from ..naming import get_basename, get_name_with_task_layer_prefix
from ..drivers import find_drivers, copy_driver from ..drivers import find_drivers, copy_driver
from ..visibility import override_obj_visability from ..visibility import override_obj_visability
from .transfer_util import ( from .transfer_util import (
@ -96,12 +96,20 @@ def modifier_is_missing(transfer_data_item):
def init_modifiers(scene, obj): def init_modifiers(scene, obj):
transfer_data_item_init( td_type_key = constants.MODIFIER_KEY
scene=scene, transfer_data = obj.transfer_data_ownership
obj=obj, task_layer_key = scene.asset_pipeline.task_layer_name
data_list=obj.modifiers, for mod in obj.modifiers:
td_type_key=constants.MODIFIER_KEY, mod.name = get_name_with_task_layer_prefix(mod.name)
) # Only add new ownership transfer_data_item if vertex group doesn't have an owner
matches = check_transfer_data_entry(transfer_data, mod.name, td_type_key)
if len(matches) == 0:
scene.asset_pipeline.add_temp_transfer_data(
name=mod.name,
owner=task_layer_key,
type=td_type_key,
obj=obj,
)
def transfer_modifier(modifier_name, target_obj, source_obj): def transfer_modifier(modifier_name, target_obj, source_obj):
@ -180,12 +188,20 @@ def constraint_is_missing(transfer_data_item):
def init_constraints(scene, obj): def init_constraints(scene, obj):
transfer_data_item_init( td_type_key = constants.CONSTRAINT_KEY
scene=scene, transfer_data = obj.transfer_data_ownership
obj=obj, task_layer_key = scene.asset_pipeline.task_layer_name
data_list=obj.constraints, for const in obj.constraints:
td_type_key=constants.CONSTRAINT_KEY, const.name = get_name_with_task_layer_prefix(const.name)
) # Only add new ownership transfer_data_item if vertex group doesn't have an owner
matches = check_transfer_data_entry(transfer_data, const.name, td_type_key)
if len(matches) == 0:
scene.asset_pipeline.add_temp_transfer_data(
name=const.name,
owner=task_layer_key,
type=td_type_key,
obj=obj,
)
def transfer_constraint(constraint_name, target_obj, source_obj): def transfer_constraint(constraint_name, target_obj, source_obj):