mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Merge pull request #4222 from pypeclub/bugfix/OP-3304_maya-image_plane_load_error
This commit is contained in:
commit
e377b03e78
1 changed files with 20 additions and 26 deletions
|
|
@ -23,8 +23,6 @@ class CameraWindow(QtWidgets.QDialog):
|
|||
self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint)
|
||||
|
||||
self.camera = None
|
||||
self.static_image_plane = False
|
||||
self.show_in_all_views = False
|
||||
|
||||
self.widgets = {
|
||||
"label": QtWidgets.QLabel("Select camera for image plane."),
|
||||
|
|
@ -45,8 +43,6 @@ class CameraWindow(QtWidgets.QDialog):
|
|||
for camera in cameras:
|
||||
self.widgets["list"].addItem(camera)
|
||||
|
||||
self.widgets["staticImagePlane"].setText("Make Image Plane Static")
|
||||
self.widgets["showInAllViews"].setText("Show Image Plane in All Views")
|
||||
|
||||
# Build buttons.
|
||||
layout = QtWidgets.QHBoxLayout(self.widgets["buttons"])
|
||||
|
|
@ -57,8 +53,6 @@ class CameraWindow(QtWidgets.QDialog):
|
|||
layout = QtWidgets.QVBoxLayout(self)
|
||||
layout.addWidget(self.widgets["label"])
|
||||
layout.addWidget(self.widgets["list"])
|
||||
layout.addWidget(self.widgets["staticImagePlane"])
|
||||
layout.addWidget(self.widgets["showInAllViews"])
|
||||
layout.addWidget(self.widgets["buttons"])
|
||||
layout.addWidget(self.widgets["warning"])
|
||||
|
||||
|
|
@ -73,8 +67,6 @@ class CameraWindow(QtWidgets.QDialog):
|
|||
if self.camera is None:
|
||||
self.widgets["warning"].setVisible(True)
|
||||
return
|
||||
self.show_in_all_views = self.widgets["showInAllViews"].isChecked()
|
||||
self.static_image_plane = self.widgets["staticImagePlane"].isChecked()
|
||||
|
||||
self.close()
|
||||
|
||||
|
|
@ -82,7 +74,6 @@ class CameraWindow(QtWidgets.QDialog):
|
|||
self.camera = None
|
||||
self.close()
|
||||
|
||||
|
||||
class ImagePlaneLoader(load.LoaderPlugin):
|
||||
"""Specific loader of plate for image planes on selected camera."""
|
||||
|
||||
|
|
@ -106,12 +97,10 @@ class ImagePlaneLoader(load.LoaderPlugin):
|
|||
|
||||
# Get camera from user selection.
|
||||
camera = None
|
||||
is_static_image_plane = None
|
||||
is_in_all_views = None
|
||||
# is_static_image_plane = None
|
||||
# is_in_all_views = None
|
||||
if data:
|
||||
camera = pm.PyNode(data.get("camera"))
|
||||
is_static_image_plane = data.get("static_image_plane")
|
||||
is_in_all_views = data.get("in_all_views")
|
||||
|
||||
if not camera:
|
||||
cameras = pm.ls(type="camera")
|
||||
|
|
@ -119,11 +108,11 @@ class ImagePlaneLoader(load.LoaderPlugin):
|
|||
camera_names["Create new camera."] = "create_camera"
|
||||
window = CameraWindow(camera_names.keys())
|
||||
window.exec_()
|
||||
# Skip if no camera was selected (Dialog was closed)
|
||||
if window.camera not in camera_names:
|
||||
return
|
||||
camera = camera_names[window.camera]
|
||||
|
||||
is_static_image_plane = window.static_image_plane
|
||||
is_in_all_views = window.show_in_all_views
|
||||
|
||||
if camera == "create_camera":
|
||||
camera = pm.createNode("camera")
|
||||
|
||||
|
|
@ -139,18 +128,14 @@ class ImagePlaneLoader(load.LoaderPlugin):
|
|||
# Create image plane
|
||||
image_plane_transform, image_plane_shape = pm.imagePlane(
|
||||
fileName=context["representation"]["data"]["path"],
|
||||
camera=camera, showInAllViews=is_in_all_views
|
||||
)
|
||||
camera=camera)
|
||||
image_plane_shape.depth.set(image_plane_depth)
|
||||
|
||||
if is_static_image_plane:
|
||||
image_plane_shape.detach()
|
||||
image_plane_transform.setRotation(camera.getRotation())
|
||||
|
||||
start_frame = pm.playbackOptions(q=True, min=True)
|
||||
end_frame = pm.playbackOptions(q=True, max=True)
|
||||
|
||||
image_plane_shape.frameOffset.set(1 - start_frame)
|
||||
image_plane_shape.frameOffset.set(0)
|
||||
image_plane_shape.frameIn.set(start_frame)
|
||||
image_plane_shape.frameOut.set(end_frame)
|
||||
image_plane_shape.frameCache.set(end_frame)
|
||||
|
|
@ -180,9 +165,17 @@ class ImagePlaneLoader(load.LoaderPlugin):
|
|||
QtWidgets.QMessageBox.Cancel
|
||||
)
|
||||
if reply == QtWidgets.QMessageBox.Ok:
|
||||
pm.delete(
|
||||
image_plane_shape.listConnections(type="expression")[0]
|
||||
)
|
||||
# find the input and output of frame extension
|
||||
expressions = image_plane_shape.frameExtension.inputs()
|
||||
frame_ext_output = image_plane_shape.frameExtension.outputs()
|
||||
if expressions:
|
||||
# the "time1" node is non-deletable attr
|
||||
# in Maya, use disconnectAttr instead
|
||||
pm.disconnectAttr(expressions, frame_ext_output)
|
||||
|
||||
if not image_plane_shape.frameExtension.isFreeToChange():
|
||||
raise RuntimeError("Can't set frame extension for {}".format(image_plane_shape)) # noqa
|
||||
# get the node of time instead and set the time for it.
|
||||
image_plane_shape.frameExtension.set(start_frame)
|
||||
|
||||
new_nodes.extend(
|
||||
|
|
@ -233,7 +226,8 @@ class ImagePlaneLoader(load.LoaderPlugin):
|
|||
)
|
||||
start_frame = asset["data"]["frameStart"]
|
||||
end_frame = asset["data"]["frameEnd"]
|
||||
image_plane_shape.frameOffset.set(1 - start_frame)
|
||||
|
||||
image_plane_shape.frameOffset.set(0)
|
||||
image_plane_shape.frameIn.set(start_frame)
|
||||
image_plane_shape.frameOut.set(end_frame)
|
||||
image_plane_shape.frameCache.set(end_frame)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue