Skip to content
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

EMSUSD-756 allow parenting under a stronger layer #3526

Merged
merged 1 commit into from
Dec 18, 2023
Merged
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
5 changes: 4 additions & 1 deletion lib/usdUfe/ufe/UsdUndoInsertChildCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ UsdUndoInsertChildCommand::UsdUndoInsertChildCommand(

// Apply restriction rules
UsdUfe::applyCommandRestriction(childPrim, "reparent");
UsdUfe::applyCommandRestriction(parentPrim, "reparent");
// Note: the parent is only receiving the prim, so it can be declared
// in a weaker layer.
const bool allowStronger = true;
UsdUfe::applyCommandRestriction(parentPrim, "reparent", allowStronger);
}

UsdUndoInsertChildCommand::~UsdUndoInsertChildCommand() { }
Expand Down
31 changes: 31 additions & 0 deletions test/lib/ufe/testParentCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,37 @@ def testParentRestrictionDefaultPrim(self):
with self.assertRaises(RuntimeError):
cmds.parent(capsulePathStr, x1PathStr)

def testParentToStrongerLayer(self):
'''
Verify that parenting a prim to a prim defined in a lower layer
is permitted.
'''
cmds.file(new=True, force=True)

# Create an empty stage with a sub-layer
import mayaUsd_createStageWithNewLayer
proxyShapePathStr = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()
stage = mayaUsd.lib.GetPrim(proxyShapePathStr).GetStage()
subLayer = usdUtils.addNewLayerToStage(stage)

# Create a xform in the sub-layer and a capsule in the root layer.
with Usd.EditContext(stage, subLayer):
subXFormName = '/SubXForm'
subXFormPrim = stage.DefinePrim(subXFormName, 'Xform')
self.assertTrue(subXFormPrim)

rootCapsuleName = '/RootCapsule'
rootCapsulePrim = stage.DefinePrim(rootCapsuleName, 'Capsule')
self.assertTrue(rootCapsulePrim)

subXFormUFEPath = proxyShapePathStr + "," + subXFormName
rootCapsuleUFEPath = proxyShapePathStr + "," + rootCapsuleName

cmds.parent(rootCapsuleUFEPath, subXFormUFEPath)

newRootCapsuleUSDPath = subXFormName + rootCapsuleName
self.assertTrue(stage.GetPrimAtPath(newRootCapsuleUSDPath))

@unittest.skipUnless(mayaUtils.mayaMajorVersion() >= 2023, 'Requires Maya fixes only available in Maya 2023 or greater.')
def testParentShader(self):
'''Shaders can only have NodeGraphs and Materials as parent.'''
Expand Down