Skip to content

EMSUSD-2278 - Creating or parenting a camera under a USD def will crash Maya #4177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ Installers for MayaUSD can be found [here](https://github.com/Autodesk/maya-usd/
- 2023
- 2024
- 2025
- 2026


## Plugin Documentation
+ [Getting Started with USD in Maya 2022](https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=GUID-36CFE2C3-766F-4B00-8464-E94F95E7AF4B)
+ [Getting Started with USD in Maya 2023](https://help.autodesk.com/view/MAYAUL/2023/ENU/?guid=GUID-36CFE2C3-766F-4B00-8464-E94F95E7AF4B)
+ [Getting Started with USD in Maya 2024](https://help.autodesk.com/view/MAYAUL/2024/ENU/?guid=GUID-36CFE2C3-766F-4B00-8464-E94F95E7AF4B)
+ [Getting Started with USD in Maya 2025](https://help.autodesk.com/view/MAYAUL/2025/ENU/?guid=GUID-36CFE2C3-766F-4B00-8464-E94F95E7AF4B)
+ [Getting Started with USD in Maya 2026](https://help.autodesk.com/view/MAYAUL/2026/ENU/?guid=GUID-36CFE2C3-766F-4B00-8464-E94F95E7AF4B)

## Building
Everything needed to build maya-usd is provided in the form of source and a devkit that needs to be installed. Unit tests are provided for all projects and can be optionally built and executed using google tests. Full details on how to build and test maya-usd can be found in [BUILD.md](doc/build.md)
Expand Down
2 changes: 1 addition & 1 deletion lib/mayaUsd/ufe/MayaUsdObject3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool MayaUsdObject3d::visibility() const
// check if the parent is visible
auto parentItem = Ufe::Hierarchy::createItem(parentPath);
auto parentObject3d = Ufe::Object3d::object3d(parentItem);
if (!parentObject3d->visibility()) {
if (parentObject3d && !parentObject3d->visibility()) {
return false;
}
parentPath = parentPath.pop();
Expand Down
2 changes: 1 addition & 1 deletion lib/usdUfe/ufe/UsdCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ bool UsdCamera::computedVisibility() const
// check if the parent is visible
auto parentItem = Ufe::Hierarchy::createItem(parentPath);
auto parentObject3d = Ufe::Object3d::object3d(parentItem);
if (!parentObject3d->visibility()) {
if (parentObject3d && !parentObject3d->visibility()) {
return false;
}
parentPath = parentPath.pop();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

from maya import cmds

from pxr import Usd

import unittest
import ufe
import os
Expand Down Expand Up @@ -117,12 +119,33 @@ def _RunTest(self):
cmds.currentTime(4)
self.assertSnapshotClose('%s_animation.png' % (self._testName))

# test camera creation and visibility
self._TestUsdCameraCreationAndVisibility()

def _GetSceneItem(self, mayaPathString, usdPathString):
mayaPathSegment = mayaUtils.createUfePathSegment(mayaPathString)
usdPathSegment = usdUtils.createUfePathSegment(usdPathString)
ufePath = ufe.Path([mayaPathSegment, usdPathSegment])
ufeItem = ufe.Hierarchy.createItem(ufePath)
return ufeItem

def _TestUsdCameraCreationAndVisibility(self):
usdFilePath = cmds.internalVar(utd=1) + '/testCamera.usda'
stage = Usd.Stage.CreateNew(usdFilePath)
# Create camera under a def
scope = stage.DefinePrim('/parent', 'Scope')
defPrim = stage.DefinePrim('/cam', '')
camera = stage.DefinePrim('/parent/cam/camera1', 'Camera')
stage.GetRootLayer().Save()
proxyShape = cmds.createNode('mayaUsdProxyShape')
cmds.setAttr('mayaUsdProxyShape1.filePath', usdFilePath, type='string')
ufeItem = ufeUtils.createItem('|mayaUsdProxy1|mayaUsdProxyShape1,/parent')
object3d = ufe.Object3d.object3d(ufeItem)
object3d.setVisibility(False)
self.assertSnapshotClose('%s_invisibile.png' % (self._testName))
object3d.setVisibility(True)
self.assertSnapshotClose('%s_visibile.png' % (self._testName))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added camera creation under scope and def. Also added tests to test camera visibility if its parent is set to invisible


@unittest.skipUnless(mayaUtils.mayaMajorVersion() > 2025, 'Requires Maya fixes only available after Maya 2025.')
def testCameras(self):
Expand Down