Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Maya: Validate NGONs simplify and speed-up #2458

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions openpype/hosts/maya/plugins/publish/validate_mesh_ngons.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@
from openpype.hosts.maya.api import lib


def polyConstraint(objects, *args, **kwargs):
kwargs.pop('mode', None)

with lib.no_undo(flush=False):
with maya.maintained_selection():
with lib.reset_polySelectConstraint():
cmds.select(objects, r=1, noExpand=True)
# Acting as 'polyCleanupArgList' for n-sided polygon selection
cmds.polySelectConstraint(*args, mode=3, **kwargs)
result = cmds.ls(selection=True)
cmds.select(clear=True)

return result


class ValidateMeshNgons(pyblish.api.Validator):
"""Ensure that meshes don't have ngons

Expand All @@ -41,8 +26,17 @@ class ValidateMeshNgons(pyblish.api.Validator):
@staticmethod
def get_invalid(instance):

meshes = cmds.ls(instance, type='mesh')
return polyConstraint(meshes, type=8, size=3)
meshes = cmds.ls(instance, type='mesh', long=True)

# Get all faces
faces = ['{0}.f[*]'.format(node) for node in meshes]

# Filter to n-sided polygon faces (ngons)
invalid = lib.polyConstraint(faces,
t=0x0008, # type=face
size=3) # size=nsided

return invalid

def process(self, instance):
"""Process all the nodes in the instance "objectSet"""
Expand Down