Asset Pipeline v2 #145
@ -101,9 +101,9 @@ class AssetTransferMapping:
|
|||||||
coll_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
|
coll_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
|
||||||
|
|
||||||
local_tl_names = [
|
local_tl_names = [
|
||||||
core.get_name_with_asset_prefix(tl_type[1])
|
core.get_name_with_asset_prefix(tl_ui_name)
|
||||||
for tl_type in constants.TASK_LAYER_TYPES
|
for tl_key, tl_ui_name in constants.TASK_LAYER_TYPES.items()
|
||||||
if tl_type[0] in self._local_tls
|
if tl_key in self._local_tls
|
||||||
]
|
]
|
||||||
|
|
||||||
for local_task_layer_col in self._local_col.children:
|
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 Tie this into props and generate based on JSON file instead
|
||||||
# TODO Met to change this
|
|
||||||
TASK_LAYER_TYPES = [
|
# Information about configured task layers.
|
||||||
("NONE", "None", ""),
|
# Task Layers are not much more than a name in this dict;
|
||||||
("MODEL", "Modeling", ""),
|
# There is no behaviour that is specific to a particular task layer.
|
||||||
("RIG", "Rigging", ""),
|
# You could even choose to name your task layers after artists in your team.
|
||||||
("SHADE", "Shading", ""),
|
# {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]
|
VERTEX_GROUP_KEY = "GROUP_VERTEX"
|
||||||
TASK_LAYER_NAMES = [task_layer[1] for task_layer in TASK_LAYER_TYPES]
|
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
|
# Information about supported transferable data.
|
||||||
TRANSFER_DATA_TYPES = [
|
# {Key string : ("UI Name", 'ICON')}
|
||||||
("NONE", "None", ""),
|
TRANSFER_DATA_TYPES = {
|
||||||
("GROUP_VERTEX", "Vertex Group", ""),
|
"NONE": ("None", "BLANK1"),
|
||||||
("COLOR_ATTRIBUTE", "Color Attribute", ""),
|
VERTEX_GROUP_KEY: ("Vertex Group", 'GROUP_VERTEX'),
|
||||||
("MODIFIER", "Modifier", ""),
|
VERTEX_COLOR_KEY: ("Color Attribute", 'GROUP_VCOL'),
|
||||||
("CONSTRAINT", "Constraint", ""),
|
MODIFIER_KEY: ("Modifier", 'MODIFIER'),
|
||||||
("MATERIAL", "Material Slot", ""),
|
CONSTRAINT_KEY: ("Constraint", 'CONSTRAINT'),
|
||||||
("UV_MAP", "UV Maps", ""),
|
MATERIAL_SLOT_KEY: ("Material Slot", 'MATERIAL'),
|
||||||
("SHAPE_KEY", "Shape Key", ""),
|
UV_LAYERS_KEY: ("UV Maps", 'GROUP_UVS'),
|
||||||
("ATTRIBUTE", "Attribute", ""),
|
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]
|
# 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.
|
||||||
VERTEX_GROUP_KEY = TRANSFER_DATA_KEYS[1]
|
TRANSFER_DATA_TYPES_ENUM_ITEMS = [
|
||||||
VERTEX_COLOR_KEY = TRANSFER_DATA_KEYS[2]
|
(tup[0], tup[1][0], tup[1][0], tup[1][1], i)
|
||||||
MODIFIER_KEY = TRANSFER_DATA_KEYS[3]
|
for i, tup in enumerate(TRANSFER_DATA_TYPES.items())
|
||||||
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", ""),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
MATERIAL_TRANSFER_INFO_NAME = "All Material Slots"
|
MATERIAL_TRANSFER_INFO_NAME = "All Material Slots"
|
||||||
|
@ -21,7 +21,7 @@ def ownership_transfer_data_cleanup(
|
|||||||
transfer_data = obj.transfer_data_ownership
|
transfer_data = obj.transfer_data_ownership
|
||||||
to_remove = []
|
to_remove = []
|
||||||
for transfer_info in transfer_data:
|
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):
|
if transfer_core.transfer_data_is_missing(transfer_info):
|
||||||
to_remove.append(transfer_info.name)
|
to_remove.append(transfer_info.name)
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ def get_invalid_objects(
|
|||||||
|
|
||||||
def get_task_layer_col_name(task_layer_key):
|
def get_task_layer_col_name(task_layer_key):
|
||||||
# TODO Docstring and return types
|
# 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)
|
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}']")
|
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.name = self._name
|
||||||
asset_pipe.prefix = self._prefix
|
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":
|
if task_layer_key == "NONE":
|
||||||
continue
|
continue
|
||||||
col_name = core.get_task_layer_col_name(task_layer_key)
|
col_name = core.get_task_layer_col_name(task_layer_key)
|
||||||
bpy.data.collections.new(col_name)
|
bpy.data.collections.new(col_name)
|
||||||
asset_col.children.link(bpy.data.collections.get(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":
|
if task_layer_key == "NONE":
|
||||||
continue
|
continue
|
||||||
name = self._name + "." + task_layer_key + ".blend"
|
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
|
asset_pipe.task_layer_name = task_layer_key
|
||||||
bpy.ops.wm.save_as_mainfile(filepath=task_layer_file, copy=True)
|
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"
|
asset_pipe.task_layer_name = "NONE"
|
||||||
publish_path = os.path.join(asset_path, constants.ACTIVE_PUBLISH_KEY)
|
publish_path = os.path.join(asset_path, constants.ACTIVE_PUBLISH_KEY)
|
||||||
name = self._name + "." + "v001" + ".blend"
|
name = self._name + "." + "v001" + ".blend"
|
||||||
@ -236,7 +236,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
|
|||||||
|
|
||||||
local_tls = [
|
local_tls = [
|
||||||
task_layer
|
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
|
if task_layer != task_layer_key
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -11,11 +11,11 @@ class AssetTransferData(bpy.types.PropertyGroup):
|
|||||||
|
|
||||||
owner: bpy.props.EnumProperty(
|
owner: bpy.props.EnumProperty(
|
||||||
name="Transfer Data Owner",
|
name="Transfer Data Owner",
|
||||||
items=constants.TASK_LAYER_TYPES,
|
items=constants.TASK_LAYER_TYPES_ENUM_ITEMS,
|
||||||
)
|
)
|
||||||
type: bpy.props.EnumProperty(
|
type: bpy.props.EnumProperty(
|
||||||
name="Transfer Data Type",
|
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(
|
owner: bpy.props.EnumProperty(
|
||||||
name="Transfer Data Owner",
|
name="Transfer Data Owner",
|
||||||
items=constants.TASK_LAYER_TYPES,
|
items=constants.TASK_LAYER_TYPES_ENUM_ITEMS,
|
||||||
)
|
)
|
||||||
type: bpy.props.EnumProperty(
|
type: bpy.props.EnumProperty(
|
||||||
name="Transfer Data Type",
|
name="Transfer Data Type",
|
||||||
items=constants.TRANSFER_DATA_TYPES,
|
items=constants.TRANSFER_DATA_TYPES_ENUM_ITEMS,
|
||||||
)
|
)
|
||||||
obj: bpy.props.PointerProperty(type=bpy.types.Object)
|
obj: bpy.props.PointerProperty(type=bpy.types.Object)
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class AssetPipeline(bpy.types.PropertyGroup):
|
|||||||
|
|
||||||
# TODO Rename to Current_Task_Layer
|
# TODO Rename to Current_Task_Layer
|
||||||
task_layer_name: bpy.props.EnumProperty(
|
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):
|
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.Scene.asset_pipeline = bpy.props.PointerProperty(type=AssetPipeline)
|
||||||
bpy.types.Object.asset_id_owner = bpy.props.EnumProperty(
|
bpy.types.Object.asset_id_owner = bpy.props.EnumProperty(
|
||||||
name="ID Owner",
|
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"""
|
"""Draw UI Element for items of a transfer data type"""
|
||||||
if transfer_data == []:
|
if transfer_data == []:
|
||||||
return
|
return
|
||||||
name = core.get_dict_tuple_item(
|
name, icon = constants.TRANSFER_DATA_TYPES[transfer_data[0].type]
|
||||||
constants.TRANSFER_DATA_TYPES, transfer_data[0].type
|
|
||||||
)[1]
|
|
||||||
box = layout.box()
|
box = layout.box()
|
||||||
icon = core.get_dict_tuple_item(
|
|
||||||
constants.TRANSFER_DATA_ICONS, transfer_data[0].type
|
|
||||||
)[1]
|
|
||||||
box.label(text=name, icon=icon)
|
box.label(text=name, icon=icon)
|
||||||
for transfer_info in transfer_data:
|
for transfer_info in transfer_data:
|
||||||
owner = core.get_dict_tuple_item(
|
owner_tl_ui_name = constants.TASK_LAYER_TYPES[transfer_info.owner]
|
||||||
constants.TASK_LAYER_TYPES, transfer_info.owner
|
box.label(text=f"{transfer_info.name}: '{owner_tl_ui_name}'")
|
||||||
)[1]
|
|
||||||
box.label(text=f"{transfer_info.name}: '{owner}'")
|
|
||||||
|
|
||||||
|
|
||||||
def draw_transfer_data(
|
def draw_transfer_data(
|
||||||
|
@ -65,10 +65,8 @@ class ASSETPIPE_ownership_inspector(bpy.types.Panel):
|
|||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
transfer_data = obj.transfer_data_ownership
|
transfer_data = obj.transfer_data_ownership
|
||||||
layout = layout.box()
|
layout = layout.box()
|
||||||
owner = core.get_dict_tuple_item(
|
owner_tl_ui_name = constants.TASK_LAYER_TYPES[obj.asset_id_owner]
|
||||||
constants.TASK_LAYER_TYPES, obj.asset_id_owner
|
layout.label(text=f"{obj.name}: '{owner_tl_ui_name}'", icon="OBJECT_DATA")
|
||||||
)[1]
|
|
||||||
layout.label(text=f"{obj.name}: '{owner}'", icon="OBJECT_DATA")
|
|
||||||
transfer_ui.draw_transfer_data(transfer_data, layout)
|
transfer_ui.draw_transfer_data(transfer_data, layout)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user