-
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
LOOKDEVX-862- Rename ports #2644
LOOKDEVX-862- Rename ports #2644
Conversation
- delete test code
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.
I will let Jerry review the shading network part of this pull request. It does need an automated test.
lib/mayaUsd/ufe/UsdAttributes.h
Outdated
@@ -62,6 +62,8 @@ class UsdAttributes : public Ufe::Attributes | |||
Ufe::AddAttributeCommand::Ptr | |||
addAttributeCmd(const std::string& name, const Ufe::Attribute::Type& type) override; | |||
Ufe::UndoableCommand::Ptr removeAttributeCmd(const std::string& name) override; | |||
Ufe::UndoableCommand::Ptr |
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.
This will be available in UFE version 0.4.33; it isn't available in 0.4.24.
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.
Yes, I've updated the version.
lib/mayaUsd/ufe/UsdAttributes.cpp
Outdated
const std::string& newName) | ||
{ | ||
if (!sceneItem || !sceneItem->prim().IsActive() | ||
|| !UsdAttributes(sceneItem).hasAttribute(targetName)) { |
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.
Don't understand this line. We can't rename if if don't have an attribute with the targetName?
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.
The name of the variable creates confusion. Maybe something like originalName
would be less ambiguous and a better match to newName
? When I see targetName
I look for sourceName
, which does not fit the logic of this code.
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.
I've renamed the variables everywhere (also in PR for UFE) so now should be more clear.
lib/mayaUsd/ufe/UsdAttributes.cpp
Outdated
} | ||
|
||
// Do not rename if an attribute already exists with the newName | ||
if (UsdAttributes(sceneItem).hasAttribute(newName)) { |
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.
This is the opposite condition of line 469.
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.
I suspect we want to integrate the work you did in #2622 so a new name gets automatically generated on collision. This would most probably require updating the UFE API to return the renamed Ufe::Attribute instead of a boolean. Might not be too late to change that Ufe API.
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.
Yes, right now if we want to create a unique name when there is a collision we need #2622.
lib/mayaUsd/ufe/UsdAttributes.cpp
Outdated
} | ||
|
||
// Do not rename if an attribute already exists with the newName | ||
if (UsdAttributes(sceneItem).hasAttribute(newName)) { |
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.
I suspect we want to integrate the work you did in #2622 so a new name gets automatically generated on collision. This would most probably require updating the UFE API to return the renamed Ufe::Attribute instead of a boolean. Might not be too late to change that Ufe API.
lib/mayaUsd/ufe/UsdAttributes.cpp
Outdated
const std::string& newName) | ||
{ | ||
if (!sceneItem || !sceneItem->prim().IsActive() | ||
|| !UsdAttributes(sceneItem).hasAttribute(targetName)) { |
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.
The name of the variable creates confusion. Maybe something like originalName
would be less ambiguous and a better match to newName
? When I see targetName
I look for sourceName
, which does not fit the logic of this code.
lib/mayaUsd/ufe/UsdAttributes.cpp
Outdated
auto prim = sceneItem->prim(); | ||
auto attribute = prim.GetAttribute(nameAsToken); | ||
|
||
PXR_NS::UsdShadeNodeGraph ngPrim(prim); |
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.
Looks like some of this code could be replaced by a call to canRemoveAttribute(targetName)
since the restrictions are exactly the same between removing and renaming.
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.
Yes exactly, I delete that function
lib/mayaUsd/ufe/UsdAttributes.cpp
Outdated
PXR_NS::TfToken nameAsToken(targetName); | ||
auto prim = sceneItem->prim(); | ||
auto attribute = prim.GetAttribute(nameAsToken); | ||
PXR_NS::UsdShadeNodeGraph ngPrim(prim); |
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.
This unused variable will most probably cause the preflight to fail on Linux and OS/X.
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.
I removed it also in the new version since I don't use it.
if (propertyHandle) { | ||
return propertyHandle->SetName(newName); | ||
} | ||
|
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.
Almost there, but the hardest part goes here. If the attribute was connected, then it must stay connected. This means finding and updating all connection sources that used the old name and changing that to the new name. This is where ngPrim
will come handy as you only have to do that if the attribute is a NodeGraph boundary. You do not have to traverse the whole stage, only the nodes in the enclosing NodeGraph, if any, and the nodes in ngPrim
.
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.
I should also have completed this part.
lib/mayaUsd/ufe/UsdAttributes.cpp
Outdated
@@ -319,6 +319,12 @@ Ufe::UndoableCommand::Ptr UsdAttributes::removeAttributeCmd(const std::string& n | |||
{ | |||
return UsdRemoveAttributeCommand::create(fItem, name); | |||
} | |||
|
|||
Ufe::UndoableCommand::Ptr |
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.
As Pierre mentioned somewhere else, this code is new to UFE 0.4.33; it isn't available in 0.4.24 where add/remove was added. You will have to move this new code into separate block that will be guarded with #if (UFE_PREVIEW_VERSION_NUM >= 4033)
(see line 311).
lib/mayaUsd/ufe/UsdAttributes.cpp
Outdated
Ufe::UndoableCommand::Ptr | ||
UsdAttributes::renameAttributeCmd(const std::string& targetName, const std::string& newName) | ||
#endif | ||
//#if (UFE_PREVIEW_VERSION_NUM >= 4033) |
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.
Commented-out code.
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.
yes I forgot to remove the comment.
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.
The #if
condition is needed.
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.
@JGamache-autodesk The code is not consistent in this file. Does it need the two conditions UFE_V4_FEATURES_AVAILABLE
and UFE_PREVIEW_VERSION_NUM >= 4033
-- or -- only the latter?
@@ -96,14 +96,14 @@ class UsdRemoveAttributeCommand : public UsdUndoableCommand<Ufe::UndoableCommand | |||
}; // UsdRemoveAttributeCommand | |||
|
|||
//! \brief Implementation of RenameAttributeCommand | |||
class UsdRenameAttributeCommand : public UsdUndoableCommand<Ufe::UndoableCommand> | |||
class UsdRenameAttributeCommand : public UsdUndoableCommand<Ufe::AttributeValuedUndoableCommand> |
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 AttributeValuedUndoableCommand in a checked-in version of UFE? I can't find it in UFE master.
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.
Yes, it is here: https://git.autodesk.com/media-and-entertainment/ufe/pull/308
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.
Update, following this discussion for UFE, I've updated the names.
I also added and tested the new test. |
@alicedegirolamo did you address all the reviewer's comments? if done, please ping reviewers to finalize & merge the pull request. |
Yes, I did. @ppt-adsk @JGamache-autodesk could you please check if my corrections are ok? Thank you. |
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.
There are points:
- The code is not consistent in the changed files and with the current changes. Does it need the two conditions UFE_V4_FEATURES_AVAILABLE and UFE_PREVIEW_VERSION_NUM >= 4033 -- or -- only the latter?
- Being in
maya-usd
the pull request must have at least one unit test to demonstrate that theusd
implementaion is working.
lib/mayaUsd/ufe/UsdAttributes.cpp
Outdated
Ufe::UndoableCommand::Ptr | ||
UsdAttributes::renameAttributeCmd(const std::string& targetName, const std::string& newName) | ||
#endif | ||
//#if (UFE_PREVIEW_VERSION_NUM >= 4033) |
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.
The #if
condition is needed.
lib/mayaUsd/ufe/UsdAttributes.cpp
Outdated
Ufe::UndoableCommand::Ptr | ||
UsdAttributes::renameAttributeCmd(const std::string& targetName, const std::string& newName) | ||
#endif | ||
//#if (UFE_PREVIEW_VERSION_NUM >= 4033) |
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.
@JGamache-autodesk The code is not consistent in this file. Does it need the two conditions UFE_V4_FEATURES_AVAILABLE
and UFE_PREVIEW_VERSION_NUM >= 4033
-- or -- only the latter?
Hi @ppt-adsk , yes, sure. Thanks! |
# Conflicts: # lib/mayaUsd/ufe/UsdUndoAttributesCommands.cpp
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.
New code looks good, but is untested. Fastest way is to import test scene test\testSamples\MaterialX\MayaSurfaces.usda
, and rename /pCube2/Looks/standardSurface2SG/MayaNG_standardSurface2SG.inputs:file2:varnameStr
to inputs:file2:varname
and make sure the connection from /pCube2/Looks/standardSurface2SG/MayaNG_standardSurface2SG/place2dTexture2.inputs:geomprop
is fixed. Then you rename /pCube2/Looks/standardSurface2SG/MayaNG_standardSurface2SG.outputs:baseColor
to outputs:MyColor
and make sure the input connection from /pCube2/Looks/standardSurface2SG/standardSurface2.inputs:base_color
stays connected.
I've updated the test and checked it's passing for the renaming in |
Description
Added the command for renaming an attribute.
I modified UFE in this PR in order to add the new command to the interface.
Type of change
Checklist: