mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
validate the mesh has uv
This commit is contained in:
parent
4a785268c8
commit
2c0cb76f35
3 changed files with 55 additions and 1 deletions
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
import pyblish.api
|
||||
from ayon_core.hosts.max.api.action import SelectInvalidAction
|
||||
from ayon_core.pipeline.publish import (
|
||||
ValidateMeshOrder,
|
||||
OptionalPyblishPluginMixin,
|
||||
PublishValidationError
|
||||
)
|
||||
from pymxs import runtime as rt
|
||||
|
||||
|
||||
class ValidateMeshHasUVs(pyblish.api.InstancePlugin,
|
||||
OptionalPyblishPluginMixin):
|
||||
|
||||
"""Validate the current mesh has UVs.
|
||||
|
||||
It validates whether the current UV set has non-zero UVs and
|
||||
at least more than the vertex count. It's not really bulletproof,
|
||||
but a simple quick validation to check if there are likely
|
||||
UVs for every face.
|
||||
"""
|
||||
|
||||
order = ValidateMeshOrder
|
||||
hosts = ['max']
|
||||
families = ['model']
|
||||
label = 'Validate Mesh Has UVs'
|
||||
actions = [SelectInvalidAction]
|
||||
optional = True
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_invalid(cls, instance):
|
||||
invalid = [member for member in instance.data["members"]
|
||||
if not member.mesh.numTVerts > 0]
|
||||
return invalid
|
||||
|
||||
def process(self, instance):
|
||||
invalid = self.get_invalid(instance)
|
||||
if invalid:
|
||||
raise PublishValidationError(
|
||||
title="Mesh has missing UVs",
|
||||
message="Model meshes are required to have UVs.<br><br>"
|
||||
"Meshes detected with invalid or missing UVs:<br>"
|
||||
"{0}".format(invalid)
|
||||
)
|
||||
|
|
@ -86,6 +86,10 @@ class PublishersModel(BaseSettingsModel):
|
|||
default_factory=ValidateLoadedPluginModel,
|
||||
title="Validate Loaded Plugin"
|
||||
)
|
||||
ValidateMeshHasUVs: BasicValidateModel = SettingsField(
|
||||
default_factory=BasicValidateModel,
|
||||
title="Validate Mesh Has UVs"
|
||||
)
|
||||
ExtractModelObj: BasicValidateModel = SettingsField(
|
||||
default_factory=BasicValidateModel,
|
||||
title="Extract OBJ",
|
||||
|
|
@ -134,6 +138,11 @@ DEFAULT_PUBLISH_SETTINGS = {
|
|||
"optional": True,
|
||||
"family_plugins_mapping": []
|
||||
},
|
||||
"ValidateMeshHasUVs": {
|
||||
"enabled": True,
|
||||
"optional": True,
|
||||
"active": False
|
||||
},
|
||||
"ExtractModelObj": {
|
||||
"enabled": True,
|
||||
"optional": True,
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
__version__ = "0.1.5"
|
||||
__version__ = "0.1.6"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue