-
Notifications
You must be signed in to change notification settings - Fork 221
Fix layer editor path display and optimize rebuild model #4174
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,10 @@ void MayaCommandHook::insertSubLayerPath(UsdLayer usdLayer, Path path, int index | |
| cmd = "mayaUsdLayerEditor -edit -insertSubPath "; | ||
| cmd += std::to_string(index); | ||
| cmd += quote(path); | ||
| cmd += quote(usdLayer->GetIdentifier()); | ||
| // Here we choose the identifier only if the layer is anonymous | ||
| std::string layerPath{usdLayer->IsAnonymous() ? usdLayer->GetIdentifier() : | ||
| usdLayer->GetRealPath()}; | ||
| cmd += quote(layerPath); | ||
|
Collaborator
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. For cases like this where the same pattern is ued multiple times, it is better to put it in a function to avoid the repetition. Maybe a function named getLayerPathForEditorCommand()
Author
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. Yes I agree a function would be better. |
||
| executeMel(cmd); | ||
| } | ||
|
|
||
|
|
@@ -127,7 +130,10 @@ void MayaCommandHook::removeSubLayerPath(UsdLayer usdLayer, Path path) | |
| cmd = "mayaUsdLayerEditor -edit -removeSubPath "; | ||
| cmd += std::to_string(index); | ||
| cmd += quote(proxyShapePath()); | ||
| cmd += quote(usdLayer->GetIdentifier()); | ||
| // Here we choose the identifier only if the layer is anonymous | ||
| std::string layerPath{usdLayer->IsAnonymous() ? usdLayer->GetIdentifier() : | ||
| usdLayer->GetRealPath()}; | ||
| cmd += quote(layerPath); | ||
| executeMel(cmd); | ||
| } | ||
|
|
||
|
|
@@ -140,9 +146,15 @@ void MayaCommandHook::moveSubLayerPath( | |
| std::string cmd; | ||
| cmd = "mayaUsdLayerEditor -edit -moveSubPath "; | ||
| cmd += quote(path); | ||
| cmd += quote(newParentUsdLayer->GetIdentifier()); | ||
| // Here we choose the identifier only if the layer is anonymous | ||
| std::string newParentUsdLayerPath{newParentUsdLayer->IsAnonymous() ? newParentUsdLayer->GetIdentifier() : | ||
| newParentUsdLayer->GetRealPath()}; | ||
| cmd += quote(newParentUsdLayerPath); | ||
| cmd += std::to_string(index); | ||
| cmd += quote(oldParentUsdLayer->GetIdentifier()); | ||
| // Here we choose the identifier only if the layer is anonymous | ||
| std::string oldParentUsdLayerPath{oldParentUsdLayer->IsAnonymous() ? oldParentUsdLayer->GetIdentifier() : | ||
| oldParentUsdLayer->GetRealPath()}; | ||
| cmd += quote(oldParentUsdLayerPath); | ||
| executeMel(cmd); | ||
| } | ||
|
|
||
|
|
@@ -153,7 +165,10 @@ void MayaCommandHook::replaceSubLayerPath(UsdLayer usdLayer, Path oldPath, Path | |
| cmd = "mayaUsdLayerEditor -edit -replaceSubPath "; | ||
| cmd += quote(oldPath); | ||
| cmd += quote(newPath); | ||
| cmd += quote(usdLayer->GetIdentifier()); | ||
| // Here we choose the identifier only if the layer is anonymous | ||
| std::string layerPath{usdLayer->IsAnonymous() ? usdLayer->GetIdentifier() : | ||
| usdLayer->GetRealPath()}; | ||
| cmd += quote(layerPath); | ||
| executeMel(cmd); | ||
| } | ||
|
|
||
|
|
@@ -162,7 +177,10 @@ void MayaCommandHook::discardEdits(UsdLayer usdLayer) | |
| { | ||
| std::string cmd; | ||
| cmd = "mayaUsdLayerEditor -edit -discardEdits "; | ||
| cmd += quote(usdLayer->GetIdentifier()); | ||
| // Here we choose the identifier only if the layer is anonymous | ||
| std::string layerPath{usdLayer->IsAnonymous() ? usdLayer->GetIdentifier() : | ||
| usdLayer->GetRealPath()}; | ||
| cmd += quote(layerPath); | ||
| executeMel(cmd); | ||
|
|
||
| refreshLayerSystemLock(usdLayer); | ||
|
|
@@ -173,7 +191,10 @@ void MayaCommandHook::clearLayer(UsdLayer usdLayer) | |
| { | ||
| std::string cmd; | ||
| cmd = "mayaUsdLayerEditor -edit -clear "; | ||
| cmd += quote(usdLayer->GetIdentifier()); | ||
| // Here we choose the identifier only if the layer is anonymous | ||
| std::string layerPath{usdLayer->IsAnonymous() ? usdLayer->GetIdentifier() : | ||
| usdLayer->GetRealPath()}; | ||
| cmd += quote(layerPath); | ||
| executeMel(cmd); | ||
| } | ||
|
|
||
|
|
@@ -183,8 +204,12 @@ UsdLayer MayaCommandHook::addAnonymousSubLayer(UsdLayer usdLayer, std::string ne | |
| std::string cmd; | ||
| cmd = "mayaUsdLayerEditor -edit -addAnonymous "; | ||
| cmd += quote(newName); | ||
| cmd += quote(usdLayer->GetIdentifier()); | ||
| // Here we choose the identifier only if the layer is anonymous | ||
| std::string layerPath{usdLayer->IsAnonymous() ? usdLayer->GetIdentifier() : | ||
| usdLayer->GetRealPath()}; | ||
| cmd += quote(layerPath); | ||
| std::string result = executeMel(cmd); | ||
|
|
||
| if (result.size() > 0) | ||
| return PXR_NS::SdfLayer::FindOrOpen(result); | ||
| else | ||
|
|
@@ -198,7 +223,10 @@ void MayaCommandHook::muteSubLayer(UsdLayer usdLayer, bool muteIt) | |
| cmd = "mayaUsdLayerEditor -edit -muteLayer "; | ||
| cmd += muteIt ? "1" : "0"; | ||
| cmd += quote(proxyShapePath()); | ||
| cmd += quote(usdLayer->GetIdentifier()); | ||
| // Here we choose the identifier only if the layer is anonymous | ||
| std::string layerPath{usdLayer->IsAnonymous() ? usdLayer->GetIdentifier() : | ||
| usdLayer->GetRealPath()}; | ||
| cmd += quote(layerPath); | ||
| executeMel(cmd); | ||
| } | ||
|
|
||
|
|
@@ -218,7 +246,10 @@ void MayaCommandHook::lockLayer( | |
| cmd += std::to_string(lockState); | ||
| cmd += includeSubLayers ? " 1" : " 0"; | ||
| cmd += quote(proxyShapePath()); | ||
| cmd += quote(usdLayer->GetIdentifier()); | ||
| // Here we choose the identifier only if the layer is anonymous | ||
| std::string layerPath{usdLayer->IsAnonymous() ? usdLayer->GetIdentifier() : | ||
| usdLayer->GetRealPath()}; | ||
| cmd += quote(layerPath); | ||
| executeMel(cmd); | ||
| } | ||
|
|
||
|
|
@@ -229,7 +260,10 @@ void MayaCommandHook::refreshLayerSystemLock(UsdLayer usdLayer, bool refreshSubL | |
| cmd += quote(proxyShapePath()); | ||
| cmd += " "; | ||
| cmd += std::to_string(refreshSubLayers); | ||
| cmd += quote(usdLayer->GetIdentifier()); | ||
| // Here we choose the identifier only if the layer is anonymous | ||
| std::string layerPath{usdLayer->IsAnonymous() ? usdLayer->GetIdentifier() : | ||
| usdLayer->GetRealPath()}; | ||
| cmd += quote(layerPath); | ||
| executeMel(cmd); | ||
| } | ||
|
|
||
|
|
||
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.
Is this change required? Like the comments said, clear() would cause multiple notifications of changes to be sent and cause flickers. Any reason why changing it to call clear?