Asset Pipeline v2 #145
@ -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"
|
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"
|
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"
|
NONE_KEY = "NONE"
|
||||||
VERTEX_GROUP_KEY = "GROUP_VERTEX"
|
VERTEX_GROUP_KEY = "GROUP_VERTEX"
|
||||||
MODIFIER_KEY = "MODIFIER"
|
MODIFIER_KEY = "MODIFIER"
|
||||||
@ -40,9 +62,31 @@ TRANSFER_DATA_TYPES_ENUM_ITEMS = [
|
|||||||
for i, tup in enumerate(TRANSFER_DATA_TYPES.items())
|
for i, tup in enumerate(TRANSFER_DATA_TYPES.items())
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# Name used in all material transferable data
|
||||||
MATERIAL_TRANSFER_DATA_ITEM_NAME = "All Materials"
|
MATERIAL_TRANSFER_DATA_ITEM_NAME = "All Materials"
|
||||||
|
|
||||||
|
# Name used in parent transferable data
|
||||||
PARENT_TRANSFER_DATA_ITEM_NAME = "Parent Relationship"
|
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_TYPES = [
|
||||||
(
|
(
|
||||||
"publish",
|
"publish",
|
||||||
@ -64,15 +108,3 @@ PUBLISH_TYPES = [
|
|||||||
PUBLISH_KEYS = [pub_type[0] for pub_type in PUBLISH_TYPES]
|
PUBLISH_KEYS = [pub_type[0] for pub_type in PUBLISH_TYPES]
|
||||||
ACTIVE_PUBLISH_KEY = PUBLISH_KEYS[0]
|
ACTIVE_PUBLISH_KEY = PUBLISH_KEYS[0]
|
||||||
STAGED_PUBLISH_KEY = PUBLISH_KEYS[1]
|
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"
|
|
||||||
|
@ -24,7 +24,6 @@ from .util import get_storage_of_id
|
|||||||
from .. import constants, config
|
from .. import constants, config
|
||||||
from .util import data_type_from_transfer_data_key
|
from .util import data_type_from_transfer_data_key
|
||||||
|
|
||||||
DELIMITER = "."
|
|
||||||
|
|
||||||
def merge_get_target_suffix(suffix: str) -> str:
|
def merge_get_target_suffix(suffix: str) -> str:
|
||||||
"""Get the corrisponding suffix for a given suffix
|
"""Get the corrisponding suffix for a given suffix
|
||||||
@ -52,7 +51,7 @@ def merge_get_target_name(name: str) -> str:
|
|||||||
Returns:
|
Returns:
|
||||||
str: Returns datablock name with the opposite suffix
|
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)
|
new = merge_get_target_suffix(old)
|
||||||
li = name.rsplit(old, 1)
|
li = name.rsplit(old, 1)
|
||||||
return new.join(li)
|
return new.join(li)
|
||||||
@ -63,11 +62,13 @@ def merge_get_basename(name: str) -> str:
|
|||||||
if name.endswith(constants.LOCAL_SUFFIX) or name.endswith(
|
if name.endswith(constants.LOCAL_SUFFIX) or name.endswith(
|
||||||
constants.EXTERNAL_SUFFIX
|
constants.EXTERNAL_SUFFIX
|
||||||
):
|
):
|
||||||
return DELIMITER.join(name.split(DELIMITER)[:-1])
|
return constants.MERGE_DELIMITER.join(
|
||||||
|
name.split(constants.MERGE_DELIMITER)[:-1]
|
||||||
|
)
|
||||||
return name
|
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
|
"""Removes the suffix after a set delimiter from all datablocks
|
||||||
referenced by a collection, itself included
|
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_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()
|
ref_map = get_id_reference_map()
|
||||||
datablocks = get_all_referenced_ids(collection, ref_map)
|
datablocks = get_all_referenced_ids(collection, ref_map)
|
||||||
@ -110,7 +111,7 @@ def merge_add_suffix_to_hierarchy(
|
|||||||
continue
|
continue
|
||||||
collision_db = get_storage_of_id(db).get(db.name + suffix)
|
collision_db = get_storage_of_id(db).get(db.name + suffix)
|
||||||
if collision_db:
|
if collision_db:
|
||||||
collision_db.name += f'{DELIMITER}OLD'
|
collision_db.name += f'{constants.MERGE_DELIMITER}OLD'
|
||||||
try:
|
try:
|
||||||
db.name += suffix
|
db.name += suffix
|
||||||
except:
|
except:
|
||||||
@ -129,9 +130,11 @@ def asset_prefix_name_get(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 + constants.DELIMITER):
|
if name.startswith(asset_pipe.prefix + constants.NAME_DELIMITER):
|
||||||
return name
|
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
|
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:
|
for task_layer_key in config.TASK_LAYER_TYPES:
|
||||||
if name.startswith(
|
if name.startswith(
|
||||||
config.TASK_LAYER_TYPES[task_layer_key] + constants.DELIMITER
|
config.TASK_LAYER_TYPES[task_layer_key] + constants.NAME_DELIMITER
|
||||||
):
|
):
|
||||||
return name
|
return name
|
||||||
prefix = config.TASK_LAYER_TYPES[task_layer_owner]
|
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:
|
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:
|
for task_layer_key in config.TASK_LAYER_TYPES:
|
||||||
if name.startswith(
|
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
|
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)
|
td_data = data_type_from_transfer_data_key(obj, transfer_data_item.type)
|
||||||
base_name = task_layer_prefix_basename_get(transfer_data_item.name)
|
base_name = task_layer_prefix_basename_get(transfer_data_item.name)
|
||||||
prefix = config.TASK_LAYER_TYPES[transfer_data_item.owner]
|
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):
|
if new_name == transfer_data_item.name or not td_data.get(transfer_data_item.name):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ from .sync import (
|
|||||||
sync_execute_pull,
|
sync_execute_pull,
|
||||||
sync_execute_push,
|
sync_execute_push,
|
||||||
)
|
)
|
||||||
|
from . import constants
|
||||||
|
|
||||||
|
|
||||||
class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
|
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
|
asset_col = self._asset_pipe.asset_collection
|
||||||
name = (
|
name = (
|
||||||
asset_col.name
|
asset_col.name
|
||||||
if "-" not in asset_col.name
|
if constants.NAME_DELIMITER not in asset_col.name
|
||||||
else asset_col.name.split("-", 1)[1]
|
else asset_col.name.split(constants.NAME_DELIMITER, 1)[1]
|
||||||
)
|
)
|
||||||
prefix = (
|
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:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user