Optimize validation speed for dense polymeshes (especially those that have locked normal)

This commit is contained in:
Roy Nieterau 2021-12-30 16:57:42 +01:00
parent b2d6011d21
commit 1d94607037

View file

@ -1,4 +1,5 @@
from maya import cmds
import maya.api.OpenMaya as om2
import pyblish.api
import openpype.api
@ -25,10 +26,16 @@ class ValidateMeshNormalsUnlocked(pyblish.api.Validator):
@staticmethod
def has_locked_normals(mesh):
"""Return whether a mesh node has locked normals"""
return any(cmds.polyNormalPerVertex("{}.vtxFace[*][*]".format(mesh),
query=True,
freezeNormal=True))
"""Return whether mesh has at least one locked normal"""
sel = om2.MGlobal.getSelectionListByName(mesh)
node = sel.getDependNode(0)
fn_mesh = om2.MFnMesh(node)
_, normal_ids = fn_mesh.getNormalIds()
for normal_id in normal_ids:
if fn_mesh.isNormalLocked(normal_id):
return True
return False
@classmethod
def get_invalid(cls, instance):