Skip to content

Commit

Permalink
HYDRA-1098 : Minor refactor from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
debloip-adsk committed Oct 21, 2024
1 parent acbaefc commit b06bc6d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
21 changes: 13 additions & 8 deletions lib/flowViewport/sceneIndex/fvpPruningSceneIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,20 @@ SdfPathVector PruningSceneIndex::GetChildPrimPaths(const SdfPath& primPath) cons
return editedChildPaths;
}

bool PruningSceneIndex::EnableFilter(const TfToken& pruningToken)
void PruningSceneIndex::SetFilterStatus(const TfToken& pruningToken, bool enabled)
{
if (enabled) {
_EnableFilter(pruningToken);
} else {
_DisableFilter(pruningToken);
}
}

void PruningSceneIndex::_EnableFilter(const TfToken& pruningToken)
{
if (_prunedPathsByFilter.find(pruningToken) != _prunedPathsByFilter.end()) {
// Filter already enabled, no change needed.
return false;
return;
}

// Enable the filter
Expand All @@ -185,15 +194,13 @@ bool PruningSceneIndex::EnableFilter(const TfToken& pruningToken)
if (!prunedPrims.empty()) {
_SendPrimsRemoved(prunedPrims);
}

return true;
}

bool PruningSceneIndex::DisableFilter(const TfToken& pruningToken)
void PruningSceneIndex::_DisableFilter(const TfToken& pruningToken)
{
if (_prunedPathsByFilter.find(pruningToken) == _prunedPathsByFilter.end()) {
// Filter already disabled, no change needed.
return false;
return;
}

HdSceneIndexObserver::AddedPrimEntries unprunedPrims;
Expand All @@ -214,8 +221,6 @@ bool PruningSceneIndex::DisableFilter(const TfToken& pruningToken)
if (!unprunedPrims.empty()) {
_SendPrimsAdded(unprunedPrims);
}

return true;
}

std::set<TfToken> PruningSceneIndex::GetActiveFilters()
Expand Down
14 changes: 8 additions & 6 deletions lib/flowViewport/sceneIndex/fvpPruningSceneIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,9 @@ class PruningSceneIndex :
FVP_API
void AddExcludedSceneRoot(const PXR_NS::SdfPath& sceneRoot);

// Enable a filter and prune out its matching prims
// Enable or disable a filter and send corresponding prim notifications
FVP_API
bool EnableFilter(const PXR_NS::TfToken& pruningToken);

// Disable a filter and re-add its filtered prims
FVP_API
bool DisableFilter(const PXR_NS::TfToken& pruningToken);
void SetFilterStatus(const PXR_NS::TfToken& pruningToken, bool enabled);

// Returns the tokens corresponding to the currently enabled filters.
FVP_API
Expand Down Expand Up @@ -113,6 +109,12 @@ class PruningSceneIndex :
void _PrimsDirtied(
const PXR_NS::HdSceneIndexBase &sender,
const PXR_NS::HdSceneIndexObserver::DirtiedPrimEntries &entries) override;

FVP_API
void _EnableFilter(const PXR_NS::TfToken& pruningToken);

FVP_API
void _DisableFilter(const PXR_NS::TfToken& pruningToken);

FVP_API
void _InsertEntry(const PXR_NS::SdfPath& primPath, const PXR_NS::TfToken& pruningToken);
Expand Down
6 changes: 1 addition & 5 deletions lib/mayaHydra/mayaPlugin/renderOverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,11 +824,7 @@ MStatus MtohRenderOverride::Render(

for (auto [mayaFilter, fvpPruningTokens] : mayaFiltersToFvpPruningTokens) {
for (const auto& fvpPruningToken : fvpPruningTokens) {
if (objectExclusions & mayaFilter) {
_pruningSceneIndex->EnableFilter(fvpPruningToken);
} else {
_pruningSceneIndex->DisableFilter(fvpPruningToken);
}
_pruningSceneIndex->SetFilterStatus(fvpPruningToken, objectExclusions & mayaFilter);
}
}
}
Expand Down

0 comments on commit b06bc6d

Please sign in to comment.