-
Notifications
You must be signed in to change notification settings - Fork 202
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-105175: Rewrote the rename restriction algorithm from scratch to cover more edge cases. #786
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6c2a798
MAYA-105175: Rewrote the rename restriction algorithm from scratch to…
e50457c
Remove redundant check to distinguish if the "over" specifier is in t…
a9226cd
Fix testParentCmd test. If parent prim is the pseudo-root, no def pri…
52d7585
MAYA-105175: Simplify the logic to avoid code redundancy.
92f1c04
Minor clean up:
8038469
MAYA-105175: minor fix in the logic: Break out of loop if the spec al…
5adec49
Covering more edge cases.
eac389a
Simplify the algorithm further.
2472eec
MAYA-105175: published the algorithm and added proper messaging.
b10a2b4
MAYA-105175: clean up some comments.
9985175
MAYA-105175: clean up the logic around pseudo-root.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ | |
|
||
#include <mayaUsdUtils/util.h> | ||
|
||
#include <iostream> | ||
|
||
PXR_NAMESPACE_USING_DIRECTIVE | ||
|
||
MAYAUSD_NS_DEF { | ||
|
@@ -132,43 +134,46 @@ void applyCommandRestriction(const UsdPrim& prim, const std::string& commandName | |
auto primSpec = MayaUsdUtils::getPrimSpecAtEditTarget(prim); | ||
auto primStack = prim.GetPrimStack(); | ||
std::string layerDisplayName; | ||
std::string message{"It is defined on another layer"}; | ||
|
||
// iterate over the prim stack, starting at the highest-priority layer. | ||
for (const auto& spec : primStack) | ||
{ | ||
const auto& layerName = spec->GetLayer()->GetDisplayName(); | ||
|
||
if (primSpec != spec) { | ||
layerDisplayName.append("[" + layerName + "]" + ","); | ||
// skip if there is no primSpec for the selected prim in the current stage's local layer. | ||
if(!primSpec){ | ||
// add "," separator for multiple layers | ||
if(!layerDisplayName.empty()) { layerDisplayName.append(","); } | ||
layerDisplayName.append("[" + layerName + "]"); | ||
continue; | ||
} | ||
else { | ||
// if exist a primSpec with reference | ||
if(spec->HasReferences()) { | ||
break; | ||
} | ||
|
||
// if exists a def sepc | ||
if (spec->GetSpecifier() == SdfSpecifierDef) { | ||
// if exists a def spec is in another layer other than current stage's local layer. | ||
if(primSpec->GetLayer() != spec->GetLayer()) { | ||
layerDisplayName.append("[" + layerName + "]" + ","); | ||
break; | ||
} | ||
continue; | ||
} | ||
// one reason for skipping the reference is to not clash | ||
// with the over that may be created in the stage's sessioLayer. | ||
// another reason is that one should be able to edit a referenced prim that | ||
// is tagged over/def as long as it has a primSpec in the selected edit target layer. | ||
if(spec->HasReferences()) { | ||
break; | ||
} | ||
|
||
// if exists an over sepc | ||
if (spec->GetSpecifier() == SdfSpecifierOver) { | ||
layerDisplayName.append("[" + layerName + "]" + ","); | ||
// if exists a def/over specs | ||
if (spec->GetSpecifier() == SdfSpecifierDef || spec->GetSpecifier() == SdfSpecifierOver) { | ||
// if exists in another layer other than current stage's local layer. | ||
if(primSpec->GetLayer() != spec->GetLayer()) { | ||
layerDisplayName.append("[" + layerName + "]"); | ||
message = "It has a stronger opinion on another layer"; | ||
break; | ||
} | ||
continue; | ||
} | ||
} | ||
|
||
if(!layerDisplayName.empty()) { | ||
layerDisplayName.pop_back(); | ||
std::string err = TfStringPrintf("Cannot %s [%s]. It is defined on another layer. Please set %s as the target layer to proceed.", | ||
std::string err = TfStringPrintf("Cannot %s [%s]. %s. Please set %s as the target layer to proceed.", | ||
commandName.c_str(), | ||
prim.GetName().GetString().c_str(), | ||
prim.GetName().GetString().c_str(), | ||
message.c_str(), | ||
layerDisplayName.c_str()); | ||
throw std::runtime_error(err.c_str()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
please see 2472eec . Also ignore my typo in the commit message: I meant "polished" not "published". Sigh.............. |
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just noticed I left out to clean up this iostream. Will have it remove in another PR.