From 881c1b353f4f38af5da8e08f2b8e9410a7c2a553 Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Thu, 7 Apr 2022 13:16:43 -0400 Subject: [PATCH 01/14] MAYA-122218 showing dactivated children Some code paths were ignoring deactivated children when they should not because hasChildren() was ignoring deactivated children. --- lib/mayaUsd/ufe/UsdHierarchy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/mayaUsd/ufe/UsdHierarchy.cpp b/lib/mayaUsd/ufe/UsdHierarchy.cpp index 45ec40b46b..74d2da6ce3 100644 --- a/lib/mayaUsd/ufe/UsdHierarchy.cpp +++ b/lib/mayaUsd/ufe/UsdHierarchy.cpp @@ -129,7 +129,8 @@ bool UsdHierarchy::hasChildren() const Ufe::SceneItemList UsdHierarchy::children() const { - return createUFEChildList(getUSDFilteredChildren(fItem), true /*filterInactive*/); + const bool isFilteringInactive = false; + return createUFEChildList(getUSDFilteredChildren(fItem), isFilteringInactive); } #ifdef UFE_V2_FEATURES_AVAILABLE From 1f19cf73092f06bebada6c3143c87db865119b44 Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Thu, 7 Apr 2022 14:21:47 -0400 Subject: [PATCH 02/14] MAYA122218 update the hiearchy unit test to reflect the current behaviour --- test/lib/ufe/testChildFilter.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/lib/ufe/testChildFilter.py b/test/lib/ufe/testChildFilter.py index 50e74ec9cb..eb98c55c47 100644 --- a/test/lib/ufe/testChildFilter.py +++ b/test/lib/ufe/testChildFilter.py @@ -92,16 +92,23 @@ 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 should still have 6 children and ball3 should still be one of them. children = propsHier.children() - self.assertEqual(5, len(children)) - self.assertNotIn(ball3Item, children) + self.assertEqual(6, len(children)) + self.assertIn(ball3Item, children) # Get the child filter for the hierarchy handler corresponding # to the runtime of the Ball_3. 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 From 639786756d0d6e98dc36b17cb0924f3d3de5d86e Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Thu, 7 Apr 2022 15:51:32 -0400 Subject: [PATCH 03/14] MAYA-122218 made children not return deactivated items Reverted the children behaviour to not return deactivated items. Only made hasChildren() consider deactivated children. --- lib/mayaUsd/ufe/UsdHierarchy.cpp | 5 +++-- test/lib/ufe/testChildFilter.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/mayaUsd/ufe/UsdHierarchy.cpp b/lib/mayaUsd/ufe/UsdHierarchy.cpp index 74d2da6ce3..4334db35d6 100644 --- a/lib/mayaUsd/ufe/UsdHierarchy.cpp +++ b/lib/mayaUsd/ufe/UsdHierarchy.cpp @@ -124,12 +124,13 @@ 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 { - const bool isFilteringInactive = false; + const bool isFilteringInactive = true; return createUFEChildList(getUSDFilteredChildren(fItem), isFilteringInactive); } diff --git a/test/lib/ufe/testChildFilter.py b/test/lib/ufe/testChildFilter.py index eb98c55c47..18d9081590 100644 --- a/test/lib/ufe/testChildFilter.py +++ b/test/lib/ufe/testChildFilter.py @@ -92,10 +92,10 @@ def testFilteredChildren(self): ball3Prim = mayaUsd.ufe.ufePathToPrim(ball3PathStr) ball3Prim.SetActive(False) - # Props should still have 6 children and ball3 should still be one of them. + # Props children should have 5 children and ball3 should not be one of them. children = propsHier.children() - self.assertEqual(6, len(children)) - self.assertIn(ball3Item, children) + self.assertEqual(5, len(children)) + self.assertNotIn(ball3Item, children) # Get the child filter for the hierarchy handler corresponding # to the runtime of the Ball_3. From f5c56a22163d6b085b5874b189e72b061a1a044a Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Fri, 8 Apr 2022 08:56:05 -0400 Subject: [PATCH 04/14] MAYA-122218 apply fix to proxy shape Proxy shape has duplicated code that also need the fix. Also put back in place the old code form in children() to minimize the diff. --- lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp | 7 ++++++- lib/mayaUsd/ufe/UsdHierarchy.cpp | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp b/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp index 9a6b66f8a1..9171658ff7 100644 --- a/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp +++ b/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp @@ -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 diff --git a/lib/mayaUsd/ufe/UsdHierarchy.cpp b/lib/mayaUsd/ufe/UsdHierarchy.cpp index 4334db35d6..6e44f44ce0 100644 --- a/lib/mayaUsd/ufe/UsdHierarchy.cpp +++ b/lib/mayaUsd/ufe/UsdHierarchy.cpp @@ -130,8 +130,7 @@ bool UsdHierarchy::hasChildren() const Ufe::SceneItemList UsdHierarchy::children() const { - const bool isFilteringInactive = true; - return createUFEChildList(getUSDFilteredChildren(fItem), isFilteringInactive); + return createUFEChildList(getUSDFilteredChildren(fItem), true /*filterInactive*/); } #ifdef UFE_V2_FEATURES_AVAILABLE From 7cdfefe48992fad920c804364ffb28741b0b292c Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Fri, 8 Apr 2022 11:50:55 -0400 Subject: [PATCH 05/14] MAYA-122218 fix conntext op test in 2022 and earlier Maya 2022 desctivate the prim when deleting, but 2023 and later permanently deletes them. --- test/lib/ufe/testContextOps.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/lib/ufe/testContextOps.py b/test/lib/ufe/testContextOps.py index f5742cb13a..1bc7263dc4 100644 --- a/test/lib/ufe/testContextOps.py +++ b/test/lib/ufe/testContextOps.py @@ -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 + # do conditional inactive filtering. + if mayaUtils.mayaMajorVersion() >= 2023: + 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 From e4dbc7a7a079ef0a1e55531f1c7e6d539c96e49c Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Thu, 14 Apr 2022 13:55:28 -0400 Subject: [PATCH 06/14] MAYA-122218 implement new hasFilteredChilden from UFE --- lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp | 26 +++++++++++++++++++++++ lib/mayaUsd/ufe/ProxyShapeHierarchy.h | 1 + lib/mayaUsd/ufe/PulledObjectHierarchy.cpp | 9 ++++++++ lib/mayaUsd/ufe/PulledObjectHierarchy.h | 3 ++- lib/mayaUsd/ufe/UsdHierarchy.cpp | 26 +++++++++++++++++++++++ lib/mayaUsd/ufe/UsdHierarchy.h | 1 + 6 files changed, 65 insertions(+), 1 deletion(-) diff --git a/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp b/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp index 9171658ff7..ae0660cda4 100644 --- a/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp +++ b/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp @@ -133,6 +133,30 @@ const UsdPrim& ProxyShapeHierarchy::getUsdRootPrim() const Ufe::SceneItem::Ptr ProxyShapeHierarchy::sceneItem() const { return fItem; } +#ifdef UFE_V4_FEATURES_AVAILABLE + +bool ProxyShapeHierarchy::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. + 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. @@ -148,6 +172,8 @@ bool ProxyShapeHierarchy::hasChildren() const return !createUFEChildList(getUSDFilteredChildren(rootPrim), false /*filterInactive*/).empty(); } +#endif + Ufe::SceneItemList ProxyShapeHierarchy::children() const { // Return children of the USD root. diff --git a/lib/mayaUsd/ufe/ProxyShapeHierarchy.h b/lib/mayaUsd/ufe/ProxyShapeHierarchy.h index 3185c0e62e..818a7daa03 100644 --- a/lib/mayaUsd/ufe/ProxyShapeHierarchy.h +++ b/lib/mayaUsd/ufe/ProxyShapeHierarchy.h @@ -57,6 +57,7 @@ class MAYAUSD_CORE_PUBLIC ProxyShapeHierarchy : public Ufe::Hierarchy Ufe::SceneItem::Ptr sceneItem() const override; bool hasChildren() const override; Ufe::SceneItemList children() const override; + UFE_V4(bool hasFilteredChildren(const ChildFilter&) const override;) UFE_V2(Ufe::SceneItemList filteredChildren(const ChildFilter&) const override;) Ufe::SceneItem::Ptr parent() const override; #ifndef UFE_V2_FEATURES_AVAILABLE diff --git a/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp b/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp index 67f55edfb5..8a1e989d47 100644 --- a/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp +++ b/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp @@ -52,14 +52,23 @@ PulledObjectHierarchy::Ptr PulledObjectHierarchy::create( Ufe::SceneItem::Ptr PulledObjectHierarchy::sceneItem() const { return _mayaHierarchy->sceneItem(); } +#ifdef UFE_V4_FEATURES_AVAILABLE +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(); } +#ifdef UFE_V2_FEATURES_AVAILABLE Ufe::SceneItemList PulledObjectHierarchy::filteredChildren(const ChildFilter& childFilter) const { return _mayaHierarchy->filteredChildren(childFilter); } +#endif Ufe::SceneItem::Ptr PulledObjectHierarchy::parent() const { diff --git a/lib/mayaUsd/ufe/PulledObjectHierarchy.h b/lib/mayaUsd/ufe/PulledObjectHierarchy.h index ba7101e0e5..9bafdf4b36 100644 --- a/lib/mayaUsd/ufe/PulledObjectHierarchy.h +++ b/lib/mayaUsd/ufe/PulledObjectHierarchy.h @@ -58,7 +58,8 @@ class MAYAUSD_CORE_PUBLIC PulledObjectHierarchy : public Ufe::Hierarchy Ufe::SceneItem::Ptr sceneItem() const override; bool hasChildren() const override; Ufe::SceneItemList children() const override; - Ufe::SceneItemList filteredChildren(const ChildFilter&) const override; + UFE_V4(bool hasFilteredChildren(const ChildFilter&) const override;) + UFE_V2(Ufe::SceneItemList filteredChildren(const ChildFilter&) const override;) Ufe::SceneItem::Ptr parent() const override; Ufe::SceneItem::Ptr createGroup(const Ufe::PathComponent& name) const override; diff --git a/lib/mayaUsd/ufe/UsdHierarchy.cpp b/lib/mayaUsd/ufe/UsdHierarchy.cpp index 6e44f44ce0..481d6d5371 100644 --- a/lib/mayaUsd/ufe/UsdHierarchy.cpp +++ b/lib/mayaUsd/ufe/UsdHierarchy.cpp @@ -117,6 +117,30 @@ UsdSceneItem::Ptr UsdHierarchy::usdSceneItem() const { return fItem; } Ufe::SceneItem::Ptr UsdHierarchy::sceneItem() const { return fItem; } +#ifdef UFE_V4_FEATURES_AVAILABLE + +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. + 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 @@ -128,6 +152,8 @@ bool UsdHierarchy::hasChildren() const return !createUFEChildList(getUSDFilteredChildren(fItem), isFilteringInactive).empty(); } +#endif + Ufe::SceneItemList UsdHierarchy::children() const { return createUFEChildList(getUSDFilteredChildren(fItem), true /*filterInactive*/); diff --git a/lib/mayaUsd/ufe/UsdHierarchy.h b/lib/mayaUsd/ufe/UsdHierarchy.h index 716b292da2..5564171c69 100644 --- a/lib/mayaUsd/ufe/UsdHierarchy.h +++ b/lib/mayaUsd/ufe/UsdHierarchy.h @@ -63,6 +63,7 @@ class MAYAUSD_CORE_PUBLIC UsdHierarchy : public Ufe::Hierarchy Ufe::SceneItem::Ptr sceneItem() const override; bool hasChildren() const override; Ufe::SceneItemList children() const override; + UFE_V4(bool hasFilteredChildren(const ChildFilter&) const override;) UFE_V2(Ufe::SceneItemList filteredChildren(const ChildFilter&) const override;) Ufe::SceneItem::Ptr parent() const override; #ifndef UFE_V2_FEATURES_AVAILABLE From ece19c4b1b37dd158f36aab1939824426135a7fc Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Thu, 14 Apr 2022 16:10:51 -0400 Subject: [PATCH 07/14] MAYA-122218 fix detection of UFe version. Need to detect patch level 4. --- lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp | 2 +- lib/mayaUsd/ufe/ProxyShapeHierarchy.h | 4 +++- lib/mayaUsd/ufe/PulledObjectHierarchy.cpp | 2 +- lib/mayaUsd/ufe/PulledObjectHierarchy.h | 4 +++- lib/mayaUsd/ufe/UsdHierarchy.cpp | 2 +- lib/mayaUsd/ufe/UsdHierarchy.h | 4 +++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp b/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp index ae0660cda4..faa194f96c 100644 --- a/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp +++ b/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp @@ -133,7 +133,7 @@ const UsdPrim& ProxyShapeHierarchy::getUsdRootPrim() const Ufe::SceneItem::Ptr ProxyShapeHierarchy::sceneItem() const { return fItem; } -#ifdef UFE_V4_FEATURES_AVAILABLE +#if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) bool ProxyShapeHierarchy::hasChildren() const { diff --git a/lib/mayaUsd/ufe/ProxyShapeHierarchy.h b/lib/mayaUsd/ufe/ProxyShapeHierarchy.h index 818a7daa03..3e5e02f69c 100644 --- a/lib/mayaUsd/ufe/ProxyShapeHierarchy.h +++ b/lib/mayaUsd/ufe/ProxyShapeHierarchy.h @@ -57,7 +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; - UFE_V4(bool hasFilteredChildren(const ChildFilter&) const override;) +#if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) + 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 diff --git a/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp b/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp index 8a1e989d47..02551e09e3 100644 --- a/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp +++ b/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp @@ -52,7 +52,7 @@ PulledObjectHierarchy::Ptr PulledObjectHierarchy::create( Ufe::SceneItem::Ptr PulledObjectHierarchy::sceneItem() const { return _mayaHierarchy->sceneItem(); } -#ifdef UFE_V4_FEATURES_AVAILABLE +#if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) bool PulledObjectHierarchy::hasFilteredChildren(const ChildFilter& childFilter) const { return _mayaHierarchy->hasFilteredChildren(childFilter); diff --git a/lib/mayaUsd/ufe/PulledObjectHierarchy.h b/lib/mayaUsd/ufe/PulledObjectHierarchy.h index 9bafdf4b36..241fee911f 100644 --- a/lib/mayaUsd/ufe/PulledObjectHierarchy.h +++ b/lib/mayaUsd/ufe/PulledObjectHierarchy.h @@ -58,7 +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; - UFE_V4(bool hasFilteredChildren(const ChildFilter&) const override;) +#if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) + bool hasFilteredChildren(const ChildFilter&) const override; +#endif UFE_V2(Ufe::SceneItemList filteredChildren(const ChildFilter&) const override;) Ufe::SceneItem::Ptr parent() const override; diff --git a/lib/mayaUsd/ufe/UsdHierarchy.cpp b/lib/mayaUsd/ufe/UsdHierarchy.cpp index 481d6d5371..466f5a42a9 100644 --- a/lib/mayaUsd/ufe/UsdHierarchy.cpp +++ b/lib/mayaUsd/ufe/UsdHierarchy.cpp @@ -117,7 +117,7 @@ UsdSceneItem::Ptr UsdHierarchy::usdSceneItem() const { return fItem; } Ufe::SceneItem::Ptr UsdHierarchy::sceneItem() const { return fItem; } -#ifdef UFE_V4_FEATURES_AVAILABLE +#if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) bool UsdHierarchy::hasChildren() const { diff --git a/lib/mayaUsd/ufe/UsdHierarchy.h b/lib/mayaUsd/ufe/UsdHierarchy.h index 5564171c69..37fb89b146 100644 --- a/lib/mayaUsd/ufe/UsdHierarchy.h +++ b/lib/mayaUsd/ufe/UsdHierarchy.h @@ -63,7 +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; - UFE_V4(bool hasFilteredChildren(const ChildFilter&) const override;) +#if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) + 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 From 1e034d1b033f09f08ab5934538a067fe1d698545 Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Fri, 15 Apr 2022 08:55:51 -0400 Subject: [PATCH 08/14] MAYA-122218 code format --- lib/mayaUsd/ufe/ProxyShapeHierarchy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mayaUsd/ufe/ProxyShapeHierarchy.h b/lib/mayaUsd/ufe/ProxyShapeHierarchy.h index 3e5e02f69c..3a2aea107d 100644 --- a/lib/mayaUsd/ufe/ProxyShapeHierarchy.h +++ b/lib/mayaUsd/ufe/ProxyShapeHierarchy.h @@ -58,7 +58,7 @@ class MAYAUSD_CORE_PUBLIC ProxyShapeHierarchy : public Ufe::Hierarchy bool hasChildren() const override; Ufe::SceneItemList children() const override; #if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) - bool hasFilteredChildren(const ChildFilter&) const override; + bool hasFilteredChildren(const ChildFilter&) const override; #endif UFE_V2(Ufe::SceneItemList filteredChildren(const ChildFilter&) const override;) Ufe::SceneItem::Ptr parent() const override; From 23de53baedb6e96aa58fb8160dfa4cb2356dea9d Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Tue, 19 Apr 2022 13:26:11 -0400 Subject: [PATCH 09/14] MAYA-122218 simplify code - Simplified the #if used to detect the UFE version. - Removed the UFE_V2 that was not needed. - Simplified the test. --- lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp | 2 +- lib/mayaUsd/ufe/ProxyShapeHierarchy.h | 2 +- lib/mayaUsd/ufe/PulledObjectHierarchy.cpp | 2 +- lib/mayaUsd/ufe/PulledObjectHierarchy.h | 4 ++-- lib/mayaUsd/ufe/UsdHierarchy.cpp | 2 +- lib/mayaUsd/ufe/UsdHierarchy.h | 2 +- test/lib/ufe/testChildFilter.py | 2 +- test/lib/ufe/testContextOps.py | 15 +++++++++------ 8 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp b/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp index faa194f96c..af4ff72f3c 100644 --- a/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp +++ b/lib/mayaUsd/ufe/ProxyShapeHierarchy.cpp @@ -133,7 +133,7 @@ const UsdPrim& ProxyShapeHierarchy::getUsdRootPrim() const Ufe::SceneItem::Ptr ProxyShapeHierarchy::sceneItem() const { return fItem; } -#if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) +#if (UFE_PREVIEW_VERSION_NUM >= 4004) bool ProxyShapeHierarchy::hasChildren() const { diff --git a/lib/mayaUsd/ufe/ProxyShapeHierarchy.h b/lib/mayaUsd/ufe/ProxyShapeHierarchy.h index 3a2aea107d..92009ee63d 100644 --- a/lib/mayaUsd/ufe/ProxyShapeHierarchy.h +++ b/lib/mayaUsd/ufe/ProxyShapeHierarchy.h @@ -57,7 +57,7 @@ class MAYAUSD_CORE_PUBLIC ProxyShapeHierarchy : public Ufe::Hierarchy Ufe::SceneItem::Ptr sceneItem() const override; bool hasChildren() const override; Ufe::SceneItemList children() const override; -#if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) +#if (UFE_PREVIEW_VERSION_NUM >= 4004) bool hasFilteredChildren(const ChildFilter&) const override; #endif UFE_V2(Ufe::SceneItemList filteredChildren(const ChildFilter&) const override;) diff --git a/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp b/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp index 02551e09e3..be83da4c0c 100644 --- a/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp +++ b/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp @@ -52,7 +52,7 @@ PulledObjectHierarchy::Ptr PulledObjectHierarchy::create( Ufe::SceneItem::Ptr PulledObjectHierarchy::sceneItem() const { return _mayaHierarchy->sceneItem(); } -#if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) +#if (UFE_PREVIEW_VERSION_NUM >= 4004) bool PulledObjectHierarchy::hasFilteredChildren(const ChildFilter& childFilter) const { return _mayaHierarchy->hasFilteredChildren(childFilter); diff --git a/lib/mayaUsd/ufe/PulledObjectHierarchy.h b/lib/mayaUsd/ufe/PulledObjectHierarchy.h index 241fee911f..b3e92377cb 100644 --- a/lib/mayaUsd/ufe/PulledObjectHierarchy.h +++ b/lib/mayaUsd/ufe/PulledObjectHierarchy.h @@ -58,10 +58,10 @@ class MAYAUSD_CORE_PUBLIC PulledObjectHierarchy : public Ufe::Hierarchy Ufe::SceneItem::Ptr sceneItem() const override; bool hasChildren() const override; Ufe::SceneItemList children() const override; -#if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) +#if (UFE_PREVIEW_VERSION_NUM >= 4004) bool hasFilteredChildren(const ChildFilter&) const override; #endif - UFE_V2(Ufe::SceneItemList filteredChildren(const ChildFilter&) const override;) + Ufe::SceneItemList filteredChildren(const ChildFilter&) const override; Ufe::SceneItem::Ptr parent() const override; Ufe::SceneItem::Ptr createGroup(const Ufe::PathComponent& name) const override; diff --git a/lib/mayaUsd/ufe/UsdHierarchy.cpp b/lib/mayaUsd/ufe/UsdHierarchy.cpp index 466f5a42a9..c7bea791ae 100644 --- a/lib/mayaUsd/ufe/UsdHierarchy.cpp +++ b/lib/mayaUsd/ufe/UsdHierarchy.cpp @@ -117,7 +117,7 @@ UsdSceneItem::Ptr UsdHierarchy::usdSceneItem() const { return fItem; } Ufe::SceneItem::Ptr UsdHierarchy::sceneItem() const { return fItem; } -#if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) +#if (UFE_PREVIEW_VERSION_NUM >= 4004) bool UsdHierarchy::hasChildren() const { diff --git a/lib/mayaUsd/ufe/UsdHierarchy.h b/lib/mayaUsd/ufe/UsdHierarchy.h index 37fb89b146..8ee22cfc77 100644 --- a/lib/mayaUsd/ufe/UsdHierarchy.h +++ b/lib/mayaUsd/ufe/UsdHierarchy.h @@ -63,7 +63,7 @@ class MAYAUSD_CORE_PUBLIC UsdHierarchy : public Ufe::Hierarchy Ufe::SceneItem::Ptr sceneItem() const override; bool hasChildren() const override; Ufe::SceneItemList children() const override; -#if defined(UFE_V4_FEATURES_AVAILABLE) && (UFE_MINOR_VERSION > 4 || UFE_PATCH_LEVEL > 3) +#if (UFE_PREVIEW_VERSION_NUM >= 4004) bool hasFilteredChildren(const ChildFilter&) const override; #endif UFE_V2(Ufe::SceneItemList filteredChildren(const ChildFilter&) const override;) diff --git a/test/lib/ufe/testChildFilter.py b/test/lib/ufe/testChildFilter.py index 18d9081590..8f97856291 100644 --- a/test/lib/ufe/testChildFilter.py +++ b/test/lib/ufe/testChildFilter.py @@ -92,7 +92,7 @@ def testFilteredChildren(self): ball3Prim = mayaUsd.ufe.ufePathToPrim(ball3PathStr) ball3Prim.SetActive(False) - # Props children should have 5 children and ball3 should not be one of them. + # Props should now have 5 children and ball3 should not be one of them. children = propsHier.children() self.assertEqual(5, len(children)) self.assertNotIn(ball3Item, children) diff --git a/test/lib/ufe/testContextOps.py b/test/lib/ufe/testContextOps.py index 1bc7263dc4..cc88ee0c1d 100644 --- a/test/lib/ufe/testContextOps.py +++ b/test/lib/ufe/testContextOps.py @@ -358,17 +358,20 @@ 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 vreater, delete really + # deletes so deactivate instead. cmds.pickWalk(d='down') - cmds.delete() + if mayaUtils.mayaMajorVersion() >= 2023: + 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) # but hasChildren still reports true for inactive to allow the caller to then # do conditional inactive filtering. - if mayaUtils.mayaMajorVersion() >= 2023: - self.assertFalse(proxyShapehier.hasChildren()) - else: - self.assertTrue(proxyShapehier.hasChildren()) + self.assertFalse(proxyShapehier.hasChildren()) self.assertEqual(len(proxyShapehier.children()), 0) # Add another Xform prim (which should get a unique name taking into From ca0eed59b8b9ad3872a9b182b2ef373288c1a10b Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Wed, 20 Apr 2022 09:11:11 -0400 Subject: [PATCH 10/14] MAYA-122218 fix version checks - Removed redundant conditional compilation. - Fix context ops test to account for different behavior in different versions. --- lib/mayaUsd/ufe/PulledObjectHierarchy.cpp | 2 -- test/lib/ufe/testContextOps.py | 19 ++++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp b/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp index be83da4c0c..574bc20b75 100644 --- a/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp +++ b/lib/mayaUsd/ufe/PulledObjectHierarchy.cpp @@ -63,12 +63,10 @@ bool PulledObjectHierarchy::hasChildren() const { return _mayaHierarchy->hasChil Ufe::SceneItemList PulledObjectHierarchy::children() const { return _mayaHierarchy->children(); } -#ifdef UFE_V2_FEATURES_AVAILABLE Ufe::SceneItemList PulledObjectHierarchy::filteredChildren(const ChildFilter& childFilter) const { return _mayaHierarchy->filteredChildren(childFilter); } -#endif Ufe::SceneItem::Ptr PulledObjectHierarchy::parent() const { diff --git a/test/lib/ufe/testContextOps.py b/test/lib/ufe/testContextOps.py index cc88ee0c1d..230b58fde2 100644 --- a/test/lib/ufe/testContextOps.py +++ b/test/lib/ufe/testContextOps.py @@ -358,20 +358,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). In Maya 2023 and vreater, delete really - # deletes so deactivate instead. + # 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') - if mayaUtils.mayaMajorVersion() >= 2023: + if mayaUtils.mayaMajorMinorVersions() > (2023, 1): 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) - # but hasChildren still reports true for inactive to allow the caller to then - # do conditional inactive filtering. - self.assertFalse(proxyShapehier.hasChildren()) + # 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 + # Maya versions before 2023 for inactive to allow the caller to do conditional + # inactive filtering, so we test that hasChildren is true for those versions. + if mayaUtils.mayaMajorMinorVersions() > (2023, 1): + 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 From ab3bdb990ee10538e642fe2906f625b039936012 Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Wed, 20 Apr 2022 10:30:06 -0400 Subject: [PATCH 11/14] MAYA-122218 fix test version check The behavior of hasChildren is based on the UFE version, not the Maya version, unlike the behaviour of cmds.delete. --- test/lib/ufe/testContextOps.py | 5 +++-- test/testUtils/ufeUtils.py | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/test/lib/ufe/testContextOps.py b/test/lib/ufe/testContextOps.py index 230b58fde2..63e2addcad 100644 --- a/test/lib/ufe/testContextOps.py +++ b/test/lib/ufe/testContextOps.py @@ -19,6 +19,7 @@ import fixturesUtils import mayaUtils import usdUtils +import ufeUtils from pxr import UsdGeom @@ -371,9 +372,9 @@ def testAddNewPrimWithDelete(self): # 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 - # Maya versions before 2023 for inactive to allow the caller to do conditional + # 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 mayaUtils.mayaMajorMinorVersions() > (2023, 1): + if ufeUtils.hasMinimumVersion((4, 0, 0), (0, 4, 4)): self.assertFalse(proxyShapehier.hasChildren()) else: self.assertTrue(proxyShapehier.hasChildren()) diff --git a/test/testUtils/ufeUtils.py b/test/testUtils/ufeUtils.py index 547d291d98..aa8950a4b8 100644 --- a/test/testUtils/ufeUtils.py +++ b/test/testUtils/ufeUtils.py @@ -105,3 +105,26 @@ def ufeFeatureSetVersion(): # v0.2.20 (unreleased preview version 2). major = ufe.VersionInfo.getMajorVersion() return ufe.VersionInfo.getMinorVersion() if major == 0 else major + +def hasMinimumVersion(releaseVersions, unreleasedVersions): + ''' + Verify if the minimum release or unrelease version are fulfilled. + Due to the fact release version are x.y.z while unrelease are 0.x.y, + conditionals are cmore complex to write, so this function takes the + burden out of checking. + + The versions passed in should be a tuple of (major, minor, patch), + on for released and one for unreleased, so for example: + (4, 0, 0) and (0, 4, 4) + + Which assumes that everything in the unreleased (0, 4, 4) will be + in the released (4, 0, 0), which is what happens. + ''' + major = ufe.VersionInfo.getMajorVersion() + minor = ufe.VersionInfo.getMinorVersion() + patch = ufe.VersionInfo.getPatchLevel() + version = (major, minor, patch) + if major: + return version >= releaseVersions + else: + return version >= unreleasedVersions From ab18f848114ce2a865f3bb96330563ae7214ee96 Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Wed, 20 Apr 2022 13:42:54 -0400 Subject: [PATCH 12/14] MAYA-122218 test correct Maya version. It is all 2023 versions, not just 2023.1 that really deletes. --- test/lib/ufe/testContextOps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/ufe/testContextOps.py b/test/lib/ufe/testContextOps.py index 63e2addcad..8d1d444bd9 100644 --- a/test/lib/ufe/testContextOps.py +++ b/test/lib/ufe/testContextOps.py @@ -363,7 +363,7 @@ def testAddNewPrimWithDelete(self): # deletes so deactivate instead to make the test act the same for all # versions. cmds.pickWalk(d='down') - if mayaUtils.mayaMajorMinorVersions() > (2023, 1): + if mayaUtils.mayaMajorVersion() >= 2023: ufeItem = ufe.GlobalSelection.get().front() item = usdUtils.getPrimFromSceneItem(ufeItem) item.SetActive(False) From b9e2aa862cda79486eba5efea9ebb3c5c8fe0e24 Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Wed, 20 Apr 2022 15:51:27 -0400 Subject: [PATCH 13/14] MAYA-122218 only use UFE pre-releae version for teh check. --- test/lib/ufe/testContextOps.py | 3 ++- test/testUtils/ufeUtils.py | 22 +++++----------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/test/lib/ufe/testContextOps.py b/test/lib/ufe/testContextOps.py index 8d1d444bd9..6c50d9de3b 100644 --- a/test/lib/ufe/testContextOps.py +++ b/test/lib/ufe/testContextOps.py @@ -374,7 +374,8 @@ def testAddNewPrimWithDelete(self): # 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 ufeUtils.hasMinimumVersion((4, 0, 0), (0, 4, 4)): + ufeVersion = ufeUtils.fullVersion() + if (0, 4, 4) <= ufeVersion < (1, 0, 0): self.assertFalse(proxyShapehier.hasChildren()) else: self.assertTrue(proxyShapehier.hasChildren()) diff --git a/test/testUtils/ufeUtils.py b/test/testUtils/ufeUtils.py index aa8950a4b8..9d7461d801 100644 --- a/test/testUtils/ufeUtils.py +++ b/test/testUtils/ufeUtils.py @@ -106,25 +106,13 @@ def ufeFeatureSetVersion(): major = ufe.VersionInfo.getMajorVersion() return ufe.VersionInfo.getMinorVersion() if major == 0 else major -def hasMinimumVersion(releaseVersions, unreleasedVersions): +def fullVersion(): ''' - Verify if the minimum release or unrelease version are fulfilled. - Due to the fact release version are x.y.z while unrelease are 0.x.y, - conditionals are cmore complex to write, so this function takes the - burden out of checking. - - The versions passed in should be a tuple of (major, minor, patch), - on for released and one for unreleased, so for example: - (4, 0, 0) and (0, 4, 4) - - Which assumes that everything in the unreleased (0, 4, 4) will be - in the released (4, 0, 0), which is what happens. + Return the full UFE version as a tuple of (major, minor, patch), + so for example: + (0, 4, 4) ''' major = ufe.VersionInfo.getMajorVersion() minor = ufe.VersionInfo.getMinorVersion() patch = ufe.VersionInfo.getPatchLevel() - version = (major, minor, patch) - if major: - return version >= releaseVersions - else: - return version >= unreleasedVersions + return (major, minor, patch) From 995a1f4f79fae281a011d33192c921c36d9095d4 Mon Sep 17 00:00:00 2001 From: Pierre Baillargeon Date: Thu, 21 Apr 2022 09:45:55 -0400 Subject: [PATCH 14/14] MAYA-122218 use UFE version env var. --- test/lib/ufe/testContextOps.py | 3 +-- test/testUtils/ufeUtils.py | 11 ----------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/test/lib/ufe/testContextOps.py b/test/lib/ufe/testContextOps.py index 6c50d9de3b..bd65cb997a 100644 --- a/test/lib/ufe/testContextOps.py +++ b/test/lib/ufe/testContextOps.py @@ -374,8 +374,7 @@ def testAddNewPrimWithDelete(self): # 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. - ufeVersion = ufeUtils.fullVersion() - if (0, 4, 4) <= ufeVersion < (1, 0, 0): + if (os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') >= '4004'): self.assertFalse(proxyShapehier.hasChildren()) else: self.assertTrue(proxyShapehier.hasChildren()) diff --git a/test/testUtils/ufeUtils.py b/test/testUtils/ufeUtils.py index 9d7461d801..547d291d98 100644 --- a/test/testUtils/ufeUtils.py +++ b/test/testUtils/ufeUtils.py @@ -105,14 +105,3 @@ def ufeFeatureSetVersion(): # v0.2.20 (unreleased preview version 2). major = ufe.VersionInfo.getMajorVersion() return ufe.VersionInfo.getMinorVersion() if major == 0 else major - -def fullVersion(): - ''' - Return the full UFE version as a tuple of (major, minor, patch), - so for example: - (0, 4, 4) - ''' - major = ufe.VersionInfo.getMajorVersion() - minor = ufe.VersionInfo.getMinorVersion() - patch = ufe.VersionInfo.getPatchLevel() - return (major, minor, patch)