From 112ae53a80ca5d3ef20af79fecfc779d41c9ec5a Mon Sep 17 00:00:00 2001 From: Pierre Tremblay Date: Thu, 28 Nov 2024 09:34:46 -0500 Subject: [PATCH] Addressed code review feedback. --- .../selection/fvpPathMapperRegistry.cpp | 3 +++ .../sceneIndex/mayaHydraSceneIndex.cpp | 9 --------- .../mayaToHydra/cpp/testPathMapperRegistry.cpp | 13 +++++++------ .../mayaUsd/render/mayaToHydra/cpp/testUtils.cpp | 2 +- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/flowViewport/selection/fvpPathMapperRegistry.cpp b/lib/flowViewport/selection/fvpPathMapperRegistry.cpp index e04e5981d..fac3600b6 100644 --- a/lib/flowViewport/selection/fvpPathMapperRegistry.cpp +++ b/lib/flowViewport/selection/fvpPathMapperRegistry.cpp @@ -159,6 +159,9 @@ PrimSelections PathMapperRegistry::UfePathToPrimSelections( bool PathMapperRegistry::HasMapper(const Ufe::Path& path) const { + if (path.empty()) { + return false; + } return _GetMapper(path) != nullptr; } diff --git a/lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndex.cpp b/lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndex.cpp index 5f639c873..ae7b59d86 100644 --- a/lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndex.cpp +++ b/lib/mayaHydra/hydraExtensions/sceneIndex/mayaHydraSceneIndex.cpp @@ -62,8 +62,6 @@ #include #include -#include - namespace { // Pick handler for the Maya scene index. As the Maya pick handler and the @@ -477,8 +475,6 @@ class MayaPathMapper : public Fvp::PathMapper Fvp::PrimSelections UfePathToPrimSelections(const Ufe::Path& appPath) const override { - std::cout << "PPT: in MayaPathMapper::UfePathToPrimSelections(" - << Ufe::PathString::string(appPath) << ")" << std::endl; auto litPaths = _piSi.UfePathToPrimSelectionsLit(appPath); auto unlitPaths = _piSi.UfePathToPrimSelections(appPath); unlitPaths.insert(unlitPaths.end(), litPaths.begin(), litPaths.end()); @@ -806,14 +802,9 @@ Fvp::PrimSelections MayaHydraSceneIndex::UfePathToPrimSelections(const Ufe::Path TF_DEBUG(MAYAHYDRALIB_SCENE_INDEX) .Msg("MayaHydraSceneIndex::UfePathToPrimSelections(const Ufe::Path& %s) called.\n", Ufe::PathString::string(appPath).c_str()); - std::cout << "PPT: in MayaHydraSceneIndex::UfePathToPrimSelections(" - << Ufe::PathString::string(appPath) << ")" << std::endl; - // We only handle Maya objects, so if the UFE path is not a Maya object, // early out with failure. if (appPath.runTimeId() != UfeExtensions::getMayaRunTimeId()) { - std::cout << "PPT: early out, not a Maya run-time UFE path." - << std::endl; return {}; } diff --git a/test/lib/mayaUsd/render/mayaToHydra/cpp/testPathMapperRegistry.cpp b/test/lib/mayaUsd/render/mayaToHydra/cpp/testPathMapperRegistry.cpp index a9fefaa10..8907500bc 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/cpp/testPathMapperRegistry.cpp +++ b/test/lib/mayaUsd/render/mayaToHydra/cpp/testPathMapperRegistry.cpp @@ -48,10 +48,6 @@ TEST(TestPathMapperRegistry, testRegistry) // Exercise the path mapper registry. auto& r = Fvp::PathMapperRegistry::Instance(); - // For the duration of this test set a null fallback mapper. - auto fbm = r.GetFallbackMapper(); - r.SetFallbackMapper(nullptr); - auto dummy = TestPathMapper::create(); // Can't register for an empty path. @@ -106,10 +102,15 @@ TEST(TestPathMapperRegistry, testRegistry) ASSERT_TRUE(r.HasMapper(Ufe::PathString::path("|apple|pear"))); ASSERT_TRUE(r.HasMapper(Ufe::PathString::path("|wizard|sorcerer"))); + // Update the path for an entry. + auto potatoP = Ufe::PathString::path("|potato"); + ASSERT_TRUE(r.Update(appleP, potatoP)); + ASSERT_FALSE(r.HasMapper(Ufe::PathString::path("|apple|pear"))); + ASSERT_TRUE(r.HasMapper(Ufe::PathString::path("|potato|baked"))); + ASSERT_TRUE(r.Update(potatoP, appleP)); + // Clean up. for (const auto& h : registered) { ASSERT_TRUE(r.Unregister(h)); } - r.SetFallbackMapper(fbm); - ASSERT_EQ(r.GetFallbackMapper(), fbm); } diff --git a/test/lib/mayaUsd/render/mayaToHydra/cpp/testUtils.cpp b/test/lib/mayaUsd/render/mayaToHydra/cpp/testUtils.cpp index 39088398e..fe91ff7a0 100644 --- a/test/lib/mayaUsd/render/mayaToHydra/cpp/testUtils.cpp +++ b/test/lib/mayaUsd/render/mayaToHydra/cpp/testUtils.cpp @@ -530,7 +530,7 @@ bool visibility(const HdSceneIndexBasePtr& sceneIndex, const SdfPath& primPath) bool contains(const PXR_NS::SdfPathVector& paths, const PXR_NS::SdfPath& path) { - return std::count(paths.begin(), paths.end(), path) > 0; + return std::find(paths.begin(), paths.end(), path) != paths.end(); } } // namespace MAYAHYDRA_NS_DEF