-
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-105277: Initial work to support None-destructive reorder ( move ) of prims relative to their siblings. #867
Conversation
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.
Looking good! A few minor things to fix up, but otherwise really close.
// Ufe::Hierarchy::insertChildCmd() returns a base class | ||
// Ufe::UndoableCommand::Ptr object, from which we can't retrieve the added | ||
// child. PPT, 13-Jul-2020. | ||
#ifdef UFE_V2_FEATURES_AVAILABLE |
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 about this macro? There is no Hierarchy::insertChild() in UFE v1.
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 catch. Yes this #ifdef is redundant. Addressed in 0977cf1
// in order to get the parent out of it. | ||
const auto& childPrim = downcast((*orderedList.begin()))->prim(); | ||
|
||
return UsdUndoReorderCommand::create(childPrim, orderedTokens); |
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 confusing to me: in the UsdUndoReorderCommand, all we do with this childPrim is to get its parent, as far as I can tell. Then why not give the parent directly, especially here since we know the parent is the pseudo-root.
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.
Can't agree more... passing parent is more appropriate. Addressed in 0977cf1
lib/mayaUsd/ufe/UsdHierarchy.cpp
Outdated
// Ufe::Hierarchy::insertChildCmd() returns a base class | ||
// Ufe::UndoableCommand::Ptr object, from which we can't retrieve the added | ||
// child. PPT, 13-Jul-2020. | ||
#ifdef UFE_V2_FEATURES_AVAILABLE |
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.
Again, insertChild() doesn't exist in UFE v1, so pretty sure this ifdef is incorrect.
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 0977cf1
lib/mayaUsd/ufe/UsdHierarchy.cpp
Outdated
orderedTokens.emplace_back(downcast(item)->prim().GetPath().GetNameToken()); | ||
} | ||
|
||
// TODO HS Oct 23, 2020, grab any child and pass it to UsdUndoReorderCommand |
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.
Since the first argument is the parent, it's the scene item of the Hierarchy interface, so this is just
return UsdUndoReorderCommand::create(downcast(sceneItem()), orderedTokens);
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 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.
Hmm, I'm confused! Isn't this a method that is called on the parent, to reorder its children? I.e. you're calling it on /Xform1's hierarchy interface, to reorder its children, so Hierarchy::sceneItem() will in fact give you the parent.
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.
Ahhh.. sorry about the confusion. Now I see it... :) I was calling the the command on a wrong hierarchy interface.
I have it fixed soon on the data model side and then make this change.
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.
) override; | ||
|
||
Ufe::SceneItem::Ptr insertChild(const Ufe::SceneItem::Ptr& child,const Ufe::SceneItem::Ptr& pos) override; | ||
Ufe::InsertChildCommand::Ptr insertChildCmd(const Ufe::SceneItem::Ptr& child, const Ufe::SceneItem::Ptr& pos) override; |
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.
Funky indentation?
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.
Yup... all of the code base under lib/mayaUsd/ufe
has a mix of spaces and tabs. I can't wait for @kxl-adsk to apply the clang format on the repo :) .
#include <ufe/undoableCommand.h> | ||
|
||
#include <mayaUsd/base/api.h> | ||
#include <mayaUsd/ufe/UsdSceneItem.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 to include UsdSceneItem.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.
Good point. Not at all. This header came from my copy-paste of another class. UsdSceneItem.h brings in #include <pxr/usd/usd/prim.h>
and that what we need here.
Addressed in 0977cf1
@@ -0,0 +1,53 @@ | |||
#usda 1.0 |
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.
Nit-pick, but seems like such a simple file, we could just create the scene on the fly in the test, I would think.
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 agree with you. primitives.usda has a very simple hierarchy and I could have created it on the fly. I admit being lazy here :)
@@ -164,6 +164,10 @@ def openGroupBallsScene(): | |||
filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "testSamples", "groupBalls", "ballset.ma" ) | |||
cmds.file(filePath, force=True, open=True) | |||
|
|||
def openPrimitivesScene(): |
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.
Have a look at the recent improvement that SPI put in for data file path access.
And I can't help to re-iterate that if you created the scene on the fly, you wouldn't need to do 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.
See
#868
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 0977cf1
test/lib/ufe/testReorderCmd.py
Outdated
''' Reorder (a.k.a move) objects relative to their siblings. | ||
For relative moves, both positive and negative numbers may be specified. | ||
''' | ||
shapeSegment = mayaUtils.createUfePathSegment("|world|Primitives_usd|Primitives_usdShape") |
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.
Because this test won't be executed for UFE v1, it would be much clearer and more maintainable to use UFE path strings:
cylinderPath = ufe.PathString.path('Primitives_usd|Primitives_usdShape,/Xform1/Cylinder1')
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. Great point.
Addressed in 0977cf1
test/lib/ufe/testReorderCmd.py
Outdated
Reorder (a.k.a move) to front and back of the sibling list | ||
''' | ||
shapeSegment = mayaUtils.createUfePathSegment("|world|Primitives_usd|Primitives_usdShape") | ||
cylinderPath = ufe.Path([shapeSegment, usdUtils.createUfePathSegment("/Xform1/Cylinder1")]) |
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.
Use path strings.
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 0977cf1
|
||
return UsdUndoReorderCommand::create(childPrim, orderedTokens); | ||
return UsdUndoReorderCommand::create(parentPrim, orderedTokens); |
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.
Of course there's nothing wrong with this, but you can avoid the downcast and the call to childPrim.GetParent(), because here you know the parent prim is the pseudo-root, so you can just pass it:
return UsdUndoReorderCommand::create(getUsdRootPrim(), orderedTokens);
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 PR is the initial work to support None-destructive reorder (move) of USD prim(s) relative to their siblings based on Maya's native reorder command.
Supported features:
To see how reorder command works: https://download.autodesk.com/us/maya/2011help/CommandsPython/reorder.html
Demo: