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-40 prevent editing instance proxy. #3187

Merged
merged 2 commits into from
Jul 4, 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
10 changes: 10 additions & 0 deletions lib/mayaUsd/fileio/primUpdaterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,11 @@ bool PrimUpdaterManager::editAsMaya(const Ufe::Path& path, const VtDictionary& u
return false;
}

if (pulledPrim.IsInstanceProxy()) {
TF_WARN("Cannot edit a USD instance proxy.");
return false;
}

MayaUsd::ProgressBarScope progressBar(7, "Converting to Maya Data");

PushPullScope scopeIt(_inPushPull);
Expand Down Expand Up @@ -1211,6 +1216,11 @@ bool PrimUpdaterManager::canEditAsMaya(const Ufe::Path& path) const
return false;
}

// USD refuses that we modify point instance proxies, so detect that.
if (prim.IsInstanceProxy()) {
return false;
}

VtDictionary userArgs;
UsdMayaPrimUpdaterContext context(UsdTimeCode::Default(), prim.GetStage(), userArgs);

Expand Down
19 changes: 17 additions & 2 deletions test/lib/mayaUsd/fileio/testEditAsMaya.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,19 @@ def testIllegalEditAsMaya(self):
stage = mayaUsd.lib.GetPrim(proxyShapePathStr).GetStage()
blendShape = stage.DefinePrim('/BlendShape1', 'BlendShape')
scope = stage.DefinePrim('/Scope1', 'Scope')
scope = stage.DefinePrim('/Mesh1', 'Mesh')
scope = stage.DefinePrim('/Material1', 'Material')
self.assertIsNotNone(scope)
mesh = stage.DefinePrim('/Mesh1', 'Mesh')
self.assertIsNotNone(mesh)
mat = stage.DefinePrim('/Material1', 'Material')
self.assertIsNotNone(mat)
instanced = stage.DefinePrim('/Instanced', 'Xform')
self.assertIsNotNone(instanced)
proto = stage.DefinePrim('/Proto', 'Xform')
self.assertIsNotNone(proto)
protoMesh = stage.DefinePrim('/Proto/Mesh', 'Mesh')
self.assertIsNotNone(protoMesh)
instanced.GetReferences().AddInternalReference('/Proto')
instanced.SetInstanceable(True)

blendShapePathStr = proxyShapePathStr + ',/BlendShape1'
scopePathStr = proxyShapePathStr + ',/Scope1'
Expand All @@ -398,6 +409,10 @@ def testIllegalEditAsMaya(self):
# capability.
self.assertFalse(mayaUsd.lib.PrimUpdaterManager.canEditAsMaya(proxyShapePathStr + ',/Material1'))

# Instance proxies cannot be edited as Maya: it explicitly disables this
# capability.
self.assertFalse(mayaUsd.lib.PrimUpdaterManager.canEditAsMaya(proxyShapePathStr + ',/Instanced/Proto/Mesh'))

def testSessionLayer(self):
'''Verify that the edit gets on the sessionLayer instead of the editTarget layer.'''

Expand Down