Asset Pipeline v2 #145
49
scripts-blender/addons/asset_pipeline_2/config.py
Normal file
49
scripts-blender/addons/asset_pipeline_2/config.py
Normal 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)
|
@ -1,16 +1,10 @@
|
|||||||
# TODO Tie this into props and generate based on JSON file instead
|
|
||||||
|
|
||||||
# Information about the list of task layers.
|
# Information about the list of task layers.
|
||||||
# There is no behaviour that is specific to a particular task layer.
|
# 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.
|
# You could even choose to name your task layers after artists in your team.
|
||||||
# {Task Layer Key: Collection/UI name}
|
# {Task Layer Key: Collection/UI name}
|
||||||
|
|
||||||
TASK_LAYER_TYPES = [
|
TASK_LAYER_CONFIG_NAME = "task_layers.json"
|
||||||
"Modeling",
|
TASK_LAYER_CONFIG_DIR_NAME = "task_layer_configs"
|
||||||
"Rigging",
|
|
||||||
"Shading",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
NONE_KEY = "NONE"
|
NONE_KEY = "NONE"
|
||||||
VERTEX_GROUP_KEY = "GROUP_VERTEX"
|
VERTEX_GROUP_KEY = "GROUP_VERTEX"
|
||||||
@ -38,21 +32,6 @@ TRANSFER_DATA_TYPES = {
|
|||||||
PARENT_KEY: ("Parent", 'FILE_PARENT'),
|
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:
|
# 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.
|
# List of 5-tuples; Re-use name as description at 3rd element, add index at 5th.
|
||||||
TRANSFER_DATA_TYPES_ENUM_ITEMS = [
|
TRANSFER_DATA_TYPES_ENUM_ITEMS = [
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
import bpy
|
import bpy
|
||||||
from bpy_extras.id_map_utils import get_id_reference_map, get_all_referenced_ids
|
from bpy_extras.id_map_utils import get_id_reference_map, get_all_referenced_ids
|
||||||
from .util import get_storage_of_id
|
from .util import get_storage_of_id
|
||||||
from .. import constants
|
from .. import constants, config
|
||||||
from .task_layer import get_default_task_layer
|
from .task_layer import get_default_task_layer
|
||||||
|
|
||||||
DELIMITER = "."
|
DELIMITER = "."
|
||||||
@ -147,7 +147,7 @@ def get_name_with_task_layer_prefix(name: str, td_type_key: str) -> str:
|
|||||||
str: Returns name with prefix
|
str: Returns name with prefix
|
||||||
"""
|
"""
|
||||||
prefix = get_default_task_layer(td_type_key)
|
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 + "."):
|
if name.startswith(task_layer_key + "."):
|
||||||
return name
|
return name
|
||||||
return prefix + "." + name
|
return prefix + "." + name
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import bpy
|
import bpy
|
||||||
from .. import constants
|
from .. import constants
|
||||||
|
from .. import config
|
||||||
|
|
||||||
|
|
||||||
def get_local_task_layers():
|
def get_local_task_layers():
|
||||||
@ -9,9 +10,9 @@ def get_local_task_layers():
|
|||||||
|
|
||||||
def get_default_task_layer(td_type: str, name=""):
|
def get_default_task_layer(td_type: str, name=""):
|
||||||
if td_type == constants.ATTRIBUTE_KEY:
|
if td_type == constants.ATTRIBUTE_KEY:
|
||||||
if name in constants.DEFAULT_OWNERSHIP_ATTRIBUTES:
|
if name in config.DEFAULT_OWNERSHIP_ATTRIBUTES:
|
||||||
return constants.DEFAULT_OWNERSHIP_ATTRIBUTES[name]
|
return config.DEFAULT_OWNERSHIP_ATTRIBUTES[name]
|
||||||
return constants.DEFAULT_OWNERSHIP[td_type]
|
return config.DEFAULT_OWNERSHIP[td_type]
|
||||||
|
|
||||||
|
|
||||||
def get_transfer_data_owner(td_type_key: str, use_default_owner: bool, name=""):
|
def get_transfer_data_owner(td_type_key: str, use_default_owner: bool, name=""):
|
||||||
|
@ -14,6 +14,7 @@ from .merge.core import (
|
|||||||
from .merge.transfer_data.transfer_ui import draw_transfer_data
|
from .merge.transfer_data.transfer_ui import draw_transfer_data
|
||||||
from .merge.shared_ids import get_shared_id_icon
|
from .merge.shared_ids import get_shared_id_icon
|
||||||
from . import constants
|
from . import constants
|
||||||
|
from . import config
|
||||||
from .merge.task_layer import get_local_task_layers
|
from .merge.task_layer import get_local_task_layers
|
||||||
|
|
||||||
|
|
||||||
@ -144,7 +145,7 @@ def sync_execute_push(self, context):
|
|||||||
|
|
||||||
local_tls = [
|
local_tls = [
|
||||||
task_layer
|
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
|
if task_layer not in self._task_layer_keys
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import bpy
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from .merge.transfer_data.transfer_ui import draw_transfer_data
|
from .merge.transfer_data.transfer_ui import draw_transfer_data
|
||||||
from .merge.task_layer import draw_task_layer_selection
|
from .merge.task_layer import draw_task_layer_selection
|
||||||
|
from .config import verify_json_data
|
||||||
|
|
||||||
|
|
||||||
class ASSETPIPE_sync(bpy.types.Panel):
|
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, "dir")
|
||||||
layout.prop(asset_pipe, "name")
|
layout.prop(asset_pipe, "name")
|
||||||
layout.prop(asset_pipe, "prefix")
|
layout.prop(asset_pipe, "prefix")
|
||||||
|
layout.prop(asset_pipe, "task_layer_config_type")
|
||||||
layout.operator("assetpipe.create_new_asset")
|
layout.operator("assetpipe.create_new_asset")
|
||||||
# layout.operator("")
|
# layout.operator("")
|
||||||
return
|
return
|
||||||
@ -26,6 +28,11 @@ class ASSETPIPE_sync(bpy.types.Panel):
|
|||||||
layout.label(text="File is not saved", icon="ERROR")
|
layout.label(text="File is not saved", icon="ERROR")
|
||||||
return
|
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.prop(asset_pipe, "asset_collection", text="Asset")
|
||||||
layout.label(text="Test UI")
|
layout.label(text="Test UI")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user