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

Fix hierarchy handler chain of responsibility child filter bug. #1810

Merged
merged 1 commit into from
Nov 8, 2021
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
5 changes: 4 additions & 1 deletion lib/mayaUsd/ufe/PulledObjectHierarchyHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ Ufe::SceneItem::Ptr PulledObjectHierarchyHandler::createItem(const Ufe::Path& pa
return _mayaHierarchyHandler->createItem(path);
}

Ufe::Hierarchy::ChildFilter PulledObjectHierarchyHandler::childFilter() const { return {}; }
Ufe::Hierarchy::ChildFilter PulledObjectHierarchyHandler::childFilter() const
{
return _mayaHierarchyHandler->childFilter();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the chain of responsibility we cannot assume that Maya handlers have no child filters: the proxy shape hierarchy handler adds a child filter flag for inactive prims, since its children are USD prims.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

}

} // namespace ufe
} // namespace MAYAUSD_NS_DEF
50 changes: 49 additions & 1 deletion test/lib/ufe/testChildFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
from maya import cmds
from maya import standalone

import mayaUsd.ufe

import ufe

import os
import unittest


Expand Down Expand Up @@ -90,6 +91,53 @@ def testFilteredChildren(self):
self.assertEqual(6, len(children))
self.assertIn(ball3Hier, children)

def testProxyShapeFilteredChildren(self):
# Check that the proxy shape has a single child, Ball_set.
psPath = ufe.PathString.path('|transform1|proxyShape1')
psItem = ufe.Hierarchy.createItem(psPath)
psHier = ufe.Hierarchy.hierarchy(psItem)
psChildren = psHier.children()

self.assertEqual(len(psChildren), 1)
ballSetPathStr = '|transform1|proxyShape1,/Ball_set'
ballSetPath = ufe.PathString.path(ballSetPathStr)
ballSetItem = ufe.Hierarchy.createItem(ballSetPath)
self.assertEqual(ballSetItem, psChildren[0])

# Get the USD child filter. We know from testFilteredChildren() that
# it has a single filter flag, 'InactivePrims'.
rid = ufe.RunTimeMgr.instance().getId('USD')
usdHierHndlr = ufe.RunTimeMgr.instance().hierarchyHandler(rid)
cf = usdHierHndlr.childFilter()

# The filtered children are the same as default children.
psFilteredChildren = psHier.filteredChildren(cf)
self.assertEqual(len(psFilteredChildren), 1)
self.assertEqual(ballSetItem, psFilteredChildren[0])

# Inactivate Ball_set. Default children will be empty, filtered
# children will remain the same.
ballSetPrim = mayaUsd.ufe.ufePathToPrim(ballSetPathStr)
ballSetPrim.SetActive(False)

psChildren = psHier.children()
self.assertEqual(len(psChildren), 0)

psFilteredChildren = psHier.filteredChildren(cf)
self.assertEqual(len(psFilteredChildren), 1)

# Now get the Maya child filter. Because the proxy shape hierarchy
# handler overrides the Maya child filter and adds the 'InactivePrims'
# child filter flag, it should be on the Maya child filter.
rid = ufe.RunTimeMgr.instance().getId('Maya-DG')
mayaHierHndlr = ufe.RunTimeMgr.instance().hierarchyHandler(rid)
cf = mayaHierHndlr.childFilter()
self.assertEqual(1, len(cf))
self.assertEqual('InactivePrims', cf[0].name)

psFilteredChildren = psHier.filteredChildren(cf)
self.assertEqual(len(psFilteredChildren), 1)
self.assertEqual(ballSetItem, psFilteredChildren[0])

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