-
Notifications
You must be signed in to change notification settings - Fork 201
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
Fallback, multi-matrix parent absolute. #1201
Fallback, multi-matrix parent absolute. #1201
Conversation
@@ -143,7 +144,10 @@ void setXformOpOrder(const UsdGeomXformable& xformable) | |||
xformable.SetXformOpOrder(newOrder, resetsXformStack); | |||
} | |||
|
|||
Ufe::Transform3d::Ptr createTransform3d(const Ufe::SceneItem::Ptr& item) | |||
Ufe::Transform3d::Ptr createEditTransform3dImp( |
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.
Factored out common code between createTransform3d() and editTransform3d().
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 be good to add documentation for parameters. As it is now, it's unclear without reading the implementation to know which arguments are input vs output. Adding a prefix is another nice way of helping developers that have to work with your 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.
Will add documentation. As for input versus output, I usually stick to
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f17-for-in-out-parameters-pass-by-reference-to-non-const
so that non-const ref parameters will be modified inside the function, but I will add that information in the documentation.
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 would prefer to see more usage of Doxygen formatted documentation with proper usage of direction [in]
and [out]
to make this clear - https://www.doxygen.nl/manual/commands.html#cmdparam. I won't block the review on it.
|
||
// The Maya fallback transform stack is the last group of transform ops in | ||
// the complete transform stack, so Mr and thus inv(Mr), are the identity. | ||
return UsdTransform3dSetObjectMatrix::create(editTransform3d, ml.GetInverse(), GfMatrix4d(1)); |
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.
transform3d() interface is used to set the object position (under parent -absolute) using the complete transform stack. To do this, use the new UsdTransform3dSetObjectMatrix wrapper that takes an editTransform3d() interface, along with the matrices to perform the matrix algebra to change only the fallback transform ops.
@@ -45,6 +46,52 @@ VtValue getValue(const UsdAttribute& attr, const UsdTimeCode& time) | |||
|
|||
const char* getMatrixOp() { return std::getenv("MAYA_USD_MATRIX_XFORM_OP_NAME"); } | |||
|
|||
std::vector<UsdGeomXformOp>::const_iterator |
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.
Factor out common code between the editTransform3d() and transform3d() interfaces.
// Use editTransform3d() to set a single matrix transform op. | ||
// transform3d() returns a whole-object interface, which may include | ||
// other transform ops. | ||
auto t3d = Ufe::Transform3d::editTransform3d(sceneItem()); |
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.
editTransform3d() sets the matrix for a single matrix op, which is what we want.
// pivot edit was done on a matrix op stack. Since matrix ops don't | ||
// support pivot edits, a fallback Maya stack will be added, and from that | ||
// point on the fallback Maya stack must be used. | ||
if (findNonMatrix(i, xformOps)) { |
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 factored-out code --- no change in behavior.
// | ||
// Certain Maya operations (such as parent -absolute) require the capability to | ||
// edit the matrix transform of the whole object. This class wraps a | ||
// UsdTransform3dMatrixOp or UsdTransform3dFallbackMayaXformStack and converts |
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.
For UsdTransform3dMatrixOp targeting a single matrix op in a multi-matrix stack, and unconditionally for UsdTransform3dFallbackMayaXformStack, use this new UsdTransform3dSetObjectMatrix object to set the local transform of the object (e.g. for parent -absolute).
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 wrote a lot of great comments and documentation...but it still took me some time to figure out what exactly maps to Ml, Mw, Mr. Now looking at it back, what would help me to understand the code quicker is an example of a xform stack and how you break it down into these three transformations given a specific op we want to edit. It's all in the code, but having it described in one place (including pull request description) would help a lot.
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 was hoping that the one place would be this header. Perhaps a pointer in the pull request description to this file would help? I can certainly add examples for the Maya fallback stack and a multi-matrix stack to this header.
@@ -213,6 +225,7 @@ void wrapUtils() | |||
def("usdPathToUfePathSegment", | |||
usdPathToUfePathSegment, | |||
(arg("usdPath"), arg("instanceIndex") = UsdImagingDelegate::ALL_INSTANCES)); | |||
def("getTime", getTime); |
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.
Reading transform op values directly through the USD interface requires time (whereas the UFE interface uses proxy time). Expose the time accessor in Python.
@@ -706,8 +706,15 @@ def testFallback(self): | |||
mayaSphereItem = ufe.Hierarchy.createItem(mayaSpherePath) | |||
usdSphereItem = ufe.Hierarchy.createItem(usdSpherePath) | |||
usdFallbackSphereItem = ufe.Hierarchy.createItem(usdFallbackSpherePath) | |||
usdSphere3d = ufe.Transform3d.transform3d(usdSphereItem) | |||
usdFallbackSphere3d = ufe.Transform3d.transform3d(usdFallbackSphereItem) | |||
# For scene items with fallback transform ops, the transform3d() |
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.
Fix latent bug exposed with new transform3d() implementation for Maya fallback stacks. It is inappropriate to use transform3d() for reading and writing fallback transform ops; editTransform3d() must be used.
test/lib/ufe/testParentCmd.py
Outdated
checkParentDone() | ||
|
||
@unittest.skipUnless(mayaUtils.previewReleaseVersion() >= 123, 'Requires Maya fixes only available in Maya Preview Release 123 or later.') | ||
def testZParentAbsoluteMultiMatrixOp(self): |
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.
Evil test order dependence is back. testParentAbsoluteMultiMatrixOp() causes testParentAbsoluteSingleMatrixOp() to fail if the former is run first, so rename it.
usdUtils.createUfePathSegment('/Capsule1')]) | ||
capsuleItem = ufe.Hierarchy.createItem(capsulePath) | ||
|
||
# Add 3 matrix transform ops to the capsule. |
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.
Create a stack of 3 matrices, and test editing of each one, in turn.
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.
Left bunch of comments...mostly requests for improvements to the documentation.
@@ -143,7 +144,10 @@ void setXformOpOrder(const UsdGeomXformable& xformable) | |||
xformable.SetXformOpOrder(newOrder, resetsXformStack); | |||
} | |||
|
|||
Ufe::Transform3d::Ptr createTransform3d(const Ufe::SceneItem::Ptr& item) | |||
Ufe::Transform3d::Ptr createEditTransform3dImp( |
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 be good to add documentation for parameters. As it is now, it's unclear without reading the implementation to know which arguments are input vs output. Adding a prefix is another nice way of helping developers that have to work with your code.
@@ -466,6 +469,9 @@ Ufe::Vector3d UsdTransform3dMayaXformStack::rotation() const | |||
} | |||
UsdGeomXformOp r = getOp(NdxRotate); | |||
TF_AXIOM(r); | |||
if (!r.GetAttr().HasValue()) { |
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 pattern is possibly repeated in every transform 3d implementation. Have you looked for it?
# Redo: capsule still hasn't moved, Maya fallback ops are back. | ||
cmds.redo() | ||
|
||
checkParentDone() |
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.
Great test
test/lib/ufe/testParentCmd.py
Outdated
cmds.undo() | ||
|
||
# Restore initial conditions. | ||
del os.environ['MAYA_USD_MATRIX_XFORM_OP_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.
How about we spare other developers debugging and put an assert in setUp to detect when another test left this env variable set?
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.
Excellent idea.
// | ||
// Certain Maya operations (such as parent -absolute) require the capability to | ||
// edit the matrix transform of the whole object. This class wraps a | ||
// UsdTransform3dMatrixOp or UsdTransform3dFallbackMayaXformStack and converts |
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 wrote a lot of great comments and documentation...but it still took me some time to figure out what exactly maps to Ml, Mw, Mr. Now looking at it back, what would help me to understand the code quicker is an example of a xform stack and how you break it down into these three transformations given a specific op we want to edit. It's all in the code, but having it described in one place (including pull request description) would help a lot.
@@ -143,7 +144,10 @@ void setXformOpOrder(const UsdGeomXformable& xformable) | |||
xformable.SetXformOpOrder(newOrder, resetsXformStack); | |||
} | |||
|
|||
Ufe::Transform3d::Ptr createTransform3d(const Ufe::SceneItem::Ptr& item) | |||
Ufe::Transform3d::Ptr createEditTransform3dImp( |
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 would prefer to see more usage of Doxygen formatted documentation with proper usage of direction [in]
and [out]
to make this clear - https://www.doxygen.nl/manual/commands.html#cmdparam. I won't block the review on it.
@@ -58,6 +58,36 @@ namespace ufe { | |||
// matrices inv(Ml) and inv(Mr). In the case of the Maya fallback transform | |||
// stack, Mr is the identity by definition, as the Maya fallback transform | |||
// stack must be the last group of transform ops in the transform stack. | |||
// | |||
// Here is an example given a Maya fallback transform stack: |
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.
Awesome!
def tearDown(self): | ||
# If there was no 'MAYA_USD_MATRIX_XFORM_OP_NAME' environment variable, | ||
# make sure there is none at the end of the test. | ||
if self.mayaUsdMatrixXformOpName is None: |
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.
Thank you
No description provided.