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

Maya: cleanup duplicate rendersetup code #2642

Merged
merged 4 commits into from
Feb 11, 2022

Conversation

BigRoy
Copy link
Collaborator

@BigRoy BigRoy commented Feb 3, 2022

Brief description

This resolves #2637 by removing attributes.py and pushing some of the "OpenPype" changes directly to lib_rendersetup.py.
This also refactors the single use/import of attributes.py to use this one instead.

Testing notes

Tested in Maya 2020 + 2022 using this:

Test RenderSetup absolute overrides on a camera.renderable

import openpype.hosts.maya.api.lib_rendersetup as lib_rendersetup
from maya import cmds
from maya.app.renderSetup.model import (
    selector,
    renderSetup
)
    
# Make a single renderable camera
cam = cmds.createNode("camera", name="cameraMain")
cmds.setAttr(cam + ".renderable", True)

# Create a renderlayer where we set this camera to also be disabled
rs = renderSetup.instance()
disabled_layer = rs.createRenderLayer('DisabledCamera')
collection = disabled_layer.createCollection("disableRenderableCamera")
sel = collection.getSelector()
sel.setFilterType(selector.Filters.kShapes)
sel.staticSelection.set([cam])
override = collection.createOverride("renderable", "absOverride")
override.finalize("renderable")
override.setAttrValue(0)

# Create a renderlayer where we set this camera to also be enabled
rs = renderSetup.instance()
enabled_layer = rs.createRenderLayer('EnabledCamera')
collection = enabled_layer.createCollection("enableRenderableCamera")
sel = collection.getSelector()
sel.setFilterType(selector.Filters.kShapes)
sel.staticSelection.set([cam])
override = collection.createOverride("renderable", "absOverride")
override.finalize("renderable")
override.setAttrValue(1)

attr = cam + ".renderable"
assert lib_rendersetup.get_attr_in_layer(attr, layer="defaultRenderLayer") == 1
assert lib_rendersetup.get_attr_in_layer(attr, layer=disabled_layer.name()) == 0
assert lib_rendersetup.get_attr_in_layer(attr, layer=enabled_layer.name()) == 1
# change the default layer value and make sure overrides still evaluate as expected
cmds.setAttr(attr, 0)
assert lib_rendersetup.get_attr_in_layer(attr, layer="defaultRenderLayer") == 0
assert lib_rendersetup.get_attr_in_layer(attr, layer=disabled_layer.name()) == 0
assert lib_rendersetup.get_attr_in_layer(attr, layer=enabled_layer.name()) == 1

Also quickly did CreateRender in Maya 2020 to see if all Collector still collect fine. And they did! Be aware however that you'll need to add a renderable camera to the DisabledCamera layer for it to collect correctly - otherwise you'll see a no render products generated error due to the renderlayer having no renderable camera set at all.

Copy link
Member

@antirotor antirotor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works, thanks!

@antirotor antirotor merged commit 06709b0 into ynput:develop Feb 11, 2022
@BigRoy BigRoy deleted the maya_lib_rendersetup_cleanup branch March 20, 2024 15:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maya: api 'attributes' and 'lib_rendersetup' are two almost identical files
3 participants