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.
6 changed files with 66 additions and 29 deletions
Showing only changes of commit c6518a9246 - Show all commits

View File

@ -0,0 +1,49 @@
import bpy
from pathlib import Path
import json
from . import constants
TASK_LAYER_TYPES = []
DEFAULT_OWNERSHIP = {}
DEFAULT_OWNERSHIP_ATTRIBUTES = {}
def get_json_file():
directory = Path(bpy.data.filepath).parent
json_file_path = directory.joinpath(constants.TASK_LAYER_CONFIG_NAME)
if json_file_path.exists():
return json_file_path
return
def get_task_layer_presets_path():
return Path(__file__).parent.joinpath(constants.TASK_LAYER_CONFIG_DIR_NAME)
def verify_json_data(json_file_path=""):
global TASK_LAYER_TYPES
global DEFAULT_OWNERSHIP
global DEFAULT_OWNERSHIP_ATTRIBUTES
directory = Path(bpy.data.filepath).parent
if json_file_path == "":
json_file_path = directory.joinpath(constants.TASK_LAYER_CONFIG_NAME)
if not json_file_path.exists():
return
json_file = open(json_file_path)
json_content = json.load(json_file)
try:
TASK_LAYER_TYPES = json_content["TASK_LAYER_TYPES"]
DEFAULT_OWNERSHIP = json_content["DEFAULT_OWNERSHIP"]
DEFAULT_OWNERSHIP_ATTRIBUTES = json_content["DEFAULT_OWNERSHIP_ATTRIBUTES"]
return True
except KeyError:
return
def write_json_file(asset_path: Path, source_file_path: Path):
json_file_path = asset_path.joinpath(constants.TASK_LAYER_CONFIG_NAME)
json_file = open(source_file_path)
json_content = json.load(json_file)
json_dump = json.dumps(json_content, indent=4)
with open(json_file_path, "w") as config_output:
config_output.write(json_dump)

View File

@ -1,16 +1,10 @@
# TODO Tie this into props and generate based on JSON file instead
# 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}
TASK_LAYER_TYPES = [
"Modeling",
"Rigging",
"Shading",
]
TASK_LAYER_CONFIG_NAME = "task_layers.json"
TASK_LAYER_CONFIG_DIR_NAME = "task_layer_configs"
NONE_KEY = "NONE"
VERTEX_GROUP_KEY = "GROUP_VERTEX"
@ -38,21 +32,6 @@ TRANSFER_DATA_TYPES = {
PARENT_KEY: ("Parent", 'FILE_PARENT'),
}
# Default of which task layer owns each data type
DEFAULT_OWNERSHIP = {
VERTEX_GROUP_KEY: "Rigging",
MODIFIER_KEY: "Rigging",
CONSTRAINT_KEY: "Rigging",
MATERIAL_SLOT_KEY: "Shading",
SHAPE_KEY_KEY: "Modeling",
ATTRIBUTE_KEY: "Rigging",
PARENT_KEY: "Rigging",
}
DEFAULT_OWNERSHIP_ATTRIBUTES = {
"sharp_face": "Modeling",
"UVMap": "Shading", # Hard Coded name of default UVMap
}
# 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 = [

View File

@ -21,7 +21,7 @@
import bpy
from bpy_extras.id_map_utils import get_id_reference_map, get_all_referenced_ids
from .util import get_storage_of_id
from .. import constants
from .. import constants, config
from .task_layer import get_default_task_layer
DELIMITER = "."
@ -147,7 +147,7 @@ def get_name_with_task_layer_prefix(name: str, td_type_key: str) -> str:
str: Returns name with prefix
"""
prefix = get_default_task_layer(td_type_key)
for task_layer_key in constants.TASK_LAYER_TYPES:
for task_layer_key in config.TASK_LAYER_TYPES:
if name.startswith(task_layer_key + "."):
return name
return prefix + "." + name

View File

@ -1,5 +1,6 @@
import bpy
from .. import constants
from .. import config
def get_local_task_layers():
@ -9,9 +10,9 @@ def get_local_task_layers():
def get_default_task_layer(td_type: str, name=""):
if td_type == constants.ATTRIBUTE_KEY:
if name in constants.DEFAULT_OWNERSHIP_ATTRIBUTES:
return constants.DEFAULT_OWNERSHIP_ATTRIBUTES[name]
return constants.DEFAULT_OWNERSHIP[td_type]
if name in config.DEFAULT_OWNERSHIP_ATTRIBUTES:
return config.DEFAULT_OWNERSHIP_ATTRIBUTES[name]
return config.DEFAULT_OWNERSHIP[td_type]
def get_transfer_data_owner(td_type_key: str, use_default_owner: bool, name=""):

View File

@ -14,6 +14,7 @@ from .merge.core import (
from .merge.transfer_data.transfer_ui import draw_transfer_data
from .merge.shared_ids import get_shared_id_icon
from . import constants
from . import config
from .merge.task_layer import get_local_task_layers
@ -144,7 +145,7 @@ def sync_execute_push(self, context):
local_tls = [
task_layer
for task_layer in constants.TASK_LAYER_TYPES
for task_layer in config.TASK_LAYER_TYPES
if task_layer not in self._task_layer_keys
]

View File

@ -3,6 +3,7 @@ import bpy
from pathlib import Path
from .merge.transfer_data.transfer_ui import draw_transfer_data
from .merge.task_layer import draw_task_layer_selection
from .config import verify_json_data
class ASSETPIPE_sync(bpy.types.Panel):
@ -18,6 +19,7 @@ class ASSETPIPE_sync(bpy.types.Panel):
layout.prop(asset_pipe, "dir")
layout.prop(asset_pipe, "name")
layout.prop(asset_pipe, "prefix")
layout.prop(asset_pipe, "task_layer_config_type")
layout.operator("assetpipe.create_new_asset")
# layout.operator("")
return
@ -26,6 +28,11 @@ class ASSETPIPE_sync(bpy.types.Panel):
layout.label(text="File is not saved", icon="ERROR")
return
# TODO Move this call out of the UI because we keep re-loading this file every draw
if not verify_json_data():
layout.label(text="Task Layer Config is invalid", icon="ERROR")
return
layout.prop(asset_pipe, "asset_collection", text="Asset")
layout.label(text="Test UI")