Bases: MayaInstancePlugin
, OptionalPyblishPluginMixin
Ensure that meshes don't have a negative scale.
Using negatively scaled proxies in a VRayMesh results in inverted normals. As such we want to avoid this.
We also avoid this on the rig or model because these are often the previous steps for those that are cached to proxies so we can catch this issue early.
Source code in client/ayon_maya/plugins/publish/validate_mesh_no_negative_scale.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 | class ValidateMeshNoNegativeScale(plugin.MayaInstancePlugin,
OptionalPyblishPluginMixin):
"""Ensure that meshes don't have a negative scale.
Using negatively scaled proxies in a VRayMesh results in inverted
normals. As such we want to avoid this.
We also avoid this on the rig or model because these are often the
previous steps for those that are cached to proxies so we can catch this
issue early.
"""
order = ValidateMeshOrder
families = ['model']
label = 'Mesh No Negative Scale'
actions = [ayon_maya.api.action.SelectInvalidAction]
optional = False
@staticmethod
def get_invalid(instance):
meshes = cmds.ls(instance,
type='mesh',
long=True,
noIntermediate=True)
invalid = []
for mesh in meshes:
transform = cmds.listRelatives(mesh, parent=True, fullPath=True)[0]
scale = cmds.getAttr("{0}.scale".format(transform))[0]
if any(x < 0 for x in scale):
invalid.append(mesh)
return invalid
def process(self, instance):
"""Process all the nodes in the instance 'objectSet'"""
if not self.is_active(instance.data):
return
invalid = self.get_invalid(instance)
if invalid:
raise PublishValidationError(
"Meshes found with negative scale:\n\n{0}".format(
_as_report_list(sorted(invalid))
),
title="Negative scale"
)
|
process(instance)
Process all the nodes in the instance 'objectSet'
Source code in client/ayon_maya/plugins/publish/validate_mesh_no_negative_scale.py
54
55
56
57
58
59
60
61
62
63
64
65
66 | def process(self, instance):
"""Process all the nodes in the instance 'objectSet'"""
if not self.is_active(instance.data):
return
invalid = self.get_invalid(instance)
if invalid:
raise PublishValidationError(
"Meshes found with negative scale:\n\n{0}".format(
_as_report_list(sorted(invalid))
),
title="Negative scale"
)
|