mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
make sure the contextlib.nested used before material loading while it is compatible for both python2 and 3
This commit is contained in:
parent
28a62bff59
commit
4648895291
3 changed files with 39 additions and 29 deletions
|
|
@ -172,8 +172,9 @@ def maintained_selection():
|
|||
cmds.select(clear=True)
|
||||
|
||||
|
||||
def reload_textures():
|
||||
"""Reload textures during playblast
|
||||
def reload_all_udim_tile_previews():
|
||||
"""Regenerate all UDIM tile preview in texture file
|
||||
nodes during context
|
||||
"""
|
||||
texture_files = cmds.ls(type="file")
|
||||
if texture_files:
|
||||
|
|
|
|||
|
|
@ -43,17 +43,13 @@ class ExtractPlayblast(publish.Extractor):
|
|||
json.dumps(preset, indent=4, sort_keys=True)
|
||||
)
|
||||
)
|
||||
if "textures" in preset["viewport_options"] and (
|
||||
"reloadTextures" in preset["viewport_options"]
|
||||
):
|
||||
with lib.material_loading_mode():
|
||||
lib.reload_textures()
|
||||
# not supported by `capture`
|
||||
preset["viewport_options"].pop("reloadTextures", None)
|
||||
path = capture.capture(log=self.log, **preset)
|
||||
else:
|
||||
preset["viewport_options"].pop("reloadTextures", None)
|
||||
path = capture.capture(log=self.log, **preset)
|
||||
|
||||
if preset["viewport_options"].get("reloadTextures"):
|
||||
# Regenerate all UDIM tiles previews
|
||||
lib.reload_all_udim_tile_previews()
|
||||
# not supported by `capture`
|
||||
preset["viewport_options"].pop("reloadTextures", None)
|
||||
path = capture.capture(log=self.log, **preset)
|
||||
self.log.debug("playblast path {}".format(path))
|
||||
|
||||
def process(self, instance):
|
||||
|
|
@ -206,11 +202,23 @@ class ExtractPlayblast(publish.Extractor):
|
|||
# TODO: Remove once dropping Python 2.
|
||||
if getattr(contextlib, "nested", None):
|
||||
# Python 3 compatibility.
|
||||
with contextlib.nested(
|
||||
lib.maintained_time(),
|
||||
panel_camera(instance.data["panel"], preset["camera"])
|
||||
):
|
||||
self._capture(preset)
|
||||
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)
|
||||
|
||||
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:
|
||||
|
|
@ -218,6 +226,8 @@ class ExtractPlayblast(publish.Extractor):
|
|||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -152,19 +152,18 @@ class ExtractThumbnail(publish.Extractor):
|
|||
json.dumps(preset, indent=4, sort_keys=True)
|
||||
)
|
||||
)
|
||||
|
||||
if "reloadTextures" in preset["viewport_options"]:
|
||||
lib.reload_all_udim_tile_previews()
|
||||
|
||||
preset["viewport_options"].pop("reloadTextures", None)
|
||||
if "textures" in preset["viewport_options"]:
|
||||
if "reloadTextures" in preset["viewport_options"]:
|
||||
with lib.material_loading_mode():
|
||||
lib.reload_textures()
|
||||
preset["viewport_options"].pop("reloadTextures", None)
|
||||
path = capture.capture(**preset)
|
||||
else:
|
||||
self.log.debug(
|
||||
"Reload Textures during playblasting is disabled.")
|
||||
preset["viewport_options"].pop("reloadTextures", None)
|
||||
with lib.material_loading_mode():
|
||||
path = capture.capture(**preset)
|
||||
# not supported by `capture`
|
||||
path = capture.capture(**preset)
|
||||
else:
|
||||
self.log.debug("Reload Textures during playblasting is disabled.")
|
||||
path = capture.capture(**preset)
|
||||
|
||||
playblast = self._fix_playblast_output_path(path)
|
||||
|
||||
_, thumbnail = os.path.split(playblast)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue