-
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
Making visibility Undo/Redo correct. #1056
Conversation
lib/mayaUsd/ufe/UsdContextOps.cpp
Outdated
auto object3d = UsdObject3d::create(fItem); | ||
auto current = object3d->visibility(); | ||
auto cmd = object3d->setVisibleCmd(!current); | ||
cmd->execute(); |
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.
Make sure setting the visibility goes through the new "setVisibleCmd"
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 need to call execute(), that's done for you by Maya. Just
return object3d->setVisibleCmd(!current);
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.
Also you need to guard this with the UFE_PREVIEW_VERSION_NUM awful pre-processor macro, and keep the old code around... :(
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.
Addressed in 7004631
#if UFE_PREVIEW_VERSION_NUM >= 2034 | ||
Ufe::UndoableCommand::Ptr setVisibleCmd(bool vis) override; | ||
#endif | ||
|
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.
Added guard around "setVisibleCmd" since this feature is available in UFE V.2034 or later.
void UsdUndoVisibleCommand::redo() { _undoableItem.redo(); } | ||
|
||
void UsdUndoVisibleCommand::undo() { _undoableItem.undo(); } | ||
|
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.
On execute(), we create an undoBlock to capture the edit and then visibility is set via UsdGeomImageable MakeVisible()/MakeInvisible() methods.
As a FYI, working on the unit-test part for this PR. Should be coming up today. |
lib/mayaUsd/ufe/UsdContextOps.cpp
Outdated
auto object3d = UsdObject3d::create(fItem); | ||
auto current = object3d->visibility(); | ||
auto cmd = object3d->setVisibleCmd(!current); | ||
cmd->execute(); |
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.
Doesn't this new code need to be protected by UFE_PREVIEW_VERSION_NUM >= 2034 and leave the old code for the else?
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.
Ugh.... Good catch! Indeed. :)
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.
Addressed in 7004631
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.
A couple of things to fix, but really what I feel is missing from this PR are the automated tests. You can write an automated test that first tests the UsdUndoVisibleCommand, and calls undo and redo on that object, for the lowest-level test.
Then, I'd like to see tests with the Maya hide and showHidden commands, with calls to Maya undo and redo, to demonstrate the full integration of the UFE command into Maya.
Thanks for doing this!
current == UsdGeomTokens->invisible ? UsdGeomTokens->inherited | ||
: UsdGeomTokens->invisible); | ||
auto object3d = UsdObject3d::create(fItem); | ||
auto current = object3d->visibility(); |
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.
Shouldn't we check that the scene item supports the Object3d interface? At this point it should, because we put up the menu entry for it, so perhaps we can just assert.
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.
A couple of things to fix, but really what I feel is missing from this PR are the automated tests. You can write an automated test that first tests the UsdUndoVisibleCommand, and calls undo and redo on that object, for the lowest-level test.
Great point. I am working on it as we speak.
Addressed in 7004631
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.
Added a test for backing the new UsdUndoVisibleCommand :
Added a new test for backing up the UFE command integration on Maya side for both "hide" and "showHidden" commands :
lib/mayaUsd/ufe/UsdContextOps.cpp
Outdated
auto object3d = UsdObject3d::create(fItem); | ||
auto current = object3d->visibility(); | ||
auto cmd = object3d->setVisibleCmd(!current); | ||
cmd->execute(); |
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 need to call execute(), that's done for you by Maya. Just
return object3d->setVisibleCmd(!current);
lib/mayaUsd/ufe/UsdContextOps.cpp
Outdated
auto object3d = UsdObject3d::create(fItem); | ||
auto current = object3d->visibility(); | ||
auto cmd = object3d->setVisibleCmd(!current); | ||
cmd->execute(); |
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.
Also you need to guard this with the UFE_PREVIEW_VERSION_NUM awful pre-processor macro, and keep the old code around... :(
|
||
#include <pxr/usd/usdGeom/tokens.h> | ||
|
||
#include <ufe/log.h> |
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.
Unused.
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.
Addressed in 7004631
#include <mayaUsd/undo/UsdUndoBlock.h> | ||
#include <mayaUsdUtils/util.h> | ||
|
||
#include <pxr/usd/usdGeom/tokens.h> |
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.
Unused.
#include "private/Utils.h" | ||
|
||
#include <mayaUsd/undo/UsdUndoBlock.h> | ||
#include <mayaUsdUtils/util.h> |
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.
Do we need this?
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.
Nope they can go away. Addressed in 7004631
// | ||
#include "UsdUndoVisibleCommand.h" | ||
|
||
#include "private/Utils.h" |
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.
Do we need this?
lib/mayaUsd/ufe/UsdContextOps.cpp
Outdated
auto object3d = UsdObject3d::create(fItem); | ||
assert(object3d); |
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.
Elsewhere we've been using TF_AXIOM, might want to consider that.
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.
Addressed in 8bac473
|
||
#include <pxr/usd/usdGeom/tokens.h> | ||
|
||
#include <ufe/log.h> | ||
#include <pxr/usd/usdGeom/xformCommonAPI.h> |
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.
You sure we need this? The common API doesn't feel like it has much to do with visibility...
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.
…y via Maya hide and showHidden commands.
# This time, expect the visibility token to exists in the USD data model | ||
self.assertTrue(bool(primSpecCapsule and UsdGeom.Tokens.visibility in primSpecCapsule.attributes)) | ||
self.assertTrue(bool(primSpecCylinder and UsdGeom.Tokens.visibility in primSpecCylinder.attributes)) | ||
|
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.
Would have been nice to undo / redo showHidden --- should be quick to add and we'd put this one to rest.
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 point. Addressed in 585cca0
This PR makes the "visibility" in USD data model Undo/Redo correct.