Skip to content
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

Prepare for upcoming UFE interface changes to support Maya transform … #827

Merged
merged 3 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/mayaUsd/ufe/UsdRotatePivotTranslateUndoableCommand.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2019 Autodesk
// Copyright 2020 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -109,7 +109,12 @@ void UsdRotatePivotTranslateUndoableCommand::redo()
// Ufe::TranslateUndoableCommand overrides
//------------------------------------------------------------------------------

#if UFE_PREVIEW_VERSION_NUM >= 2025
//#ifdef UFE_V2_FEATURES_AVAILABLE
bool UsdRotatePivotTranslateUndoableCommand::set(double x, double y, double z)
#else
bool UsdRotatePivotTranslateUndoableCommand::translate(double x, double y, double z)
#endif
{
#ifdef UFE_V2_FEATURES_AVAILABLE
rotatePivotTranslateOp(prim(), fPath, x, y, z);
Expand Down
7 changes: 6 additions & 1 deletion lib/mayaUsd/ufe/UsdRotatePivotTranslateUndoableCommand.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2019 Autodesk
// Copyright 2020 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,7 +60,12 @@ class MAYAUSD_CORE_PUBLIC UsdRotatePivotTranslateUndoableCommand : public Ufe::T
// Ufe::TranslateUndoableCommand overrides
void undo() override;
void redo() override;
#if UFE_PREVIEW_VERSION_NUM >= 2025
//#ifdef UFE_V2_FEATURES_AVAILABLE
bool set(double x, double y, double z) override;
#else
bool translate(double x, double y, double z) override;
#endif

inline UsdPrim prim() const { TF_AXIOM(fItem != nullptr); return fItem->prim(); }

Expand Down
5 changes: 5 additions & 0 deletions lib/mayaUsd/ufe/UsdRotateUndoableCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ void UsdRotateUndoableCommand::performImp(double x, double y, double z)
// Ufe::RotateUndoableCommand overrides
//------------------------------------------------------------------------------

#if UFE_PREVIEW_VERSION_NUM >= 2025
//#ifdef UFE_V2_FEATURES_AVAILABLE
bool UsdRotateUndoableCommand::set(double x, double y, double z)
#else
bool UsdRotateUndoableCommand::rotate(double x, double y, double z)
#endif
{
// Fail early - Initialization did not go as expected.
if (fFailedInit)
Expand Down
5 changes: 5 additions & 0 deletions lib/mayaUsd/ufe/UsdRotateUndoableCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ class MAYAUSD_CORE_PUBLIC UsdRotateUndoableCommand : public Ufe::RotateUndoableC
// rotation value and executes the command.
void undo() override;
void redo() override;
#if UFE_PREVIEW_VERSION_NUM >= 2025
//#ifdef UFE_V2_FEATURES_AVAILABLE
bool set(double x, double y, double z) override;
#else
bool rotate(double x, double y, double z) override;
#endif

#ifdef UFE_V2_FEATURES_AVAILABLE
Ufe::Path getPath() const override { return path(); }
Expand Down
7 changes: 6 additions & 1 deletion lib/mayaUsd/ufe/UsdScaleUndoableCommand.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2019 Autodesk
// Copyright 2020 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -89,7 +89,12 @@ void UsdScaleUndoableCommand::performImp(double x, double y, double z)
// Ufe::ScaleUndoableCommand overrides
//------------------------------------------------------------------------------

#if UFE_PREVIEW_VERSION_NUM >= 2025
//#ifdef UFE_V2_FEATURES_AVAILABLE
bool UsdScaleUndoableCommand::set(double x, double y, double z)
#else
bool UsdScaleUndoableCommand::scale(double x, double y, double z)
#endif
{
perform(x, y, z);
return true;
Expand Down
7 changes: 6 additions & 1 deletion lib/mayaUsd/ufe/UsdScaleUndoableCommand.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2019 Autodesk
// Copyright 2020 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -56,7 +56,12 @@ class MAYAUSD_CORE_PUBLIC UsdScaleUndoableCommand : public Ufe::ScaleUndoableCom
// Ufe::ScaleUndoableCommand overrides
void undo() override;
void redo() override;
#if UFE_PREVIEW_VERSION_NUM >= 2025
//#ifdef UFE_V2_FEATURES_AVAILABLE
bool set(double x, double y, double z) override;
#else
bool scale(double x, double y, double z) override;
#endif

#ifdef UFE_V2_FEATURES_AVAILABLE
Ufe::Path getPath() const override { return path(); }
Expand Down
34 changes: 33 additions & 1 deletion lib/mayaUsd/ufe/UsdTransform3d.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2019 Autodesk
// Copyright 2020 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -196,7 +196,11 @@ Ufe::ScaleUndoableCommand::Ptr UsdTransform3d::scaleCmd()
#endif

#ifdef UFE_V2_FEATURES_AVAILABLE
#if UFE_PREVIEW_VERSION_NUM >= 2025
Ufe::SetMatrix4dUndoableCommand::Ptr UsdTransform3d::setMatrixCmd(const Ufe::Matrix4d& m)
#else
Ufe::SetMatrixUndoableCommand::Ptr UsdTransform3d::setMatrixCmd(const Ufe::Matrix4d& m)
#endif
{
// TODO: HS Aug25,2020 dummy code to pass the compiler errors
return nullptr;
Expand All @@ -215,6 +219,20 @@ void UsdTransform3d::scale(double x, double y, double z)
scaleOp(prim(), fItem->path(), x, y, z);
}

#if UFE_PREVIEW_VERSION_NUM >= 2025
//#ifdef UFE_V2_FEATURES_AVAILABLE
Ufe::TranslateUndoableCommand::Ptr UsdTransform3d::rotatePivotCmd(double, double, double)
{
// As of 12-Oct-2020, setting rotate pivot on command creation
// unsupported. Use translate() method on returned command.
return UsdRotatePivotTranslateUndoableCommand::create(fItem->path());
}

void UsdTransform3d::rotatePivot(double x, double y, double z)
{
rotatePivotTranslateOp(prim(), path(), x, y, z);
}
#else
Ufe::TranslateUndoableCommand::Ptr UsdTransform3d::rotatePivotTranslateCmd()
{
#ifdef UFE_V2_FEATURES_AVAILABLE
Expand All @@ -229,6 +247,7 @@ void UsdTransform3d::rotatePivotTranslate(double x, double y, double z)
{
rotatePivotTranslateOp(prim(), path(), x, y, z);
}
#endif

Ufe::Vector3d UsdTransform3d::rotatePivot() const
{
Expand All @@ -246,6 +265,18 @@ Ufe::Vector3d UsdTransform3d::rotatePivot() const
return Ufe::Vector3d(x, y, z);
}

#if UFE_PREVIEW_VERSION_NUM >= 2025
//#ifdef UFE_V2_FEATURES_AVAILABLE
Ufe::TranslateUndoableCommand::Ptr UsdTransform3d::scalePivotCmd(double, double, double)
{
throw std::runtime_error("UsdTransform3d::scalePivotCmd() not implemented");
}

void UsdTransform3d::scalePivot(double x, double y, double z)
{
return rotatePivot(x, y, z);
}
#else
Ufe::TranslateUndoableCommand::Ptr UsdTransform3d::scalePivotTranslateCmd()
{
throw std::runtime_error("UsdTransform3d::scalePivotTranslateCmd() not implemented");
Expand All @@ -255,6 +286,7 @@ void UsdTransform3d::scalePivotTranslate(double x, double y, double z)
{
return rotatePivotTranslate(x, y, z);
}
#endif

Ufe::Vector3d UsdTransform3d::scalePivot() const
{
Expand Down
16 changes: 14 additions & 2 deletions lib/mayaUsd/ufe/UsdTransform3d.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2019 Autodesk
// Copyright 2020 Autodesk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -68,19 +68,31 @@ class MAYAUSD_CORE_PUBLIC UsdTransform3d : public Ufe::Transform3d
#endif

#ifdef UFE_V2_FEATURES_AVAILABLE
#if UFE_PREVIEW_VERSION_NUM >= 2025
Ufe::SetMatrix4dUndoableCommand::Ptr setMatrixCmd(const Ufe::Matrix4d& m) override;
#else
Ufe::SetMatrixUndoableCommand::Ptr setMatrixCmd(const Ufe::Matrix4d& m) override;
#endif
Ufe::Matrix4d matrix() const override;
#endif

void translate(double x, double y, double z) override;
Ufe::Vector3d translation() const override;
void rotate(double x, double y, double z) override;
void scale(double x, double y, double z) override;
#if UFE_PREVIEW_VERSION_NUM >= 2025
//#ifdef UFE_V2_FEATURES_AVAILABLE
Ufe::TranslateUndoableCommand::Ptr rotatePivotCmd(double x, double y, double z) override;
void rotatePivot(double x, double y, double z) override;
Ufe::TranslateUndoableCommand::Ptr scalePivotCmd(double x, double y, double z) override;
void scalePivot(double x, double y, double z) override;
#else
Ufe::TranslateUndoableCommand::Ptr rotatePivotTranslateCmd() override;
void rotatePivotTranslate(double x, double y, double z) override;
Ufe::Vector3d rotatePivot() const override;
Ufe::TranslateUndoableCommand::Ptr scalePivotTranslateCmd() override;
void scalePivotTranslate(double x, double y, double z) override;
#endif
Ufe::Vector3d rotatePivot() const override;
Ufe::Vector3d scalePivot() const override;
Ufe::Matrix4d segmentInclusiveMatrix() const override;
Ufe::Matrix4d segmentExclusiveMatrix() const override;
Expand Down
5 changes: 5 additions & 0 deletions lib/mayaUsd/ufe/UsdTranslateUndoableCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ void UsdTranslateUndoableCommand::performImp(double x, double y, double z)
// Ufe::TranslateUndoableCommand overrides
//------------------------------------------------------------------------------

#if UFE_PREVIEW_VERSION_NUM >= 2025
//#ifdef UFE_V2_FEATURES_AVAILABLE
bool UsdTranslateUndoableCommand::set(double x, double y, double z)
#else
bool UsdTranslateUndoableCommand::translate(double x, double y, double z)
#endif
{
perform(x, y, z);
return true;
Expand Down
5 changes: 5 additions & 0 deletions lib/mayaUsd/ufe/UsdTranslateUndoableCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ class MAYAUSD_CORE_PUBLIC UsdTranslateUndoableCommand : public Ufe::TranslateUnd
// translation value and executes the command.
void undo() override;
void redo() override;
#if UFE_PREVIEW_VERSION_NUM >= 2025
//#ifdef UFE_V2_FEATURES_AVAILABLE
bool set(double x, double y, double z) override;
#else
bool translate(double x, double y, double z) override;
#endif

#ifdef UFE_V2_FEATURES_AVAILABLE
Ufe::Path getPath() const override { return path(); }
Expand Down
2 changes: 1 addition & 1 deletion lib/mayaUsd/ufe/UsdUIInfoHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace
template<typename T>
void addMetadataCount(const T& op, std::string& tooltip, bool& needComma, const std::string& singular, const std::string& plural)
{
T::ItemVector refs;
typename T::ItemVector refs;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this.

op.ApplyOperations(&refs);
if (!refs.empty()) {
addMetadataStrings(refs.size(), tooltip, needComma, singular, plural);
Expand Down
27 changes: 22 additions & 5 deletions test/lib/ufe/testRotatePivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,37 @@ def testRotatePivot(self):
usdSphereItem = ufe.Hierarchy.createItem(usdSpherePath)
t3d = ufe.Transform3d.transform3d(usdSphereItem)

t3d.rotatePivotTranslate(pivot[0], pivot[1], pivot[2])
# if (ufeUtils.ufeFeatureSetVersion() >= 2):
if(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '2025'):
t3d.rotatePivotTranslate(pivot[0], pivot[1], pivot[2])
else:
t3d.rotatePivot(pivot[0], pivot[1], pivot[2])
usdPivot = t3d.rotatePivot()
self.assertEqual(v3dToMPoint(usdPivot), pivot)

t3d.rotate(degrees(rot[0]), degrees(rot[1]), degrees(rot[2]))
sphereMatrix = om.MMatrix(t3d.inclusiveMatrix().matrix)
self.checkPos(sphereMatrix, [xyWorldValue, xyWorldValue, 0])

t3d.rotatePivotTranslate(0, 0, 0)
# if (ufeUtils.ufeFeatureSetVersion() >= 2):
if(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '2025'):
t3d.rotatePivotTranslate(0, 0, 0)
else:
t3d.rotatePivot(0, 0, 0)
usdPivot = t3d.rotatePivot()
self.assertEqual(v3dToMPoint(usdPivot), om.MPoint(0, 0, 0))

sphereMatrix = om.MMatrix(t3d.inclusiveMatrix().matrix)
self.checkPos(sphereMatrix, [10, 0, 0])

# Use a UFE undoable command to set the pivot.
rotatePivotCmd = t3d.rotatePivotTranslateCmd()
rotatePivotCmd.translate(pivot[0], pivot[1], pivot[2])
# if (ufeUtils.ufeFeatureSetVersion() >= 2):
if(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '2025'):
rotatePivotCmd = t3d.rotatePivotTranslateCmd()
rotatePivotCmd.translate(pivot[0], pivot[1], pivot[2])
else:
rotatePivotCmd = t3d.rotatePivotCmd()
rotatePivotCmd.set(pivot[0], pivot[1], pivot[2])

usdPivot = t3d.rotatePivot()
self.assertEqual(v3dToMPoint(usdPivot), pivot)
Expand Down Expand Up @@ -162,7 +175,11 @@ def testRotatePivotCmd(self):
# Start with a non-zero initial rotate pivot. This is required to test
# MAYA-105345, otherwise a zero initial rotate pivot produces the
# correct result through an unintended code path.
t3d.rotatePivotTranslate(2, 0, 0)
# if (ufeUtils.ufeFeatureSetVersion() >= 2):
if(os.getenv('UFE_PREVIEW_VERSION_NUM', '0000') < '2025'):
t3d.rotatePivotTranslate(2, 0, 0)
else:
t3d.rotatePivot(2, 0, 0)
usdPivot = t3d.rotatePivot()
self.assertEqual(v3dToMPoint(usdPivot), om.MPoint(2, 0, 0))

Expand Down