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 73 additions and 35 deletions
Showing only changes of commit 8efea36eac - Show all commits

View File

@ -1,15 +1,37 @@
# Information about the list of task layers.
# There is no behaviour that is specific to a particular task layer.
# You could even choose to name your task layers after artists in your team.
# {Task Layer Key: Collection/UI name}
ADDON_NAME = "asset_pipeline_2"
TASK_LAYER_CONFIG_NAME = "task_layers.json"
# Delimiter used for naming data within Blender
NAME_DELIMITER = "-"
###################
# MERGE
###################
# Delimiter used by suffixes in the merge process
MERGE_DELIMITER = "."
# Suffixes used when naming items to merge
LOCAL_SUFFIX = "LOCAL"
EXTERNAL_SUFFIX = "EXTERNAL"
###################
# Task Layers
###################
# Name of directory containing task layer prefixes internal to add-on
TASK_LAYER_CONFIG_DIR_NAME = "task_layer_configs"
DELIMITER = "-"
# Name of task layer file found a the root of an asset
TASK_LAYER_CONFIG_NAME = "task_layers.json"
###################
# Transferable Data
###################
# Keys for transferable data
NONE_KEY = "NONE"
VERTEX_GROUP_KEY = "GROUP_VERTEX"
MODIFIER_KEY = "MODIFIER"
@ -40,9 +62,31 @@ TRANSFER_DATA_TYPES_ENUM_ITEMS = [
for i, tup in enumerate(TRANSFER_DATA_TYPES.items())
]
# Name used in all material transferable data
MATERIAL_TRANSFER_DATA_ITEM_NAME = "All Materials"
# Name used in parent transferable data
PARENT_TRANSFER_DATA_ITEM_NAME = "Parent Relationship"
MATERIAL_ATTRIBUTE_NAME = "material_index"
###################
# SHARED IDs
###################
# SHARED ID Icons
GEO_NODE = "GEOMETRY_NODES"
IMAGE = "IMAGE_DATA"
BLANK = "BLANK1"
###################
# Publish
###################
# List of different states used when Publishing a Final Asset
PUBLISH_TYPES = [
(
"publish",
@ -64,15 +108,3 @@ PUBLISH_TYPES = [
PUBLISH_KEYS = [pub_type[0] for pub_type in PUBLISH_TYPES]
ACTIVE_PUBLISH_KEY = PUBLISH_KEYS[0]
STAGED_PUBLISH_KEY = PUBLISH_KEYS[1]
LOCAL_SUFFIX = "LOCAL"
EXTERNAL_SUFFIX = "EXTERNAL"
MATERIAL_ATTRIBUTE_NAME = "material_index"
## SHARED ID Icons
GEO_NODE = "GEOMETRY_NODES"
IMAGE = "IMAGE_DATA"
BLANK = "BLANK1"

View File

@ -24,7 +24,6 @@ from .util import get_storage_of_id
from .. import constants, config
from .util import data_type_from_transfer_data_key
DELIMITER = "."
def merge_get_target_suffix(suffix: str) -> str:
"""Get the corrisponding suffix for a given suffix
@ -52,7 +51,7 @@ def merge_get_target_name(name: str) -> str:
Returns:
str: Returns datablock name with the opposite suffix
"""
old = name.split(DELIMITER)[-1]
old = name.split(constants.MERGE_DELIMITER)[-1]
new = merge_get_target_suffix(old)
li = name.rsplit(old, 1)
return new.join(li)
@ -63,11 +62,13 @@ def merge_get_basename(name: str) -> str:
if name.endswith(constants.LOCAL_SUFFIX) or name.endswith(
constants.EXTERNAL_SUFFIX
):
return DELIMITER.join(name.split(DELIMITER)[:-1])
return constants.MERGE_DELIMITER.join(
name.split(constants.MERGE_DELIMITER)[:-1]
)
return name
def remove_suffix_from_hierarchy(collection: bpy.types.Collection) -> None:
def merge_remove_suffix_from_hierarchy(collection: bpy.types.Collection) -> None:
"""Removes the suffix after a set delimiter from all datablocks
referenced by a collection, itself included
@ -99,7 +100,7 @@ def merge_add_suffix_to_hierarchy(
suffix_base (str): Suffix to append to collection and items linked to collection
"""
suffix = f"{DELIMITER}{suffix_base}"
suffix = f"{constants.MERGE_DELIMITER}{suffix_base}"
ref_map = get_id_reference_map()
datablocks = get_all_referenced_ids(collection, ref_map)
@ -110,7 +111,7 @@ def merge_add_suffix_to_hierarchy(
continue
collision_db = get_storage_of_id(db).get(db.name + suffix)
if collision_db:
collision_db.name += f'{DELIMITER}OLD'
collision_db.name += f'{constants.MERGE_DELIMITER}OLD'
try:
db.name += suffix
except:
@ -129,9 +130,11 @@ def asset_prefix_name_get(name: str) -> str:
str: Returns name with prefix
"""
asset_pipe = bpy.context.scene.asset_pipeline
if name.startswith(asset_pipe.prefix + constants.DELIMITER):
if name.startswith(asset_pipe.prefix + constants.NAME_DELIMITER):
return name
prefix = asset_pipe.prefix + constants.DELIMITER if asset_pipe.prefix != "" else ""
prefix = (
asset_pipe.prefix + constants.NAME_DELIMITER if asset_pipe.prefix != "" else ""
)
return prefix + name
@ -149,11 +152,11 @@ def task_layer_prefix_name_get(name: str, task_layer_owner: str) -> str:
"""
for task_layer_key in config.TASK_LAYER_TYPES:
if name.startswith(
config.TASK_LAYER_TYPES[task_layer_key] + constants.DELIMITER
config.TASK_LAYER_TYPES[task_layer_key] + constants.NAME_DELIMITER
):
return name
prefix = config.TASK_LAYER_TYPES[task_layer_owner]
return prefix + constants.DELIMITER + name
return prefix + constants.NAME_DELIMITER + name
def task_layer_prefix_basename_get(name: str) -> str:
@ -169,9 +172,9 @@ def task_layer_prefix_basename_get(name: str) -> str:
"""
for task_layer_key in config.TASK_LAYER_TYPES:
if name.startswith(
config.TASK_LAYER_TYPES[task_layer_key] + constants.DELIMITER
config.TASK_LAYER_TYPES[task_layer_key] + constants.NAME_DELIMITER
):
return name.replace(name.split(constants.DELIMITER)[0], "")[1:]
return name.replace(name.split(constants.NAME_DELIMITER)[0], "")[1:]
return name
@ -197,7 +200,7 @@ def task_layer_prefix_transfer_data_update(
td_data = data_type_from_transfer_data_key(obj, transfer_data_item.type)
base_name = task_layer_prefix_basename_get(transfer_data_item.name)
prefix = config.TASK_LAYER_TYPES[transfer_data_item.owner]
new_name = prefix + constants.DELIMITER + base_name
new_name = prefix + constants.NAME_DELIMITER + base_name
if new_name == transfer_data_item.name or not td_data.get(transfer_data_item.name):
return

View File

@ -17,6 +17,7 @@ from .sync import (
sync_execute_pull,
sync_execute_push,
)
from . import constants
class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
@ -77,11 +78,13 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
asset_col = self._asset_pipe.asset_collection
name = (
asset_col.name
if "-" not in asset_col.name
else asset_col.name.split("-", 1)[1]
if constants.NAME_DELIMITER not in asset_col.name
else asset_col.name.split(constants.NAME_DELIMITER, 1)[1]
)
prefix = (
"" if "-" not in asset_col.name else asset_col.name.split("-", 1)[0]
""
if constants.NAME_DELIMITER not in asset_col.name
else asset_col.name.split(constants.NAME_DELIMITER, 1)[0]
)
else: