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

MAYA-122218 showing dactivated children #2265

Merged
merged 14 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
7 changes: 6 additions & 1 deletion lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,17 @@ Ufe::SceneItem::Ptr ProxyShapeHierarchy::sceneItem() const { return fItem; }

bool ProxyShapeHierarchy::hasChildren() const
{
// Return children of the USD root.
const UsdPrim& rootPrim = getUsdRootPrim();
if (!rootPrim.IsValid())
return false;

// We have an extra logic in createUFEChildList to remap and filter
// prims. Going this direction is more costly, but easier to maintain.
//
// I don't have data that proves we need to worry about performance in here,
// so going after maintainability.
return !children().empty();
return !createUFEChildList(getUSDFilteredChildren(rootPrim), false /*filterInactive*/).empty();
}

Ufe::SceneItemList ProxyShapeHierarchy::children() const
Expand Down
3 changes: 2 additions & 1 deletion lib/mayaUsd/ufe/UsdHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ bool UsdHierarchy::hasChildren() const
//
// I don't have data that proves we need to worry about performance in here,
// so going after maintainability.
return !children().empty();
const bool isFilteringInactive = false;
return !createUFEChildList(getUSDFilteredChildren(fItem), isFilteringInactive).empty();
}

Ufe::SceneItemList UsdHierarchy::children() const
Expand Down
9 changes: 8 additions & 1 deletion test/lib/ufe/testChildFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def testFilteredChildren(self):
ball3Prim = mayaUsd.ufe.ufePathToPrim(ball3PathStr)
ball3Prim.SetActive(False)

# Props should now have 5 children and ball3 should not be one of them.
# Props children should have 5 children and ball3 should not be one of them.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you remove "now". The comment was correct. At line 84 we test that there are 6 children and now we are testing that there are 5.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I took multiple passes to update the test and did not realized I dropped a word there.

children = propsHier.children()
self.assertEqual(5, len(children))
self.assertNotIn(ball3Item, children)
Expand All @@ -102,6 +102,13 @@ def testFilteredChildren(self):
usdHierHndlr = ufe.RunTimeMgr.instance().hierarchyHandler(ball3Item.runTimeId())
cf = usdHierHndlr.childFilter()

# Toggle "Inactive Prims" off and get the filtered children
# Props filtered children should have 5 children and ball3 should not be one of them.
cf[0].value = False
children = propsHier.filteredChildren(cf)
self.assertEqual(5, len(children))
self.assertNotIn(ball3Item, children)

# Toggle "Inactive Prims" on and get the filtered children
# (with inactive prims) and verify ball3 is one of them.
cf[0].value = True
Expand Down
9 changes: 7 additions & 2 deletions test/lib/ufe/testContextOps.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,13 @@ def testAddNewPrimWithDelete(self):
cmds.pickWalk(d='down')
cmds.delete()

# The proxy shape should now have no UFE child items (since we skip inactive).
self.assertFalse(proxyShapehier.hasChildren())
# The proxy shape should now have no UFE child items (since we skip inactive)
# but hasChildren still reports true for inactive to allow the caller to then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment and code don't match.

# do conditional inactive filtering.
if mayaUtils.mayaMajorVersion() >= 2023:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm confused why this check is against a Maya version. What change is there in Maya that is affecting this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm confused as to why we changed the test at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The behaviour of the delete command vs prim changed from deactibvating to really deleting. When deactivated, hasChildren() returns true.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay then instead of using then the Maya test should also surround lines 363 (which does the delete) and the comment you wrote here should be added to the test. Then for Maya 2023 we should not use delete, but instead deactivate the prim.

self.assertFalse(proxyShapehier.hasChildren())
else:
self.assertTrue(proxyShapehier.hasChildren())
self.assertEqual(len(proxyShapehier.children()), 0)

# Add another Xform prim (which should get a unique name taking into
Expand Down