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 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
31 changes: 31 additions & 0 deletions lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ const UsdPrim& ProxyShapeHierarchy::getUsdRootPrim() const

Ufe::SceneItem::Ptr ProxyShapeHierarchy::sceneItem() const { return fItem; }

#if (UFE_PREVIEW_VERSION_NUM >= 4004)

bool ProxyShapeHierarchy::hasChildren() const
{
// We have an extra logic in createUFEChildList to remap and filter
Expand All @@ -143,6 +145,35 @@ bool ProxyShapeHierarchy::hasChildren() const
return !children().empty();
}

bool ProxyShapeHierarchy::hasFilteredChildren(const ChildFilter& childFilter) const
{
// 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 !filteredChildren(childFilter).empty();
}

#else

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 !createUFEChildList(getUSDFilteredChildren(rootPrim), false /*filterInactive*/).empty();
ppt-adsk marked this conversation as resolved.
Show resolved Hide resolved
}

#endif

Ufe::SceneItemList ProxyShapeHierarchy::children() const
{
// Return children of the USD root.
Expand Down
3 changes: 3 additions & 0 deletions lib/mayaUsd/ufe/ProxyShapeHierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class MAYAUSD_CORE_PUBLIC ProxyShapeHierarchy : public Ufe::Hierarchy
Ufe::SceneItem::Ptr sceneItem() const override;
bool hasChildren() const override;
Ufe::SceneItemList children() const override;
#if (UFE_PREVIEW_VERSION_NUM >= 4004)
bool hasFilteredChildren(const ChildFilter&) const override;
#endif
UFE_V2(Ufe::SceneItemList filteredChildren(const ChildFilter&) const override;)
Ufe::SceneItem::Ptr parent() const override;
#ifndef UFE_V2_FEATURES_AVAILABLE
Expand Down
7 changes: 7 additions & 0 deletions lib/mayaUsd/ufe/PulledObjectHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ PulledObjectHierarchy::Ptr PulledObjectHierarchy::create(

Ufe::SceneItem::Ptr PulledObjectHierarchy::sceneItem() const { return _mayaHierarchy->sceneItem(); }

#if (UFE_PREVIEW_VERSION_NUM >= 4004)
bool PulledObjectHierarchy::hasFilteredChildren(const ChildFilter& childFilter) const
{
return _mayaHierarchy->hasFilteredChildren(childFilter);
}
#endif

bool PulledObjectHierarchy::hasChildren() const { return _mayaHierarchy->hasChildren(); }

Ufe::SceneItemList PulledObjectHierarchy::children() const { return _mayaHierarchy->children(); }
Expand Down
3 changes: 3 additions & 0 deletions lib/mayaUsd/ufe/PulledObjectHierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class MAYAUSD_CORE_PUBLIC PulledObjectHierarchy : public Ufe::Hierarchy
Ufe::SceneItem::Ptr sceneItem() const override;
bool hasChildren() const override;
Ufe::SceneItemList children() const override;
#if (UFE_PREVIEW_VERSION_NUM >= 4004)
bool hasFilteredChildren(const ChildFilter&) const override;
#endif
Ufe::SceneItemList filteredChildren(const ChildFilter&) const override;
Ufe::SceneItem::Ptr parent() const override;

Expand Down
27 changes: 27 additions & 0 deletions lib/mayaUsd/ufe/UsdHierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ UsdSceneItem::Ptr UsdHierarchy::usdSceneItem() const { return fItem; }

Ufe::SceneItem::Ptr UsdHierarchy::sceneItem() const { return fItem; }

#if (UFE_PREVIEW_VERSION_NUM >= 4004)

bool UsdHierarchy::hasChildren() const
{
// We have an extra logic in createUFEChildList to remap and filter
Expand All @@ -127,6 +129,31 @@ bool UsdHierarchy::hasChildren() const
return !children().empty();
}

bool UsdHierarchy::hasFilteredChildren(const ChildFilter& childFilter) const
{
// 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 !filteredChildren(childFilter).empty();
}

#else

bool UsdHierarchy::hasChildren() const
{
// 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.
const bool isFilteringInactive = false;
return !createUFEChildList(getUSDFilteredChildren(fItem), isFilteringInactive).empty();
seando-adsk marked this conversation as resolved.
Show resolved Hide resolved
}

#endif

Ufe::SceneItemList UsdHierarchy::children() const
{
return createUFEChildList(getUSDFilteredChildren(fItem), true /*filterInactive*/);
Expand Down
3 changes: 3 additions & 0 deletions lib/mayaUsd/ufe/UsdHierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class MAYAUSD_CORE_PUBLIC UsdHierarchy : public Ufe::Hierarchy
Ufe::SceneItem::Ptr sceneItem() const override;
bool hasChildren() const override;
Ufe::SceneItemList children() const override;
#if (UFE_PREVIEW_VERSION_NUM >= 4004)
bool hasFilteredChildren(const ChildFilter&) const override;
#endif
UFE_V2(Ufe::SceneItemList filteredChildren(const ChildFilter&) const override;)
Ufe::SceneItem::Ptr parent() const override;
#ifndef UFE_V2_FEATURES_AVAILABLE
Expand Down
7 changes: 7 additions & 0 deletions test/lib/ufe/testChildFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 19 additions & 5 deletions test/lib/ufe/testContextOps.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import fixturesUtils
import mayaUtils
import usdUtils
import ufeUtils

from pxr import UsdGeom

Expand Down Expand Up @@ -358,12 +359,25 @@ def testAddNewPrimWithDelete(self):
self.assertEqual(len(proxyShapehier.children()), 1)

# Using UFE, delete this new prim (which doesn't actually delete it but
# instead makes it inactive).
# instead makes it inactive). In Maya 2023 and greater, delete really
# deletes so deactivate instead to make the test act the same for all
# versions.
cmds.pickWalk(d='down')
cmds.delete()

# The proxy shape should now have no UFE child items (since we skip inactive).
self.assertFalse(proxyShapehier.hasChildren())
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.

ufeItem = ufe.GlobalSelection.get().front()
item = usdUtils.getPrimFromSceneItem(ufeItem)
item.SetActive(False)
else:
cmds.delete()

# The proxy shape should now have no UFE child items (since we skip inactive
# when returning the children list) but hasChildren still reports true in
# UFE version before 0.4.4 for inactive to allow the caller to do conditional
# inactive filtering, so we test that hasChildren is true for those versions.
if (os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') >= '4004'):
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