Skip to content

Commit

Permalink
Merge pull request #3187 from Autodesk/bailp/EMSUSD-40/edit-point-ins…
Browse files Browse the repository at this point in the history
…tance-proxy

EMSUSD-40 prevent editing instance proxy.
  • Loading branch information
seando-adsk authored Jul 4, 2023
2 parents 7764ccf + e0b676d commit 0eb0a3a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
10 changes: 10 additions & 0 deletions lib/mayaUsd/fileio/primUpdaterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,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 @@ -1250,6 +1255,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

0 comments on commit 0eb0a3a

Please sign in to comment.