Removed camera from render instance and added validator to check camera

This commit is contained in:
Simone Barbieri 2023-08-24 11:37:52 +01:00
parent a0c25edab9
commit 153a299901
4 changed files with 46 additions and 13 deletions

View file

@ -213,18 +213,6 @@ class CreateRenderlayer(plugin.Creator):
return aov_file_products
@staticmethod
def set_render_camera(asset_group):
# There should be only one camera in the instance
found = False
for obj in asset_group.all_objects:
if isinstance(obj, bpy.types.Object) and obj.type == "CAMERA":
bpy.context.scene.camera = obj
found = True
break
assert found, "No camera found in the render instance"
@staticmethod
def imprint_render_settings(node, data):
RENDER_DATA = "render_data"
@ -262,7 +250,6 @@ class CreateRenderlayer(plugin.Creator):
# We set the render path, the format and the camera
bpy.context.scene.render.filepath = render_product
self.set_render_format(ext, multilayer)
self.set_render_camera(asset_group)
render_settings = {
"render_folder": render_folder,

View file

@ -0,0 +1,17 @@
import bpy
import pyblish.api
class ValidateRenderCameraIsSet(pyblish.api.InstancePlugin):
"""Validate that there is a camera set as active for rendering."""
order = pyblish.api.ValidatorOrder
hosts = ["blender"]
families = ["renderlayer"]
label = "Validate Render Camera Is Set"
optional = False
def process(self, instance):
if not bpy.context.scene.camera:
raise RuntimeError("No camera is active for rendering.")

View file

@ -41,6 +41,11 @@
"active": true,
"exclude_families": []
},
"ValidateRenderCameraIsSet": {
"enabled": true,
"optional": false,
"active": true
},
"ValidateMeshHasUvs": {
"enabled": true,
"optional": true,

View file

@ -51,6 +51,30 @@
}
]
},
{
"type": "dict",
"collapsible": true,
"key": "ValidateRenderCameraIsSet",
"label": "Validate Render Camera Is Set",
"checkbox_key": "enabled",
"children": [
{
"type": "boolean",
"key": "enabled",
"label": "Enabled"
},
{
"type": "boolean",
"key": "optional",
"label": "Optional"
},
{
"type": "boolean",
"key": "active",
"label": "Active"
}
]
},
{
"type": "collapsible-wrap",
"label": "Model",