mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 21:32:15 +01:00
improved method of getting illegal transform node
This commit is contained in:
parent
721ef1edc8
commit
d63a75fdeb
1 changed files with 41 additions and 21 deletions
|
|
@ -1,47 +1,67 @@
|
|||
import pyblish.api
|
||||
import colorbleed.api
|
||||
|
||||
|
||||
class CollectSetDress(pyblish.api.InstancePlugin):
|
||||
"""Collect all relevant setdress items
|
||||
class ValidateSetDressModelTransforms(pyblish.api.InstancePlugin):
|
||||
"""Verify only root nodes of the loaded asset have transformations.
|
||||
|
||||
Collected data:
|
||||
Note: This check is temporary and is subject to change.
|
||||
|
||||
* File name
|
||||
* Compatible loader
|
||||
* Matrix per instance
|
||||
* Namespace
|
||||
Example outliner:
|
||||
<> means referenced
|
||||
===================================================================
|
||||
|
||||
Note: GPU caches are currently not supported in the pipeline. There is no
|
||||
logic yet which supports the swapping of GPU cache to renderable objects.
|
||||
setdress_GRP|
|
||||
props_GRP|
|
||||
barrel_01_:modelDefault| [can have transforms]
|
||||
<> barrel_01_:barrel_GRP [CAN'T have transforms]
|
||||
|
||||
fence_01_:modelDefault| [can have transforms]
|
||||
<> fence_01_:fence_GRP [CAN'T have transforms]
|
||||
|
||||
"""
|
||||
|
||||
order = pyblish.api.CollectorOrder + 0.49
|
||||
label = "Transformation of Items"
|
||||
order = pyblish.api.ValidatorOrder + 0.49
|
||||
label = "Setdress Model Transforms"
|
||||
families = ["colorbleed.setdress"]
|
||||
actions = [colorbleed.api.SelectInvalidAction]
|
||||
|
||||
def process(self, instance):
|
||||
invalid = self.get_invalid(instance)
|
||||
if invalid:
|
||||
raise RuntimeError("Found invalid transforms of setdress items")
|
||||
raise RuntimeError("Found %s invalid transforms of setdress items")
|
||||
|
||||
@classmethod
|
||||
def get_invalid(cls, instance):
|
||||
|
||||
from colorbleed.maya import lib
|
||||
import colorbleed.maya.lib as lib
|
||||
from maya import cmds
|
||||
|
||||
invalid = []
|
||||
|
||||
setdress_hierarchies = instance.data["hierarchy"]
|
||||
items = cmds.listRelatives(instance,
|
||||
allDescendents=True,
|
||||
type="transform",
|
||||
fullPath=True)
|
||||
for item in items:
|
||||
if item in setdress_hierarchies:
|
||||
continue
|
||||
# Get all transforms in the loaded containers
|
||||
container_roots = cmds.listRelatives(instance.data["hierarchy"],
|
||||
children=True,
|
||||
type="transform",
|
||||
fullPath=True)
|
||||
|
||||
transforms_in_container = cmds.listRelatives(container_roots,
|
||||
allDescendents=True,
|
||||
type="transform",
|
||||
fullPath=True)
|
||||
|
||||
# Extra check due to the container roots still being passed through
|
||||
transforms_in_container = [i for i in transforms_in_container if i
|
||||
not in container_roots]
|
||||
|
||||
# Ensure all are identity matrix
|
||||
for transform in transforms_in_container:
|
||||
node_matrix = cmds.xform(transform,
|
||||
query=True,
|
||||
matrix=True,
|
||||
objectSpace=True)
|
||||
if not lib.matrix_equals(node_matrix, lib.DEFAULT_MATRIX):
|
||||
print transform
|
||||
invalid.append(transform)
|
||||
|
||||
return invalid
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue