mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 21:32:15 +01:00
removed backwards compatibility, update source data files
This commit is contained in:
parent
40b68f9839
commit
f810d04861
1 changed files with 9 additions and 105 deletions
|
|
@ -38,24 +38,13 @@ class YetiCacheLoader(api.Loader):
|
|||
fursettings = json.load(fp)
|
||||
|
||||
# Check if resources map exists
|
||||
# TODO: should be stored in fursettings
|
||||
image_search_path = ""
|
||||
version_folder = os.path.dirname(self.fname)
|
||||
resource_folder = os.path.join(version_folder, "resources")
|
||||
if os.path.exists(resource_folder):
|
||||
image_search_path = os.path.normpath(resource_folder)
|
||||
|
||||
# Get node name from JSON
|
||||
if "nodes" in fursettings:
|
||||
node_data = fursettings["nodes"]
|
||||
nodes = self.create_nodes(namespace, image_search_path, node_data)
|
||||
else:
|
||||
# Backwards compatibilty
|
||||
self.log.info("Encountered old data, "
|
||||
"using backwards compatibility")
|
||||
nodes = self.create_nodes_old(namespace,
|
||||
image_search_path,
|
||||
fursettings)
|
||||
if "nodes" not in fursettings:
|
||||
raise RuntimeError("Encountered invalid data, expect 'nodes' in "
|
||||
"fursettings.")
|
||||
|
||||
node_data = fursettings["nodes"]
|
||||
nodes = self.create_nodes(namespace, node_data)
|
||||
|
||||
group_name = "{}:{}".format(namespace, asset["name"])
|
||||
group_node = cmds.group(nodes, name=group_name)
|
||||
|
|
@ -148,7 +137,7 @@ class YetiCacheLoader(api.Loader):
|
|||
|
||||
return filename
|
||||
|
||||
def create_nodes(self, namespace, image_search_path, settings):
|
||||
def create_nodes(self, namespace, settings):
|
||||
|
||||
# Get node name from JSON
|
||||
nodes = []
|
||||
|
|
@ -156,8 +145,8 @@ class YetiCacheLoader(api.Loader):
|
|||
|
||||
# Create transform node
|
||||
transform = node_settings["transform"]
|
||||
transform_node = cmds.createNode("transform",
|
||||
name=transform["name"])
|
||||
transform_name = "{}:{}".format(namespace, transform["name"])
|
||||
transform_node = cmds.createNode("transform", name=transform_name)
|
||||
|
||||
lib.set_id(transform_node, transform["cbId"])
|
||||
|
||||
|
|
@ -199,91 +188,6 @@ class YetiCacheLoader(api.Loader):
|
|||
cache_path,
|
||||
type="string")
|
||||
|
||||
cmds.setAttr("%s.imageSearchPath" % yeti_node,
|
||||
image_search_path,
|
||||
type="string")
|
||||
|
||||
# Set verbosity for debug purposes
|
||||
cmds.setAttr("%s.verbosity" % yeti_node, 2)
|
||||
|
||||
# Enable the cache by setting the file mode
|
||||
cmds.setAttr("%s.fileMode" % yeti_node, 1)
|
||||
|
||||
nodes.append(yeti_node)
|
||||
nodes.append(transform_node)
|
||||
|
||||
return nodes
|
||||
|
||||
def create_nodes_old(self, namespace, image_search_path, settings):
|
||||
"""Create nodes with the old logic
|
||||
|
||||
Support previously published assets
|
||||
|
||||
Args:
|
||||
namespace(str): unique name to identify the nodes
|
||||
image_search_path (str): directory path to textures
|
||||
settings(dict): collection of node names with settings
|
||||
Returns:
|
||||
list: all created pgYetiMaya nodes and their transforms
|
||||
|
||||
"""
|
||||
|
||||
nodes = []
|
||||
for node, node_settings in settings.items():
|
||||
|
||||
# Create transform
|
||||
transform_name = "{}:{}".format(namespace, node.split("Shape")[0])
|
||||
transform_node = cmds.createNode("transform", name=transform_name)
|
||||
|
||||
# Create new pgYetiMaya node
|
||||
node_name = "{}:{}".format(namespace, node)
|
||||
yeti_node = cmds.createNode("pgYetiMaya",
|
||||
name=node_name,
|
||||
parent=transform_node)
|
||||
|
||||
cmds.connectAttr("time1.outTime", "%s.currentTime" % yeti_node)
|
||||
|
||||
# Apply explicit colorbleed ID to node
|
||||
shape_id = node_settings["cbId"]
|
||||
asset_id = shape_id.split(":", 1)[0]
|
||||
|
||||
lib.set_id(node=yeti_node,
|
||||
unique_id=shape_id,
|
||||
overwrite=True)
|
||||
node_settings.pop("cbId", None)
|
||||
|
||||
# Apply new colorbleed ID to transform node
|
||||
# TODO: get ID from transform in data to ensure consistency
|
||||
_ids = lib.generate_ids(nodes=[transform_node], asset_id=asset_id)
|
||||
for n, _id in _ids:
|
||||
lib.set_id(n, unique_id=_id)
|
||||
|
||||
# Apply settings
|
||||
for attr, value in node_settings.items():
|
||||
attribute = "%s.%s" % (yeti_node, attr)
|
||||
cmds.setAttr(attribute, value)
|
||||
|
||||
# Ensure the node has no namespace identifiers
|
||||
node = node.replace(":", "_")
|
||||
|
||||
# Create full cache path
|
||||
cache = os.path.join(self.fname, "{}.%04d.fur".format(node))
|
||||
cache = os.path.normpath(cache)
|
||||
cache_fname = self.validate_cache(cache)
|
||||
cache_path = os.path.join(self.fname, cache_fname)
|
||||
|
||||
# Preset the viewport density
|
||||
cmds.setAttr("%s.viewportDensity" % yeti_node, 0.1)
|
||||
|
||||
# Add filename to `cacheFileName` attribute
|
||||
cmds.setAttr("%s.cacheFileName" % yeti_node,
|
||||
cache_path,
|
||||
type="string")
|
||||
|
||||
cmds.setAttr("%s.imageSearchPath" % yeti_node,
|
||||
image_search_path,
|
||||
type="string")
|
||||
|
||||
# Set verbosity for debug purposes
|
||||
cmds.setAttr("%s.verbosity" % yeti_node, 2)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue