mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Merge pull request #3304 from pypeclub/enhancement/OP-3302_maya-camera-content-validation
Maya: Allow more data to be published along camera 🎥
This commit is contained in:
commit
03ab7e578b
5 changed files with 76 additions and 14 deletions
|
|
@ -34,7 +34,6 @@ class ExtractCameraAlembic(openpype.api.Extractor):
|
|||
dag=True, type="camera")
|
||||
|
||||
# validate required settings
|
||||
assert len(cameras) == 1, "Not a single camera found in extraction"
|
||||
assert isinstance(step, float), "Step must be a float value"
|
||||
camera = cameras[0]
|
||||
|
||||
|
|
@ -44,8 +43,12 @@ class ExtractCameraAlembic(openpype.api.Extractor):
|
|||
path = os.path.join(dir_path, filename)
|
||||
|
||||
# Perform alembic extraction
|
||||
member_shapes = cmds.ls(
|
||||
members, leaf=True, shapes=True, long=True, dag=True)
|
||||
with lib.maintained_selection():
|
||||
cmds.select(camera, replace=True, noExpand=True)
|
||||
cmds.select(
|
||||
member_shapes,
|
||||
replace=True, noExpand=True)
|
||||
|
||||
# Enforce forward slashes for AbcExport because we're
|
||||
# embedding it into a job string
|
||||
|
|
@ -57,10 +60,12 @@ class ExtractCameraAlembic(openpype.api.Extractor):
|
|||
job_str += ' -step {0} '.format(step)
|
||||
|
||||
if bake_to_worldspace:
|
||||
transform = cmds.listRelatives(camera,
|
||||
parent=True,
|
||||
fullPath=True)[0]
|
||||
job_str += ' -worldSpace -root {0}'.format(transform)
|
||||
job_str += ' -worldSpace'
|
||||
for member in member_shapes:
|
||||
self.log.info(f"processing {member}")
|
||||
transform = cmds.listRelatives(
|
||||
member, parent=True, fullPath=True)[0]
|
||||
job_str += ' -root {0}'.format(transform)
|
||||
|
||||
job_str += ' -file "{0}"'.format(path)
|
||||
|
||||
|
|
|
|||
|
|
@ -131,12 +131,12 @@ class ExtractCameraMayaScene(openpype.api.Extractor):
|
|||
"bake to world space is ignored...")
|
||||
|
||||
# get cameras
|
||||
members = instance.data['setMembers']
|
||||
members = cmds.ls(instance.data['setMembers'], leaf=True, shapes=True,
|
||||
long=True, dag=True)
|
||||
cameras = cmds.ls(members, leaf=True, shapes=True, long=True,
|
||||
dag=True, type="camera")
|
||||
|
||||
# validate required settings
|
||||
assert len(cameras) == 1, "Single camera must be found in extraction"
|
||||
assert isinstance(step, float), "Step must be a float value"
|
||||
camera = cameras[0]
|
||||
transform = cmds.listRelatives(camera, parent=True, fullPath=True)
|
||||
|
|
@ -158,15 +158,24 @@ class ExtractCameraMayaScene(openpype.api.Extractor):
|
|||
frame_range=[start, end],
|
||||
step=step
|
||||
)
|
||||
baked_shapes = cmds.ls(baked,
|
||||
baked_camera_shapes = cmds.ls(baked,
|
||||
type="camera",
|
||||
dag=True,
|
||||
shapes=True,
|
||||
long=True)
|
||||
|
||||
members = members + baked_camera_shapes
|
||||
members.remove(camera)
|
||||
else:
|
||||
baked_shapes = cameras
|
||||
baked_camera_shapes = cmds.ls(cameras,
|
||||
type="camera",
|
||||
dag=True,
|
||||
shapes=True,
|
||||
long=True)
|
||||
# Fix PLN-178: Don't allow background color to be non-black
|
||||
for cam in baked_shapes:
|
||||
for cam in cmds.ls(
|
||||
baked_camera_shapes, type="camera", dag=True,
|
||||
shapes=True, long=True):
|
||||
attrs = {"backgroundColorR": 0.0,
|
||||
"backgroundColorG": 0.0,
|
||||
"backgroundColorB": 0.0,
|
||||
|
|
@ -177,7 +186,8 @@ class ExtractCameraMayaScene(openpype.api.Extractor):
|
|||
cmds.setAttr(plug, value)
|
||||
|
||||
self.log.info("Performing extraction..")
|
||||
cmds.select(baked_shapes, noExpand=True)
|
||||
cmds.select(cmds.ls(members, dag=True,
|
||||
shapes=True, long=True), noExpand=True)
|
||||
cmds.file(path,
|
||||
force=True,
|
||||
typ="mayaAscii" if self.scene_type == "ma" else "mayaBinary", # noqa: E501
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class ValidateCameraContents(pyblish.api.InstancePlugin):
|
|||
hosts = ['maya']
|
||||
label = 'Camera Contents'
|
||||
actions = [openpype.hosts.maya.api.action.SelectInvalidAction]
|
||||
validate_shapes = True
|
||||
|
||||
@classmethod
|
||||
def get_invalid(cls, instance):
|
||||
|
|
@ -32,7 +33,7 @@ class ValidateCameraContents(pyblish.api.InstancePlugin):
|
|||
invalid = []
|
||||
cameras = cmds.ls(shapes, type='camera', long=True)
|
||||
if len(cameras) != 1:
|
||||
cls.log.warning("Camera instance must have a single camera. "
|
||||
cls.log.error("Camera instance must have a single camera. "
|
||||
"Found {0}: {1}".format(len(cameras), cameras))
|
||||
invalid.extend(cameras)
|
||||
|
||||
|
|
@ -49,15 +50,32 @@ class ValidateCameraContents(pyblish.api.InstancePlugin):
|
|||
|
||||
raise RuntimeError("No cameras found in empty instance.")
|
||||
|
||||
if not cls.validate_shapes:
|
||||
cls.log.info("Not validating shapes in the content.")
|
||||
|
||||
for member in members:
|
||||
parents = cmds.ls(member, long=True)[0].split("|")[1:-1]
|
||||
parents_long_named = [
|
||||
"|".join(parents[:i]) for i in range(1, 1 + len(parents))
|
||||
]
|
||||
if cameras[0] in parents_long_named:
|
||||
cls.log.error(
|
||||
"{} is parented under camera {}".format(
|
||||
member, cameras[0]))
|
||||
invalid.extend(member)
|
||||
return invalid
|
||||
|
||||
# non-camera shapes
|
||||
valid_shapes = cmds.ls(shapes, type=('camera', 'locator'), long=True)
|
||||
shapes = set(shapes) - set(valid_shapes)
|
||||
if shapes:
|
||||
shapes = list(shapes)
|
||||
cls.log.warning("Camera instance should only contain camera "
|
||||
cls.log.error("Camera instance should only contain camera "
|
||||
"shapes. Found: {0}".format(shapes))
|
||||
invalid.extend(shapes)
|
||||
|
||||
|
||||
|
||||
invalid = list(set(invalid))
|
||||
|
||||
return invalid
|
||||
|
|
|
|||
|
|
@ -443,6 +443,11 @@
|
|||
"optional": true,
|
||||
"active": true
|
||||
},
|
||||
"ValidateCameraContents": {
|
||||
"enabled": true,
|
||||
"optional": true,
|
||||
"validate_shapes": true
|
||||
},
|
||||
"ExtractPlayblast": {
|
||||
"capture_preset": {
|
||||
"Codec": {
|
||||
|
|
|
|||
|
|
@ -594,6 +594,30 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "dict",
|
||||
"collapsible": true,
|
||||
"key": "ValidateCameraContents",
|
||||
"label": "Validate Camera Content",
|
||||
"checkbox_key": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"key": "enabled",
|
||||
"label": "Enabled"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"key": "optional",
|
||||
"label": "Optional"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"key": "validate_shapes",
|
||||
"label": "Validate presence of shapes"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "splitter"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue