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

Restrict namespace edits to current stage #2977

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions lib/mayaUsd/nodes/proxyShapeUpdateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <pxr/usd/usd/tokens.h>
#include <pxr/usd/usdUI/tokens.h>

#include <mutex>
Copy link
Collaborator

Choose a reason for hiding this comment

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

No sure why this file got modified, was this to fix a build issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I couldn't build locally without that change. It's PR'd here:
#2975


using namespace MAYAUSD_NS_DEF;

PXR_NAMESPACE_OPEN_SCOPE
Expand Down
25 changes: 21 additions & 4 deletions lib/mayaUsd/utils/layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,33 @@ void enforceMutedLayer(const PXR_NS::UsdPrim& prim, const char* command)
}
}

static SdfPrimSpecHandleVector _GetLocalPrimStack(const UsdPrim& prim)
Copy link
Collaborator

Choose a reason for hiding this comment

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

ON second thought, maybe adding a comments on what this code is trying to avoid, like the description you gave in teh bug would be helpful for future coders.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I too the liberty of adding the comment myself to your branch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you!!

{
SdfPrimSpecHandleVector primSpecs;

UsdStagePtr stage = prim.GetStage();
if (!stage)
return primSpecs;

for (const SdfLayerHandle& layer : stage->GetLayerStack()) {
const SdfPrimSpecHandle primSpec = layer->GetPrimAtPath(prim.GetPath());
if (primSpec)
primSpecs.push_back(primSpec);
}

return primSpecs;
}

void applyToAllPrimSpecs(const UsdPrim& prim, const PrimSpecFunc& func)
{
const SdfPrimSpecHandleVector primStack = prim.GetPrimStack();
const SdfPrimSpecHandleVector primStack = _GetLocalPrimStack(prim);
for (const SdfPrimSpecHandle& spec : primStack)
func(prim, spec);
}

void applyToAllLayersWithOpinions(const UsdPrim& prim, PrimLayerFunc& func)
{
const SdfPrimSpecHandleVector primStack = prim.GetPrimStack();
const SdfPrimSpecHandleVector primStack = _GetLocalPrimStack(prim);
for (const SdfPrimSpecHandle& spec : primStack) {
const auto layer = spec->GetLayer();
func(prim, layer);
Expand All @@ -137,7 +154,7 @@ void applyToSomeLayersWithOpinions(
const std::set<SdfLayerRefPtr>& layers,
PrimLayerFunc& func)
{
const SdfPrimSpecHandleVector primStack = prim.GetPrimStack();
const SdfPrimSpecHandleVector primStack = _GetLocalPrimStack(prim);
for (const SdfPrimSpecHandle& spec : primStack) {
const auto layer = spec->GetLayer();
if (layers.count(layer) == 0)
Expand Down Expand Up @@ -215,4 +232,4 @@ SdfLayerHandle getStrongerLayer(
return getStrongerLayer(stage->GetRootLayer(), layer1, layer2);
}

} // namespace MAYAUSD_NS_DEF
} // namespace MAYAUSD_NS_DEF