From 1d94607037bad9393fb9ed82fae2842bbe66a626 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Thu, 30 Dec 2021 16:57:42 +0100 Subject: [PATCH] Optimize validation speed for dense polymeshes (especially those that have locked normal) --- .../publish/validate_mesh_normals_unlocked.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/validate_mesh_normals_unlocked.py b/openpype/hosts/maya/plugins/publish/validate_mesh_normals_unlocked.py index b14781b608..750932df54 100644 --- a/openpype/hosts/maya/plugins/publish/validate_mesh_normals_unlocked.py +++ b/openpype/hosts/maya/plugins/publish/validate_mesh_normals_unlocked.py @@ -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):