mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
add exitstack.py into maya api folder & code tweaks
This commit is contained in:
parent
c62862a773
commit
9f1ab7519f
3 changed files with 130 additions and 31 deletions
|
|
@ -7,6 +7,7 @@ import capture
|
|||
|
||||
from openpype.pipeline import publish
|
||||
from openpype.hosts.maya.api import lib
|
||||
from openpype.hosts.maya.api.exitstack import ExitStack
|
||||
|
||||
from maya import cmds
|
||||
|
||||
|
|
@ -199,37 +200,15 @@ class ExtractPlayblast(publish.Extractor):
|
|||
preset.update(panel_preset)
|
||||
|
||||
# Need to ensure Python 2 compatibility.
|
||||
# TODO: Remove once dropping Python 2.
|
||||
if getattr(contextlib, "nested", None):
|
||||
# Python 3 compatibility.
|
||||
with ExitStack() as stack:
|
||||
stack.enter_context(lib.maintained_time())
|
||||
stack.enter_context(
|
||||
panel_camera(instance.data["panel"], preset["camera"])
|
||||
)
|
||||
if preset["viewport_options"].get("textures"):
|
||||
# If capture includes textures then ensure material
|
||||
# load mode is set to `immediate` to ensure all
|
||||
# textures have loaded when playblast starts
|
||||
with contextlib.nested(
|
||||
lib.maintained_time(),
|
||||
panel_camera(instance.data["panel"], preset["camera"]),
|
||||
lib.material_loading_mode()
|
||||
):
|
||||
self._capture(preset)
|
||||
stack.enter_context(lib.material_loading_mode())
|
||||
|
||||
else:
|
||||
with contextlib.nested(
|
||||
lib.maintained_time(),
|
||||
panel_camera(instance.data["panel"], preset["camera"])
|
||||
):
|
||||
self._capture(preset)
|
||||
else:
|
||||
# Python 2 compatibility.
|
||||
with contextlib.ExitStack() as stack:
|
||||
stack.enter_context(lib.maintained_time())
|
||||
stack.enter_context(
|
||||
panel_camera(instance.data["panel"], preset["camera"])
|
||||
)
|
||||
if preset["viewport_options"].get("textures"):
|
||||
stack.enter_context(lib.material_loading_mode())
|
||||
|
||||
self._capture(preset)
|
||||
self._capture(preset)
|
||||
|
||||
# Restoring viewport options.
|
||||
if viewport_defaults:
|
||||
|
|
|
|||
|
|
@ -153,11 +153,11 @@ class ExtractThumbnail(publish.Extractor):
|
|||
)
|
||||
)
|
||||
|
||||
if "reloadTextures" in preset["viewport_options"]:
|
||||
if preset["viewport_options"].get("reloadTextures"):
|
||||
lib.reload_all_udim_tile_previews()
|
||||
|
||||
preset["viewport_options"].pop("reloadTextures", None)
|
||||
if "textures" in preset["viewport_options"]:
|
||||
if preset["viewport_options"].get("textures"):
|
||||
with lib.material_loading_mode():
|
||||
path = capture.capture(**preset)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue