mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
refactor the capture function and move it to lib
This commit is contained in:
parent
008f78e6a0
commit
f9603bb0a5
3 changed files with 31 additions and 46 deletions
|
|
@ -9,6 +9,8 @@ import re
|
|||
import json
|
||||
import logging
|
||||
import contextlib
|
||||
import capture
|
||||
from .exitstack import ExitStack
|
||||
from collections import OrderedDict, defaultdict
|
||||
from math import ceil
|
||||
from six import string_types
|
||||
|
|
@ -183,6 +185,32 @@ def reload_all_udim_tile_previews():
|
|||
cmds.ogs(regenerateUVTilePreview=texture_file)
|
||||
|
||||
|
||||
def capture_with_preset(preset):
|
||||
if os.environ.get("OPENPYPE_DEBUG") == "1":
|
||||
log.debug(
|
||||
"Using preset: {}".format(
|
||||
json.dumps(preset, indent=4, sort_keys=True)
|
||||
)
|
||||
)
|
||||
|
||||
if preset["viewport_options"].get("textures"):
|
||||
with ExitStack() as stack:
|
||||
stack.enter_context(material_loading_mode())
|
||||
if preset["viewport_options"].get("reloadTextures"):
|
||||
# Regenerate all UDIM tiles previews
|
||||
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))
|
||||
else:
|
||||
preset["viewport_options"].pop("reloadTextures", None)
|
||||
path = capture.capture(log=self.log, **preset)
|
||||
self.log.debug("playblast path {}".format(path))
|
||||
|
||||
return path
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def material_loading_mode(mode="immediate"):
|
||||
"""Set material loading mode during context"""
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import os
|
||||
import json
|
||||
import contextlib
|
||||
|
||||
import clique
|
||||
|
|
@ -9,6 +8,7 @@ from openpype.pipeline import publish
|
|||
from openpype.hosts.maya.api import lib
|
||||
from openpype.hosts.maya.api.exitstack import ExitStack
|
||||
|
||||
|
||||
from maya import cmds
|
||||
|
||||
|
||||
|
|
@ -37,29 +37,6 @@ class ExtractPlayblast(publish.Extractor):
|
|||
capture_preset = {}
|
||||
profiles = None
|
||||
|
||||
def _capture(self, preset):
|
||||
if os.environ.get("OPENPYPE_DEBUG") == "1":
|
||||
self.log.debug(
|
||||
"Using preset: {}".format(
|
||||
json.dumps(preset, indent=4, sort_keys=True)
|
||||
)
|
||||
)
|
||||
|
||||
if preset["viewport_options"].get("textures"):
|
||||
with ExitStack() as stack:
|
||||
stack.enter_context(lib.material_loading_mode())
|
||||
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))
|
||||
else:
|
||||
preset["viewport_options"].pop("reloadTextures", None)
|
||||
path = capture.capture(log=self.log, **preset)
|
||||
self.log.debug("playblast path {}".format(path))
|
||||
|
||||
def process(self, instance):
|
||||
self.log.debug("Extracting capture..")
|
||||
|
||||
|
|
@ -212,7 +189,7 @@ class ExtractPlayblast(publish.Extractor):
|
|||
stack.enter_context(
|
||||
panel_camera(instance.data["panel"], preset["camera"])
|
||||
)
|
||||
self._capture(preset)
|
||||
path = lib.capture_with_preset(preset)
|
||||
|
||||
# Restoring viewport options.
|
||||
if viewport_defaults:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
import os
|
||||
import glob
|
||||
import tempfile
|
||||
import json
|
||||
|
||||
import capture
|
||||
|
||||
from openpype.pipeline import publish
|
||||
from openpype.hosts.maya.api import lib
|
||||
|
|
@ -146,24 +143,7 @@ class ExtractThumbnail(publish.Extractor):
|
|||
preset.update(panel_preset)
|
||||
cmds.setFocus(panel)
|
||||
|
||||
if os.environ.get("OPENPYPE_DEBUG") == "1":
|
||||
self.log.debug(
|
||||
"Using preset: {}".format(
|
||||
json.dumps(preset, indent=4, sort_keys=True)
|
||||
)
|
||||
)
|
||||
|
||||
if preset["viewport_options"].get("textures"):
|
||||
with lib.material_loading_mode():
|
||||
if preset["viewport_options"].get("reloadTextures"):
|
||||
lib.reload_all_udim_tile_previews()
|
||||
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)
|
||||
path = capture.capture(**preset)
|
||||
path = lib.capture_with_preset(preset)
|
||||
|
||||
playblast = self._fix_playblast_output_path(path)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue