diff --git a/pxr/usd/usd/inherits.cpp b/pxr/usd/usd/inherits.cpp index 59b67a3d19..62f56fa863 100644 --- a/pxr/usd/usd/inherits.cpp +++ b/pxr/usd/usd/inherits.cpp @@ -84,8 +84,9 @@ UsdInherits::GetAllDirectInherits() const auto addIfDirectInheritFn = [&](const PcpNodeRef &node) { if (node.GetArcType() == PcpArcTypeInherit && - !node.GetOriginRootNode().IsDueToAncestor() && - seen.insert(node.GetPath()).second) { + node.GetLayerStack() == node.GetRootNode().GetLayerStack() && + !node.GetOriginRootNode().IsDueToAncestor() && + seen.insert(node.GetPath()).second) { ret.push_back(node.GetPath()); } }; @@ -106,14 +107,17 @@ UsdInherits::GetAllDirectInherits() const // specializes. Thus, we have to search under both the root's inherits // and its specializes to find all propagated inherit arcs. // - // Note that this relies on the fact that propagated direct class base arcs - // are not culled from the prim index even if they do not produce specs. + // We search the expanded prim index to ensure that we pick up all possible + // sources of opinions even if they currently do not produce specs. These + // locations may be culled from the index returned by _prim.GetPrimIndex(). + PcpPrimIndex fullPrimIndex = _prim.ComputeExpandedPrimIndex(); + for (const PcpNodeRef &node: - _prim.GetPrimIndex().GetNodeRange(PcpRangeTypeInherit)) { + fullPrimIndex.GetNodeRange(PcpRangeTypeInherit)) { addIfDirectInheritFn(node); } for (const PcpNodeRef &node: - _prim.GetPrimIndex().GetNodeRange(PcpRangeTypeSpecialize)) { + fullPrimIndex.GetNodeRange(PcpRangeTypeSpecialize)) { addIfDirectInheritFn(node); } return ret; diff --git a/pxr/usd/usd/testenv/testUsdInherits.py b/pxr/usd/usd/testenv/testUsdInherits.py index 70719332c6..af229ab3a7 100644 --- a/pxr/usd/usd/testenv/testUsdInherits.py +++ b/pxr/usd/usd/testenv/testUsdInherits.py @@ -340,7 +340,8 @@ def "Child" ( self.assertEqual(child.GetInherits().GetAllDirectInherits(), [Sdf.Path(path) for path in [ '/CI', '/CRI', '/CRI_NOSPEC', '/PRCI', '/PRCI_NOSPEC', - '/Parent/Sibling']]) + '/Parent/Sibling', '/PISI/Sibling', '/PSI/Sibling', + ]]) def test_ListPosition(self): for fmt in allFormats: