From 73105eea93325333b1d267805caa0246b4d6a0fc Mon Sep 17 00:00:00 2001 From: debloip Date: Mon, 26 Aug 2024 14:04:49 -0400 Subject: [PATCH 1/3] HYDRA-1160 : Handle optional case in instancing traversal --- .../fvpWireframeSelectionHighlightSceneIndex.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp b/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp index 7e664f7fe1..2b9408feaf 100644 --- a/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp +++ b/lib/flowViewport/sceneIndex/fvpWireframeSelectionHighlightSceneIndex.cpp @@ -104,9 +104,13 @@ SdfPathVector _GetInstancingRelatedPaths(const HdSceneIndexPrim& prim, Fvp::Sele instancingRelatedPaths.push_back(instancerPath); } - auto protoRootPaths = instancedBy.GetPrototypeRoots()->GetTypedValue(0); - for (const auto& protoRootPath : protoRootPaths) { - instancingRelatedPaths.push_back(protoRootPath); + // Having a prototype root is not a hard requirement (a single prim being instanced + // does not need to specify itself as its own prototype root). + if (instancedBy.GetPrototypeRoots()) { + auto protoRootPaths = instancedBy.GetPrototypeRoots()->GetTypedValue(0); + for (const auto& protoRootPath : protoRootPaths) { + instancingRelatedPaths.push_back(protoRootPath); + } } } From 597841e8a6a79ac341d30e4a1a0333358d0972f5 Mon Sep 17 00:00:00 2001 From: debloip Date: Mon, 26 Aug 2024 15:08:55 -0400 Subject: [PATCH 2/3] HYDRA-1160 : Add test --- .../cpp/testDataProducerExample.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/lib/mayaUsd/render/mayaToHydra/cpp/testDataProducerExample.py b/test/lib/mayaUsd/render/mayaToHydra/cpp/testDataProducerExample.py index 89cd192009..6543720b53 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/cpp/testDataProducerExample.py +++ b/test/lib/mayaUsd/render/mayaToHydra/cpp/testDataProducerExample.py @@ -58,6 +58,9 @@ def cube000PathString(self): def cube222PathString(self): return '|transform1|' + self._locator + ',/cube_2_2_2' + def cubePrototypePathString(self): + return '|transform1|' + self._locator + ',/cube_' + def test_Pick(self): # Pick an exterior cube to ensure we don't pick a hidden one. cmds.mayaHydraCppTest(self.cube222PathString(), f='TestUsdPicking.pick') @@ -132,5 +135,27 @@ def assertTranslationAlmostEqual(expected): cmds.redo() assertTranslationAlmostEqual([3, 4, 5]) + def test_SelectPrototype(self): + # Enable instancing + cmds.setAttr(self._locator + '.cubesUseInstancing', True) + + # Clear selection + sn = ufe.GlobalSelection.get() + sn.clear() + + # Empty Maya selection, therefore no fully selected path in the scene + # index. + cmds.mayaHydraCppTest(f='TestSelection.fullySelectedPaths') + + # Add cube to selection + item = ufe.Hierarchy.createItem(ufe.PathString.path(self.cubePrototypePathString())) + sn.append(item) + + # Item added to the Maya selection, it should be fully selected in the + # scene index. + cmds.mayaHydraCppTest( + self.cubePrototypePathString(), f='TestSelection.fullySelectedPaths') + + if __name__ == '__main__': fixturesUtils.runTests(globals()) From e1f36384438079aca8fb89a6547e4c567a1d21d2 Mon Sep 17 00:00:00 2001 From: debloip Date: Mon, 26 Aug 2024 15:32:48 -0400 Subject: [PATCH 3/3] HYDRA-1160 : Remove extra whitespace --- .../mayaUsd/render/mayaToHydra/cpp/testDataProducerExample.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/lib/mayaUsd/render/mayaToHydra/cpp/testDataProducerExample.py b/test/lib/mayaUsd/render/mayaToHydra/cpp/testDataProducerExample.py index 6543720b53..6a0aad63ea 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/cpp/testDataProducerExample.py +++ b/test/lib/mayaUsd/render/mayaToHydra/cpp/testDataProducerExample.py @@ -156,6 +156,5 @@ def test_SelectPrototype(self): cmds.mayaHydraCppTest( self.cubePrototypePathString(), f='TestSelection.fullySelectedPaths') - if __name__ == '__main__': fixturesUtils.runTests(globals())