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

Add auto edit testing coverage to custom rig codeless schema test #2057

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
7 changes: 3 additions & 4 deletions lib/mayaUsd/fileio/primUpdaterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,11 +1143,10 @@ void PrimUpdaterManager::onProxyContentChanged(
UsdMayaPrimUpdaterContext context(UsdTimeCode::Default(), stage, userArgs);

for (const auto& changedPath : notice.GetResyncedPaths()) {
if (changedPath == SdfPath::AbsoluteRootPath()) {
continue;
}
UsdPrim resyncPrim = (changedPath != SdfPath::AbsoluteRootPath())
? stage->GetPrimAtPath(changedPath)
: stage->GetPseudoRoot();

UsdPrim resyncPrim = stage->GetPrimAtPath(changedPath);
UsdPrimRange range(resyncPrim, predicate);

for (auto it = range.begin(); it != range.end(); it++) {
Expand Down
91 changes: 85 additions & 6 deletions test/lib/mayaUsd/fileio/testCustomRig.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ class customRigPrimUpdater(mayaUsdLib.PrimUpdater):
def __init__(self, *args, **kwargs):
super(customRigPrimUpdater, self).__init__(*args, **kwargs)

def shouldAutoEdit(self):
autoEditAttr = self.getUsdPrim().GetAttribute("autoEdit")
if autoEditAttr == None:
return False

return autoEditAttr.Get()

def editAsMaya(self):
return super(customRigPrimUpdater, self).editAsMaya()

Expand All @@ -74,6 +81,12 @@ class testCustomRig(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.inputPath = fixturesUtils.setUpClass(__file__)

typeName = Usd.SchemaRegistry.GetTypeFromSchemaTypeName("CustomRig").typeName

mayaUsdLib.PrimReader.Register(customRigPrimReader, typeName)
mayaUsdLib.PrimUpdater.Register(customRigPrimUpdater, typeName, "transform", customRigPrimUpdater.Supports.All.value + customRigPrimUpdater.Supports.AutoPull.value)


@classmethod
def tearDownClass(cls):
Expand Down Expand Up @@ -111,9 +124,6 @@ def testCustomRigSchema(self):
def testCustomRigReader(self):
"Validate prim reader for CustomRig codeless schema"

typeName = Usd.SchemaRegistry.GetTypeFromSchemaTypeName("CustomRig").typeName
mayaUsdLib.PrimReader.Register(customRigPrimReader, typeName)

layer = Sdf.Layer.CreateAnonymous(".usd")
layer.ImportFromString(
''' #usda 1.0
Expand All @@ -140,9 +150,6 @@ def CustomRig "bob" {
def testCustomRigUpdater(self):
"Validate prim updater for CustomRig codeless schema"

typeName = Usd.SchemaRegistry.GetTypeFromSchemaTypeName("CustomRig").typeName
mayaUsdLib.PrimUpdater.Register(customRigPrimUpdater, typeName, "transform", customRigPrimUpdater.Supports.All.value)

import mayaUsd_createStageWithNewLayer
proxyShape = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()

Expand Down Expand Up @@ -203,5 +210,77 @@ def CustomRig "bob" {
self.assertEqual(attr.GetNumTimeSamples(), 11)
self.assertEqual(attr.GetTimeSamples(), [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0])

def testCustomRigUpdaterAutoEditLoad(self):
"Validate auto edit on stage load for CustomRig codeless schema"

import mayaUsd_createStageWithNewLayer
proxyShape = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()

stage = mayaUsdUfe.getStage(proxyShape)
self.assertTrue(stage)

layer = stage.GetRootLayer()
layer.ImportFromString(
''' #sdf 1
(
defaultPrim = "world"
)
def Xform "world" {
def Xform "anim" {
def CustomRig "bob" {
int cubes = 2
bool autoEdit = 1
}
}
}
'''
)

self.assertTrue(self._GetMFnDagNode("bob|pCube1"))
self.assertTrue(self._GetMFnDagNode("bob|pCube2"))

bobPrim = stage.GetPrimAtPath("/world/anim/bob")
autoEditAttr = bobPrim.GetAttribute("autoEdit")
self.assertTrue(autoEditAttr.Get())

def testCustomRigUpdaterAutoEditChange(self):
"Validate auto edit on attr change for CustomRig codeless schema"

import mayaUsd_createStageWithNewLayer
proxyShape = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()

stage = mayaUsdUfe.getStage(proxyShape)
self.assertTrue(stage)

layer = stage.GetRootLayer()
layer.ImportFromString(
''' #sdf 1
(
defaultPrim = "world"
)
def Xform "world" {
def Xform "anim" {
def CustomRig "bob" {
int cubes = 2
bool autoEdit = 0
}
}
}
'''
)

self.assertFalse(self._GetMFnDagNode("bob|pCube1"))
self.assertFalse(self._GetMFnDagNode("bob|pCube2"))

bobPrim = stage.GetPrimAtPath("/world/anim/bob")
autoEditAttr = bobPrim.GetAttribute("autoEdit")
self.assertFalse(autoEditAttr.Get())

autoEditAttr.Set(True)
self.assertTrue(autoEditAttr.Get())

self.assertTrue(self._GetMFnDagNode("bob|pCube1"))
self.assertTrue(self._GetMFnDagNode("bob|pCube2"))

if __name__ == '__main__':
unittest.main(verbosity=2)