mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
changed is_visible to lib.is_visible
This commit is contained in:
parent
fc7006911c
commit
2182f3f238
3 changed files with 45 additions and 88 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import os
|
||||
import re
|
||||
import pyblish.api
|
||||
|
||||
VERBOSE = False
|
||||
|
|
@ -10,6 +12,27 @@ def is_cache_resource(resource):
|
|||
return required.issubset(tags)
|
||||
|
||||
|
||||
def valdidate_files(files):
|
||||
for f in files:
|
||||
assert os.path.exists(f)
|
||||
assert f.endswith(".mcx") or f.endswith(".mcc")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def filter_ticks(files):
|
||||
tick_files = set()
|
||||
ticks = set()
|
||||
for path in files:
|
||||
match = re.match(".+Tick([0-9]+).mcx$", os.path.basename(path))
|
||||
if match:
|
||||
tick_files.add(path)
|
||||
num = match.group(1)
|
||||
ticks.add(int(num))
|
||||
|
||||
return tick_files, ticks
|
||||
|
||||
|
||||
class ValidateInstancerFrameRanges(pyblish.api.InstancePlugin):
|
||||
"""Validates all instancer particle systems are cached correctly.
|
||||
|
||||
|
|
@ -26,7 +49,6 @@ class ValidateInstancerFrameRanges(pyblish.api.InstancePlugin):
|
|||
@classmethod
|
||||
def get_invalid(cls, instance):
|
||||
|
||||
import os
|
||||
import pyseq
|
||||
|
||||
start_frame = instance.data.get("startFrame", 0)
|
||||
|
|
@ -42,7 +64,6 @@ class ValidateInstancerFrameRanges(pyblish.api.InstancePlugin):
|
|||
|
||||
node = resource['node']
|
||||
all_files = resource['files'][:]
|
||||
|
||||
all_lookup = set(all_files)
|
||||
|
||||
# The first file is usually the .xml description file.
|
||||
|
|
@ -54,28 +75,21 @@ class ValidateInstancerFrameRanges(pyblish.api.InstancePlugin):
|
|||
|
||||
# Ensure all files exist (including ticks)
|
||||
# The remainder file paths should be the .mcx or .mcc files
|
||||
for f in all_files:
|
||||
assert os.path.exists(f)
|
||||
assert f.endswith(".mcx") or f.endswith(".mcc")
|
||||
valdidate_files(all_files)
|
||||
|
||||
# Maya particle caches support substeps by saving out additional files
|
||||
# that end with a Tick60.mcx, Tick120.mcx, etc. suffix. To avoid `pyseq`
|
||||
# getting confused we filter those out and then for each file (except
|
||||
# the last frame) check that at least all ticks exist.
|
||||
tick_files = set()
|
||||
ticks = set()
|
||||
for path in all_files:
|
||||
import re
|
||||
match = re.match(".+Tick([0-9]+).mcx$", os.path.basename(path))
|
||||
# Maya particle caches support substeps by saving out additional
|
||||
# files that end with a Tick60.mcx, Tick120.mcx, etc. suffix.
|
||||
# To avoid `pyseq` getting confused we filter those out and then
|
||||
# for each file (except the last frame) check that at least all
|
||||
# ticks exist.
|
||||
|
||||
if match:
|
||||
tick_files.add(path)
|
||||
num = match.group(1)
|
||||
ticks.add(int(num))
|
||||
tick_files, ticks = filter_ticks(all_files)
|
||||
if tick_files:
|
||||
files = [f for f in all_files if f not in tick_files]
|
||||
else:
|
||||
files = all_files
|
||||
|
||||
files = [f for f in all_files if f not in tick_files] if tick_files else all_files
|
||||
sequences = pyseq.get_sequences(files)
|
||||
|
||||
if len(sequences) != 1:
|
||||
invalid.append(node)
|
||||
cls.log.warning("More than one sequence found? "
|
||||
|
|
@ -112,7 +126,8 @@ class ValidateInstancerFrameRanges(pyblish.api.InstancePlugin):
|
|||
# for the frames required by the time range.
|
||||
if ticks:
|
||||
ticks = list(sorted(ticks))
|
||||
cls.log.info("Found ticks: {0} (substeps: {1})".format(ticks, len(ticks)))
|
||||
cls.log.info("Found ticks: {0} "
|
||||
"(substeps: {1})".format(ticks, len(ticks)))
|
||||
|
||||
# Check all frames except the last since we don't
|
||||
# require subframes after our time range.
|
||||
|
|
@ -123,7 +138,8 @@ class ValidateInstancerFrameRanges(pyblish.api.InstancePlugin):
|
|||
frame = item.frame
|
||||
if not frame:
|
||||
invalid.append(node)
|
||||
cls.log.error("Path is not a frame in sequence: {0}".format(item))
|
||||
cls.log.error("Path is not a frame in sequence: "
|
||||
"{0}".format(item))
|
||||
continue
|
||||
|
||||
# Not required for our time range
|
||||
|
|
@ -137,7 +153,8 @@ class ValidateInstancerFrameRanges(pyblish.api.InstancePlugin):
|
|||
if tick_file not in all_lookup:
|
||||
invalid.append(node)
|
||||
cls.log.warning("Tick file found that is not "
|
||||
"in cache query filenames: {0}".format(tick_file))
|
||||
"in cache query filenames: "
|
||||
"{0}".format(tick_file))
|
||||
|
||||
return invalid
|
||||
|
||||
|
|
@ -148,4 +165,4 @@ class ValidateInstancerFrameRanges(pyblish.api.InstancePlugin):
|
|||
if invalid:
|
||||
self.log.error("Invalid nodes: {0}".format(invalid))
|
||||
raise RuntimeError("Invalid particle caches in instance. "
|
||||
"See logs for details.")
|
||||
"See logs for details.")
|
||||
|
|
@ -2,66 +2,7 @@ from maya import cmds
|
|||
|
||||
import pyblish.api
|
||||
import colorbleed.api
|
||||
|
||||
|
||||
def is_visible(node,
|
||||
displayLayer=True,
|
||||
intermediateObject=True,
|
||||
parentHidden=True,
|
||||
visibility=True):
|
||||
"""Is `node` visible?
|
||||
|
||||
Returns whether a node is hidden by one of the following methods:
|
||||
- The node exists (always checked)
|
||||
- The node must be a dagNode (always checked)
|
||||
- The node's visibility is off.
|
||||
- The node is set as intermediate Object.
|
||||
- The node is in a disabled displayLayer.
|
||||
- Whether any of its parent nodes is hidden.
|
||||
|
||||
Roughly based on: http://ewertb.soundlinker.com/mel/mel.098.php
|
||||
|
||||
Returns:
|
||||
bool: Whether the node is visible in the scene
|
||||
|
||||
"""
|
||||
|
||||
# Only existing objects can be visible
|
||||
if not cmds.objExists(node):
|
||||
return False
|
||||
|
||||
# Only dagNodes can be visible
|
||||
if not cmds.objectType(node, isAType='dagNode'):
|
||||
return False
|
||||
|
||||
if visibility:
|
||||
if not cmds.getAttr('{0}.visibility'.format(node)):
|
||||
return False
|
||||
|
||||
if intermediateObject and cmds.objectType(node, isAType='shape'):
|
||||
if cmds.getAttr('{0}.intermediateObject'.format(node)):
|
||||
return False
|
||||
|
||||
if displayLayer:
|
||||
# Display layers set overrideEnabled and overrideVisibility on members
|
||||
if cmds.attributeQuery('overrideEnabled', node=node, exists=True):
|
||||
override_enabled = cmds.getAttr('{}.overrideEnabled'.format(node))
|
||||
override_visibility = cmds.getAttr('{}.overrideVisibility'.format(node))
|
||||
if override_enabled and override_visibility:
|
||||
return False
|
||||
|
||||
if parentHidden:
|
||||
parents = cmds.listRelatives(node, parent=True, fullPath=True)
|
||||
if parents:
|
||||
parent = parents[0]
|
||||
if not is_visible(parent,
|
||||
displayLayer=displayLayer,
|
||||
intermediateObject=False,
|
||||
parentHidden=parentHidden,
|
||||
visibility=visibility):
|
||||
return False
|
||||
|
||||
return True
|
||||
import colorbleed.maya.lib as lib
|
||||
|
||||
|
||||
class ValidateJointsHidden(pyblish.api.InstancePlugin):
|
||||
|
|
@ -87,7 +28,7 @@ class ValidateJointsHidden(pyblish.api.InstancePlugin):
|
|||
@staticmethod
|
||||
def get_invalid(instance):
|
||||
joints = cmds.ls(instance, type='joint', long=True)
|
||||
return [j for j in joints if is_visible(j, displayLayer=True)]
|
||||
return [j for j in joints if lib.is_visible(j, displayLayer=True)]
|
||||
|
||||
def process(self, instance):
|
||||
"""Process all the nodes in the instance 'objectSet'"""
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from maya import cmds
|
|||
|
||||
import pyblish.api
|
||||
import colorbleed.api
|
||||
from colorbleed.api import get_errored_instances_from_context
|
||||
|
||||
from cbra.utils.maya.node_uuid import get_id, add_ids
|
||||
|
||||
|
|
@ -71,10 +70,10 @@ class CopyUUIDsFromHistory(pyblish.api.Action):
|
|||
|
||||
# Get the errored instances
|
||||
self.log.info("Finding failed instances..")
|
||||
errored_instances = get_errored_instances_from_context(context)
|
||||
errored = colorbleed.api.get_errored_instances_from_context(context)
|
||||
|
||||
# Apply pyblish.logic to get the instances for the plug-in
|
||||
instances = pyblish.api.instances_by_plugin(errored_instances, plugin)
|
||||
instances = pyblish.api.instances_by_plugin(errored, plugin)
|
||||
|
||||
ids_map = dict()
|
||||
for instance in instances:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue