-
Notifications
You must be signed in to change notification settings - Fork 203
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
Assign new material to multiple objects #2641
Assign new material to multiple objects #2641
Conversation
@stefanminning-autodesk Before we start the code review and preflight process can you please clean this up by squashing the 11 commits? |
cadd76e
to
8dd50e8
Compare
Sure, I've pushed with squashed history. |
@womanyoyoyo-adsk Natalia can you please have a look at this from a design perspective? |
Right, I've coded it to match the current behaviour, where a new material would be assigned to an object when the right-click operation is applied upon it, regardless of its selection state. Additional selected objects will then also receive the new material. But what you're describing also seems like a perfectly valid option. I'll leave it to the UX team to decide what the best workflow is. I've asked in our team for clarification. Should be an easy change, either way. |
@stefanminning-autodesk Actually sorry I don't think that is correct. With your changes it applies the material to all the selected objects. If the object you right click on is not selected, then the material is not applied to it. The normal context menu behavior would be "if the context object is selected?" then apply to selection, otherwise apply only to context object. |
Ah yes, you're right: Looking at the code again, it should not be ignoring Anyway, guess I'll have to have another look at this when the designers are back from holidays and they've clarified the exact behaviour they'd like to see. |
Hi, myself and Lookdevx designer are looking into this. Keep you posted. |
a90833f
to
66dd552
Compare
As discussed with the UX team, the new material will be assigned to all of the following:
The designers would also like to see additional UI feedback for the right-clicked item, but that will come as part of another task. |
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.
LGTM
@@ -105,6 +111,11 @@ class MAYAUSD_CORE_PUBLIC UsdUndoAssignNewMaterialCommand : public Ufe::InsertCh | |||
//! sdrShaderIdentifier and assigns it to \p parentItem | |||
static UsdUndoAssignNewMaterialCommand::Ptr | |||
create(const UsdSceneItem::Ptr& parentItem, const std::string& sdrShaderIdentifier); | |||
//! Create a UsdUndoAssignNewMaterialCommand that creates a new material based on \p |
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.
Not clear about Doxygen but I would have move \p
close to the parameter name sdrShaderIdentifier
_stagesAndPaths[stage].push_back(parentPath); | ||
} | ||
|
||
UsdUndoAssignNewMaterialCommand::UsdUndoAssignNewMaterialCommand( |
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.
Does that code need UFE_PREVIEW_XX
defines protection?
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.
Good question, honestly not sure.
These changes are entirely contained in MayaUSD, with no UFE update required. What UFE version would I be looking for?
//! sdrShaderIdentifier and assigns it to multiple \p parentItems | ||
static UsdUndoAssignNewMaterialCommand::Ptr | ||
create(const std::vector<const UsdSceneItem::Ptr>& parentItems, | ||
const std::string& sdrShaderIdentifier); |
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.
Should the new method be protected by UFE_PREVIEW_XX
defines?
@@ -93,6 +96,9 @@ class MAYAUSD_CORE_PUBLIC UsdUndoAssignNewMaterialCommand : public Ufe::InsertCh | |||
UsdUndoAssignNewMaterialCommand( | |||
const UsdSceneItem::Ptr& parentItem, | |||
const std::string& sdrShaderIdentifier); | |||
UsdUndoAssignNewMaterialCommand( | |||
const std::vector<const UsdSceneItem::Ptr>& parentItems, | |||
const std::string& sdrShaderIdentifier); |
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.
Should the new method be protected by UFE_PREVIEW_XX defines?
@@ -116,8 +126,8 @@ class MAYAUSD_CORE_PUBLIC UsdUndoAssignNewMaterialCommand : public Ufe::InsertCh | |||
void connectShaderToMaterial(Ufe::SceneItem::Ptr shaderItem, PXR_NS::UsdPrim materialPrim); | |||
void markAsFailed(); | |||
|
|||
const Ufe::Path _parentPath; | |||
const std::string _nodeId; | |||
std::map<pxr::UsdStageWeakPtr, std::vector<const Ufe::Path>> _stagesAndPaths; |
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.
Sorry I didn't catch this earlier. We shouldn't use the namespace name directly, but instead the define. So "pxr::" should be "PXR_NS::" (see line 126).
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.
Once this and the merge conflict is fixed, you can run another preflight and if it passes add the label "ready for merge" and I'll merge it. I confirmed with our designer that the multiple selection workflow is okay.
Please ignore for now, I botched the merge apparently. |
3619924
to
656a49c
Compare
Alright, merge issue should be fixed. |
@stefanminning-autodesk There are clang-format errors that need to be fixed. Please see codingGuidelines for info on clang-format. |
@seando-adsk Sorry about that. I've now let clang-format do its thing and it fixed two issues. Fingers crossed! |
b7124b4
to
1b03a5d
Compare
@seando-adsk @hodoulp I have added a unit test to test the multiple material assignment test case. Please have a look. |
test/lib/ufe/testContextOps.py
Outdated
os.putenv("MAYAUSD_MATERIALS_SCOPE_NAME", "test_scope") | ||
ufeCmd.execute(cmdSS) | ||
checkMaterial(self, rootHier, 5, 1, 1, 0, "standard_surface", "mtlx", "out", "/test_scope") | ||
|
||
# Clear the envvar, otherwise we're affecting the results of following tests. | ||
os.putenv("MAYAUSD_MATERIALS_SCOPE_NAME", "") |
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 think we should have a way to make sure this is automatically restored using a context manager object. Look at TemporaryDirectory
. You can create one that will restore an env var. The input would be the env var and the new value. The init will get the current value, store it and set the env var to input and the exit will restore to stored value. Then you can wrap this section of code in a with ...
statement.
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.
Good idea, will do.
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.
Thanks for the test. If you could just create a new context object and use it the two places that env var is set/restored that would be great. The new context object can be in testUtils.py
…s less error prone
test/testUtils/testUtils.py
Outdated
Context manager that creates a temporary environment variable and deletes it on exit, | ||
so it's usable with "with" statement. |
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.
Rather than deleting it upon exit, you should save the current env var value (if any) in the init and restore it in the exit (if one was saved).
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.
Alright, I've changed it to restore the original value.
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.
Everything looks good now. Thanks.
@stefanminning-autodesk FYI, any new commit (such as your latest one merging in dev) will invalidate the preflight check and it must be run again. So I've removed the ready for merge label and re-started the preflight for you. When it passes, you may add back the label and I'll merge. |
Thanks @seando-adsk. The preflight succeeded, but then it was complaining about a tiny merge issues which I resolved right here in Github. I've kicked off another preflight just to be sure. |
This PR adds functionality to the existing
UsdUndoAssignNewMaterialCommand
, allowing for a new material to be assigned to multiple objects.The command's original functionality remains untouched, as I wanted to avoid breaking API changes.