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

HYDRA-1160 : Fix crash when traversing prototype prims without prototype roots for highlighting #159

Merged
merged 3 commits into from
Aug 27, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down
24 changes: 24 additions & 0 deletions test/lib/mayaUsd/render/mayaToHydra/cpp/testDataProducerExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -132,5 +135,26 @@ 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())