Skip to content

Commit

Permalink
Remove incorrect Populate() on invalidate.
Browse files Browse the repository at this point in the history
  • Loading branch information
ppt-adsk committed Oct 8, 2024
1 parent 2200639 commit e4cc5c0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,22 @@ void MayaUsdProxyShapeSceneIndex::_StageInvalidate(const MAYAUSDAPI_NS::ProxySta
{
_usdImagingStageSceneIndex->SetStage(nullptr);
_populated = false;
Populate();
// Simply mark populate as dirty and do not call
// Populate();
// here. Doing so is incorrect for two reasons:
// - _StageInvalidate() is a callback called during Maya invalidation.
// Populate() calls MayaUsdProxyShapeBase::getUsdStage(), which calls
// MayaUsdProxyShapeBase::compute(), which should not be done during
// dirty propagation.
// - Calling getUsdStage() through Populate() creates an invalidate
// callback dependency between _StageInvalidate() and
// the mayaUsd plugin MayaStagesSubject::onStageInvalidate(). During
// getUsdStage(), MayaStagesSubject::setupListeners() is called, and it
// depends on MayaStagesSubject::onStageInvalidate() being called first,
// otherwise setupListeners() and therefore getUsdStage() will fail.
//
// Invalidate callbacks should not have dependencies on one another ---
// it should be possible to call them in random order.
}

void MayaUsdProxyShapeSceneIndex::_ObjectsChanged(
Expand Down
14 changes: 14 additions & 0 deletions test/lib/mayaUsd/render/mayaToHydra/cpp/testUsdStageFromFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import fixturesUtils
import mtohUtils
import usdUtils
import mayaUsd

import testUtils
from testUtils import PluginLoaded
Expand Down Expand Up @@ -51,11 +52,24 @@ def test_UsdStageFromFile(self):

cmds.setAttr('cubeShape.filePath', usdScenePath, type="string")

cmds.refresh()

populateCallsPost = cmds.mayaHydraInstruments("MayaUsdProxyShapeSceneIndex:NbPopulateCalls", q=True)

self.assertEqual(populateCallsPre+1, populateCallsPost)

cmds.mayaHydraCppTest(self.CONE_PATH, f="TestHydraPrim.fromAppPath")

def test_getStage(self):

# Any file will do.
usdScenePath = testUtils.getTestScene('testUsdNativeInstances', 'instancedCubeHierarchies.usda')

proxyShapePathStr = usdUtils.createStageFromFile(usdScenePath)

stage = mayaUsd.lib.GetPrim(proxyShapePathStr).GetStage()

self.assertIsNotNone(stage)

if __name__ == '__main__':
fixturesUtils.runTests(globals())

0 comments on commit e4cc5c0

Please sign in to comment.