Asset Pipeline v2 #145
@ -101,9 +101,9 @@ class AssetTransferMapping:
|
||||
coll_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
|
||||
|
||||
local_tl_names = [
|
||||
core.get_name_with_asset_prefix(tl_type[1])
|
||||
for tl_type in constants.TASK_LAYER_TYPES
|
||||
if tl_type[0] in self._local_tls
|
||||
core.get_name_with_asset_prefix(tl_ui_name)
|
||||
for tl_key, tl_ui_name in constants.TASK_LAYER_TYPES.items()
|
||||
if tl_key in self._local_tls
|
||||
]
|
||||
|
||||
for local_task_layer_col in self._local_col.children:
|
||||
|
@ -1,49 +1,51 @@
|
||||
# TODO Tie this into props and generate based on JSON file instead
|
||||
# TODO Met to change this
|
||||
TASK_LAYER_TYPES = [
|
||||
("NONE", "None", ""),
|
||||
("MODEL", "Modeling", ""),
|
||||
("RIG", "Rigging", ""),
|
||||
("SHADE", "Shading", ""),
|
||||
|
||||
# Information about configured task layers.
|
||||
# Task Layers are not much more than a name in this dict;
|
||||
# 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}
|
||||
TASK_LAYER_TYPES = {
|
||||
"NONE": "None",
|
||||
"MODEL": "Modeling",
|
||||
"RIG": "Rigging",
|
||||
"SHADE": "Shading",
|
||||
}
|
||||
|
||||
# Convert it to the format that EnumProperty.items wants:
|
||||
# List of 3-tuples, re-use name as description at 3rd element.
|
||||
TASK_LAYER_TYPES_ENUM_ITEMS = [
|
||||
(key, value, value) for key, value in TASK_LAYER_TYPES.items()
|
||||
]
|
||||
|
||||
TASK_LAYER_KEYS = [task_layer[0] for task_layer in TASK_LAYER_TYPES]
|
||||
TASK_LAYER_NAMES = [task_layer[1] for task_layer in TASK_LAYER_TYPES]
|
||||
VERTEX_GROUP_KEY = "GROUP_VERTEX"
|
||||
VERTEX_COLOR_KEY = "COLOR_ATTRIBUTE"
|
||||
MODIFIER_KEY = "MODIFIER"
|
||||
CONSTRAINT_KEY = "CONSTRAINT"
|
||||
MATERIAL_SLOT_KEY = "MATERIAL"
|
||||
UV_LAYERS_KEY = "UV_MAP"
|
||||
SHAPE_KEY_KEY = "SHAPE_KEY"
|
||||
ATTRIBUTE_KEY = "ATTRIBUTE"
|
||||
|
||||
# KEYS FOR TRANSFER DATA TYPE MATCH NAME OF ICON
|
||||
TRANSFER_DATA_TYPES = [
|
||||
("NONE", "None", ""),
|
||||
("GROUP_VERTEX", "Vertex Group", ""),
|
||||
("COLOR_ATTRIBUTE", "Color Attribute", ""),
|
||||
("MODIFIER", "Modifier", ""),
|
||||
("CONSTRAINT", "Constraint", ""),
|
||||
("MATERIAL", "Material Slot", ""),
|
||||
("UV_MAP", "UV Maps", ""),
|
||||
("SHAPE_KEY", "Shape Key", ""),
|
||||
("ATTRIBUTE", "Attribute", ""),
|
||||
]
|
||||
# Information about supported transferable data.
|
||||
# {Key string : ("UI Name", 'ICON')}
|
||||
TRANSFER_DATA_TYPES = {
|
||||
"NONE": ("None", "BLANK1"),
|
||||
VERTEX_GROUP_KEY: ("Vertex Group", 'GROUP_VERTEX'),
|
||||
VERTEX_COLOR_KEY: ("Color Attribute", 'GROUP_VCOL'),
|
||||
MODIFIER_KEY: ("Modifier", 'MODIFIER'),
|
||||
CONSTRAINT_KEY: ("Constraint", 'CONSTRAINT'),
|
||||
MATERIAL_SLOT_KEY: ("Material Slot", 'MATERIAL'),
|
||||
UV_LAYERS_KEY: ("UV Maps", 'GROUP_UVS'),
|
||||
SHAPE_KEY_KEY: ("Shape Key", 'SHAPEKEY_DATA'),
|
||||
ATTRIBUTE_KEY: ("Attribute", 'EVENT_A'),
|
||||
}
|
||||
|
||||
TRANSFER_DATA_KEYS = [transfer_data[0] for transfer_data in TRANSFER_DATA_TYPES]
|
||||
|
||||
VERTEX_GROUP_KEY = TRANSFER_DATA_KEYS[1]
|
||||
VERTEX_COLOR_KEY = TRANSFER_DATA_KEYS[2]
|
||||
MODIFIER_KEY = TRANSFER_DATA_KEYS[3]
|
||||
CONSTRAINT_KEY = TRANSFER_DATA_KEYS[4]
|
||||
MATERIAL_SLOT_KEY = TRANSFER_DATA_KEYS[5]
|
||||
UV_LAYERS_KEY = TRANSFER_DATA_KEYS[6]
|
||||
SHAPE_KEY_KEY = TRANSFER_DATA_KEYS[7]
|
||||
ATTRIBUTE_KEY = TRANSFER_DATA_KEYS[8]
|
||||
|
||||
TRANSFER_DATA_ICONS = [
|
||||
("None", "NONE", ""),
|
||||
(VERTEX_GROUP_KEY, "GROUP_VERTEX", ""),
|
||||
(VERTEX_COLOR_KEY, "GROUP_VCOL", ""),
|
||||
(MODIFIER_KEY, "MODIFIER", ""),
|
||||
(CONSTRAINT_KEY, "CONSTRAINT", ""),
|
||||
(MATERIAL_SLOT_KEY, "MATERIAL", ""),
|
||||
(UV_LAYERS_KEY, "GROUP_UVS", ""),
|
||||
(SHAPE_KEY_KEY, "SHAPEKEY_DATA", ""),
|
||||
(ATTRIBUTE_KEY, "EVENT_A", ""),
|
||||
# Convert it to the format that EnumProperty.items wants:
|
||||
# List of 5-tuples; Re-use name as description at 3rd element, add index at 5th.
|
||||
TRANSFER_DATA_TYPES_ENUM_ITEMS = [
|
||||
(tup[0], tup[1][0], tup[1][0], tup[1][1], i)
|
||||
for i, tup in enumerate(TRANSFER_DATA_TYPES.items())
|
||||
]
|
||||
|
||||
MATERIAL_TRANSFER_INFO_NAME = "All Material Slots"
|
||||
|
@ -21,7 +21,7 @@ def ownership_transfer_data_cleanup(
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
to_remove = []
|
||||
for transfer_info in transfer_data:
|
||||
if constants.TASK_LAYER_KEYS[transfer_info["owner"]] == task_layer_name:
|
||||
if transfer_info.owner == task_layer_name:
|
||||
if transfer_core.transfer_data_is_missing(transfer_info):
|
||||
to_remove.append(transfer_info.name)
|
||||
|
||||
@ -102,7 +102,7 @@ def get_invalid_objects(
|
||||
|
||||
def get_task_layer_col_name(task_layer_key):
|
||||
# TODO Docstring and return types
|
||||
task_layer_name = get_dict_tuple_item(constants.TASK_LAYER_TYPES, task_layer_key)[1]
|
||||
task_layer_name = constants.TASK_LAYER_TYPES[task_layer_key]
|
||||
return get_name_with_asset_prefix(task_layer_name)
|
||||
|
||||
|
||||
@ -339,10 +339,3 @@ def import_data_from_lib(
|
||||
)
|
||||
|
||||
return eval(f"bpy.data.{data_category}['{data_name}']")
|
||||
|
||||
|
||||
def get_dict_tuple_item(dict: dict, key: str) -> tuple:
|
||||
"""For a dict of tuples, returns a dict item based on it's key"""
|
||||
for item in dict:
|
||||
if item[0] == key:
|
||||
return item
|
||||
|
@ -64,14 +64,14 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
|
||||
asset_pipe.name = self._name
|
||||
asset_pipe.prefix = self._prefix
|
||||
|
||||
for task_layer_key in constants.TASK_LAYER_KEYS:
|
||||
for task_layer_key in constants.TASK_LAYER_TYPES.keys():
|
||||
if task_layer_key == "NONE":
|
||||
continue
|
||||
col_name = core.get_task_layer_col_name(task_layer_key)
|
||||
bpy.data.collections.new(col_name)
|
||||
asset_col.children.link(bpy.data.collections.get(col_name))
|
||||
|
||||
for task_layer_key in reversed(constants.TASK_LAYER_KEYS):
|
||||
for task_layer_key in constants.TASK_LAYER_TYPES.keys():
|
||||
if task_layer_key == "NONE":
|
||||
continue
|
||||
name = self._name + "." + task_layer_key + ".blend"
|
||||
@ -79,7 +79,7 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
|
||||
asset_pipe.task_layer_name = task_layer_key
|
||||
bpy.ops.wm.save_as_mainfile(filepath=task_layer_file, copy=True)
|
||||
|
||||
# Creata intial publish based on task layers
|
||||
# Create intial publish based on task layers.
|
||||
asset_pipe.task_layer_name = "NONE"
|
||||
publish_path = os.path.join(asset_path, constants.ACTIVE_PUBLISH_KEY)
|
||||
name = self._name + "." + "v001" + ".blend"
|
||||
@ -236,7 +236,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
|
||||
|
||||
local_tls = [
|
||||
task_layer
|
||||
for task_layer in constants.TASK_LAYER_KEYS
|
||||
for task_layer in constants.TASK_LAYER_TYPES.keys()
|
||||
if task_layer != task_layer_key
|
||||
]
|
||||
|
||||
|
@ -11,11 +11,11 @@ class AssetTransferData(bpy.types.PropertyGroup):
|
||||
|
||||
owner: bpy.props.EnumProperty(
|
||||
name="Transfer Data Owner",
|
||||
items=constants.TASK_LAYER_TYPES,
|
||||
items=constants.TASK_LAYER_TYPES_ENUM_ITEMS,
|
||||
)
|
||||
type: bpy.props.EnumProperty(
|
||||
name="Transfer Data Type",
|
||||
items=constants.TRANSFER_DATA_TYPES,
|
||||
items=constants.TRANSFER_DATA_TYPES_ENUM_ITEMS,
|
||||
)
|
||||
|
||||
|
||||
@ -25,11 +25,11 @@ class AssetTransferDataTemp(bpy.types.PropertyGroup):
|
||||
|
||||
owner: bpy.props.EnumProperty(
|
||||
name="Transfer Data Owner",
|
||||
items=constants.TASK_LAYER_TYPES,
|
||||
items=constants.TASK_LAYER_TYPES_ENUM_ITEMS,
|
||||
)
|
||||
type: bpy.props.EnumProperty(
|
||||
name="Transfer Data Type",
|
||||
items=constants.TRANSFER_DATA_TYPES,
|
||||
items=constants.TRANSFER_DATA_TYPES_ENUM_ITEMS,
|
||||
)
|
||||
obj: bpy.props.PointerProperty(type=bpy.types.Object)
|
||||
|
||||
@ -53,7 +53,7 @@ class AssetPipeline(bpy.types.PropertyGroup):
|
||||
|
||||
# TODO Rename to Current_Task_Layer
|
||||
task_layer_name: bpy.props.EnumProperty(
|
||||
name="Task Layer Name", items=constants.TASK_LAYER_TYPES
|
||||
name="Task Layer Name", items=constants.TASK_LAYER_TYPES_ENUM_ITEMS
|
||||
)
|
||||
|
||||
def add_temp_trasnfer_data(self, name, owner, type, obj):
|
||||
@ -94,7 +94,7 @@ def register():
|
||||
bpy.types.Scene.asset_pipeline = bpy.props.PointerProperty(type=AssetPipeline)
|
||||
bpy.types.Object.asset_id_owner = bpy.props.EnumProperty(
|
||||
name="ID Owner",
|
||||
items=constants.TASK_LAYER_TYPES,
|
||||
items=constants.TASK_LAYER_TYPES_ENUM_ITEMS,
|
||||
)
|
||||
|
||||
|
||||
|
@ -8,19 +8,12 @@ def draw_transfer_data_type(
|
||||
"""Draw UI Element for items of a transfer data type"""
|
||||
if transfer_data == []:
|
||||
return
|
||||
name = core.get_dict_tuple_item(
|
||||
constants.TRANSFER_DATA_TYPES, transfer_data[0].type
|
||||
)[1]
|
||||
name, icon = constants.TRANSFER_DATA_TYPES[transfer_data[0].type]
|
||||
box = layout.box()
|
||||
icon = core.get_dict_tuple_item(
|
||||
constants.TRANSFER_DATA_ICONS, transfer_data[0].type
|
||||
)[1]
|
||||
box.label(text=name, icon=icon)
|
||||
for transfer_info in transfer_data:
|
||||
owner = core.get_dict_tuple_item(
|
||||
constants.TASK_LAYER_TYPES, transfer_info.owner
|
||||
)[1]
|
||||
box.label(text=f"{transfer_info.name}: '{owner}'")
|
||||
owner_tl_ui_name = constants.TASK_LAYER_TYPES[transfer_info.owner]
|
||||
box.label(text=f"{transfer_info.name}: '{owner_tl_ui_name}'")
|
||||
|
||||
|
||||
def draw_transfer_data(
|
||||
|
@ -65,10 +65,8 @@ class ASSETPIPE_ownership_inspector(bpy.types.Panel):
|
||||
obj = context.active_object
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
layout = layout.box()
|
||||
owner = core.get_dict_tuple_item(
|
||||
constants.TASK_LAYER_TYPES, obj.asset_id_owner
|
||||
)[1]
|
||||
layout.label(text=f"{obj.name}: '{owner}'", icon="OBJECT_DATA")
|
||||
owner_tl_ui_name = constants.TASK_LAYER_TYPES[obj.asset_id_owner]
|
||||
layout.label(text=f"{obj.name}: '{owner_tl_ui_name}'", icon="OBJECT_DATA")
|
||||
transfer_ui.draw_transfer_data(transfer_data, layout)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user