TVPaint: Optional Validation plugins can be de/activated by user (#4674)

* fix TVPaint validation plugins so they can be enabled/disabled

* add missing 'is_active' method usage

* added option to enable auto detet render creator

* added fps to instance data

* safe access to layers

* fix handling of missing render layer

* render passes are safer

* fix convertor plugin
This commit is contained in:
Jakub Trllo 2023-03-27 09:57:37 +02:00 committed by GitHub
parent 4820bcb227
commit 09e0ba54f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 63 additions and 18 deletions

View file

@ -55,7 +55,7 @@ class TVPaintLegacyConverted(SubsetConvertorPlugin):
self._convert_render_layers(
to_convert["renderLayer"], current_instances)
self._convert_render_passes(
to_convert["renderpass"], current_instances)
to_convert["renderPass"], current_instances)
self._convert_render_scenes(
to_convert["renderScene"], current_instances)
self._convert_workfiles(
@ -116,7 +116,7 @@ class TVPaintLegacyConverted(SubsetConvertorPlugin):
render_layers_by_group_id = {}
for instance in current_instances:
if instance.get("creator_identifier") == "render.layer":
group_id = instance["creator_identifier"]["group_id"]
group_id = instance["creator_attributes"]["group_id"]
render_layers_by_group_id[group_id] = instance
for render_pass in render_passes:

View file

@ -415,11 +415,11 @@ class CreateRenderPass(TVPaintCreator):
.get("creator_attributes", {})
.get("render_layer_instance_id")
)
render_layer_info = render_layers.get(render_layer_instance_id)
render_layer_info = render_layers.get(render_layer_instance_id, {})
self.update_instance_labels(
instance_data,
render_layer_info["variant"],
render_layer_info["template_data"]
render_layer_info.get("variant"),
render_layer_info.get("template_data")
)
instance = CreatedInstance.from_existing(instance_data, self)
self._add_instance_to_context(instance)
@ -607,11 +607,11 @@ class CreateRenderPass(TVPaintCreator):
current_instances = self.host.list_instances()
render_layers = [
{
"value": instance["instance_id"],
"label": instance["subset"]
"value": inst["instance_id"],
"label": inst["subset"]
}
for instance in current_instances
if instance["creator_identifier"] == CreateRenderlayer.identifier
for inst in current_instances
if inst.get("creator_identifier") == CreateRenderlayer.identifier
]
if not render_layers:
render_layers.append({"value": None, "label": "N/A"})
@ -697,6 +697,7 @@ class TVPaintAutoDetectRenderCreator(TVPaintCreator):
["create"]
["auto_detect_render"]
)
self.enabled = plugin_settings.get("enabled", False)
self.allow_group_rename = plugin_settings["allow_group_rename"]
self.group_name_template = plugin_settings["group_name_template"]
self.group_idx_offset = plugin_settings["group_idx_offset"]

View file

@ -22,9 +22,11 @@ class CollectOutputFrameRange(pyblish.api.InstancePlugin):
context = instance.context
frame_start = asset_doc["data"]["frameStart"]
fps = asset_doc["data"]["fps"]
frame_end = frame_start + (
context.data["sceneMarkOut"] - context.data["sceneMarkIn"]
)
instance.data["fps"] = fps
instance.data["frameStart"] = frame_start
instance.data["frameEnd"] = frame_end
self.log.info(

View file

@ -1,5 +1,8 @@
import pyblish.api
from openpype.pipeline import PublishXmlValidationError
from openpype.pipeline import (
PublishXmlValidationError,
OptionalPyblishPluginMixin,
)
from openpype.hosts.tvpaint.api.pipeline import (
list_instances,
write_instances,
@ -31,7 +34,10 @@ class FixAssetNames(pyblish.api.Action):
write_instances(new_instance_items)
class ValidateAssetNames(pyblish.api.ContextPlugin):
class ValidateAssetName(
OptionalPyblishPluginMixin,
pyblish.api.ContextPlugin
):
"""Validate assset name present on instance.
Asset name on instance should be the same as context's.
@ -43,6 +49,8 @@ class ValidateAssetNames(pyblish.api.ContextPlugin):
actions = [FixAssetNames]
def process(self, context):
if not self.is_active(context.data):
return
context_asset_name = context.data["asset"]
for instance in context:
asset_name = instance.data.get("asset")

View file

@ -11,7 +11,7 @@ class ValidateLayersVisiblity(pyblish.api.InstancePlugin):
families = ["review", "render"]
def process(self, instance):
layers = instance.data["layers"]
layers = instance.data.get("layers")
# Instance have empty layers
# - it is not job of this validator to check that
if not layers:

View file

@ -1,7 +1,10 @@
import json
import pyblish.api
from openpype.pipeline import PublishXmlValidationError
from openpype.pipeline import (
PublishXmlValidationError,
OptionalPyblishPluginMixin,
)
from openpype.hosts.tvpaint.api.lib import execute_george
@ -23,7 +26,10 @@ class ValidateMarksRepair(pyblish.api.Action):
)
class ValidateMarks(pyblish.api.ContextPlugin):
class ValidateMarks(
OptionalPyblishPluginMixin,
pyblish.api.ContextPlugin
):
"""Validate mark in and out are enabled and it's duration.
Mark In/Out does not have to match frameStart and frameEnd but duration is
@ -59,6 +65,9 @@ class ValidateMarks(pyblish.api.ContextPlugin):
}
def process(self, context):
if not self.is_active(context.data):
return
current_data = {
"markIn": context.data["sceneMarkIn"],
"markInState": context.data["sceneMarkInState"],

View file

@ -1,11 +1,17 @@
import json
import pyblish.api
from openpype.pipeline import PublishXmlValidationError
from openpype.pipeline import (
PublishXmlValidationError,
OptionalPyblishPluginMixin,
)
# TODO @iLliCiTiT add fix action for fps
class ValidateProjectSettings(pyblish.api.ContextPlugin):
class ValidateProjectSettings(
OptionalPyblishPluginMixin,
pyblish.api.ContextPlugin
):
"""Validate scene settings against database."""
label = "Validate Scene Settings"
@ -13,6 +19,9 @@ class ValidateProjectSettings(pyblish.api.ContextPlugin):
optional = True
def process(self, context):
if not self.is_active(context.data):
return
expected_data = context.data["assetEntity"]["data"]
scene_data = {
"fps": context.data.get("sceneFps"),

View file

@ -1,5 +1,8 @@
import pyblish.api
from openpype.pipeline import PublishXmlValidationError
from openpype.pipeline import (
PublishXmlValidationError,
OptionalPyblishPluginMixin,
)
from openpype.hosts.tvpaint.api.lib import execute_george
@ -14,7 +17,10 @@ class RepairStartFrame(pyblish.api.Action):
execute_george("tv_startframe 0")
class ValidateStartFrame(pyblish.api.ContextPlugin):
class ValidateStartFrame(
OptionalPyblishPluginMixin,
pyblish.api.ContextPlugin
):
"""Validate start frame being at frame 0."""
label = "Validate Start Frame"
@ -24,6 +30,9 @@ class ValidateStartFrame(pyblish.api.ContextPlugin):
optional = True
def process(self, context):
if not self.is_active(context.data):
return
start_frame = execute_george("tv_startframe")
if start_frame == 0:
return

View file

@ -42,6 +42,7 @@
"default_variants": []
},
"auto_detect_render": {
"enabled": false,
"allow_group_rename": true,
"group_name_template": "L{group_index}",
"group_idx_offset": 10,

View file

@ -202,7 +202,13 @@
"key": "auto_detect_render",
"label": "Auto-Detect Create Render",
"is_group": true,
"checkbox_key": "enabled",
"children": [
{
"type": "boolean",
"key": "enabled",
"label": "Enabled"
},
{
"type": "label",
"label": "The creator tries to auto-detect Render Layers and Render Passes in scene. For Render Layers is used group name as a variant and for Render Passes is used TVPaint layer name.<br/><br/>Group names can be renamed by their used order in scene. The renaming template where can be used <b>{group_index}</b> formatting key which is filled by \"used position index of group\".<br/>- Template: <b>L{group_index}</b><br/>- Group offset: <b>10</b><br/>- Group padding: <b>3</b><br/>Would create group names \"<b>L010</b>\", \"<b>L020</b>\", ..."