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

Ufe manipulation #962

Merged
merged 63 commits into from
Dec 6, 2020
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
beb4977
Proof of concept for USD matrix transform op editing.
ppt-adsk Jul 22, 2020
26eb26b
UFE commands must read initial value from proxy shape time.
ppt-adsk Aug 25, 2020
a46a9db
Made read vs write time explicit in TRS commands.
ppt-adsk Aug 26, 2020
37249f8
Merge pull request #729 from Autodesk/adsk_matrixOp_proof_of_concept
Sep 1, 2020
20f1b92
Merge branch 'dev' into merge_dev_to_ufe-manipulation
ppt-adsk Sep 9, 2020
cd29d82
Merge pull request #767 from Autodesk/merge_dev_to_ufe-manipulation
ppt-adsk Sep 9, 2020
cdddf38
Merge branch 'dev' into merge_dev_to_ufe-manipulation_01
ppt-adsk Sep 10, 2020
ae53705
Update to latest Ufe::Transform3d interface.
ppt-adsk Sep 10, 2020
cb124c6
Merge pull request #770 from Autodesk/merge_dev_to_ufe-manipulation_01
ppt-adsk Sep 10, 2020
16ef109
Merge branch 'dev' into ufe-manipulation
ppt-adsk Sep 23, 2020
ce15747
Merge branch 'dev' into ufe-manipulation
ppt-adsk Oct 15, 2020
f1faa20
Merge branch 'dev' into ufe-manipulation
ppt-adsk Oct 26, 2020
d9a4239
Compilation fixes to update to latest dev.
ppt-adsk Oct 26, 2020
765ab86
Implementation of Maya transform stack Transform3d interface.
ppt-adsk Oct 15, 2020
8c9e076
Address internal code review feedback.
ppt-adsk Oct 28, 2020
c2307b7
Minor bug fixes.
ppt-adsk Oct 29, 2020
fccaafb
Merge branch 'dev' into ufe-manipulation
ppt-adsk Oct 30, 2020
02be11f
Merge pull request #872 from Autodesk/tremblp/MAYA-106087/maya_xform_…
Nov 3, 2020
c54aed6
Merge branch 'ufe-manipulation' of https://github.com/Autodesk/maya-u…
ppt-adsk Nov 4, 2020
f513d94
Enable initialization order warning on Windows, fix compilation.
ppt-adsk Nov 4, 2020
c5c801b
Merge pull request #887 from Autodesk/tremblp/MAYA-106087/maya_xform_…
ppt-adsk Nov 4, 2020
0d0983b
Merge commit '0fe90bcce893dfbd4422f70bda84435f5721dd43' into kxl-adsk…
Nov 5, 2020
2487c4a
Merge commit '7c64b5df1f1cdbf879aaef12ed64b7fdd77a3af1' into kxl-adsk…
Nov 5, 2020
6a7548c
Merge remote-tracking branch 'origin/dev' into kxl-adsk/merge_dev_wit…
Nov 5, 2020
8529e8d
Merge pull request #894 from Autodesk/kxl-adsk/merge_dev_with_clang_f…
ppt-adsk Nov 5, 2020
45d69f8
First working fallback transform op handling.
ppt-adsk Nov 16, 2020
5e1e7c4
Removed Maya and Maya fallback code duplication.
ppt-adsk Nov 17, 2020
25fefe1
Command state machine and lifescope fixes.
ppt-adsk Nov 25, 2020
0780f8a
Added common transform API to chain of responsibility, with test.
ppt-adsk Nov 26, 2020
9af738c
Ran clang-format on changed files.
ppt-adsk Nov 26, 2020
182c71e
Merge branch 'ufe-manipulation' into tremblp/MAYA-106088/arbitrary_st…
ppt-adsk Nov 26, 2020
8224093
Addressed review feedback.
ppt-adsk Nov 26, 2020
d73ad7e
Merge pull request #945 from Autodesk/tremblp/MAYA-106088/arbitrary_s…
ppt-adsk Nov 26, 2020
b9f0330
Integrate Ufe::Transform3d::editTransform3d() hint support.
ppt-adsk Nov 30, 2020
4255dbd
Merge branch 'dev' into ufe-manipulation
Nov 30, 2020
5df6b3c
Add Undo/Redo support for 3dMayaXformStack.
Dec 1, 2020
8e32ac4
Replace c-style function pointer in favor of the std::function + lambda.
Dec 1, 2020
625c337
Merge pull request #956 from Autodesk/sabrih/MAYA-106089/support_undo…
HamedSabri-adsk Dec 1, 2020
e39340b
Adapt to changes in UFE editTransform3d hint.
ppt-adsk Dec 1, 2020
813d266
Ensure compilation with previous Maya preview release.
ppt-adsk Dec 1, 2020
0ff936a
Added Maya command to toggle Transform3d handler back to legacy.
ppt-adsk Dec 2, 2020
25a0ffe
Applied clang-format.
ppt-adsk Dec 2, 2020
8221079
Merge branch 'ufe-manipulation' into tremblp/MAYA-106088/arbitrary_st…
ppt-adsk Dec 2, 2020
4d8d5ac
Merge pull request #948 from Autodesk/tremblp/MAYA-106088/arbitrary_s…
ppt-adsk Dec 2, 2020
3f99a2a
- Adjust UndoBlock to capture the opFunc functor that sets/adds to th…
Dec 2, 2020
4e8282c
Merge pull request #959 from Autodesk/sabrih/fix_undo_redo_transforma…
ppt-adsk Dec 2, 2020
d9e93e8
Fixed parent test undo / redo failures.
ppt-adsk Dec 2, 2020
38eb698
Merge pull request #960 from Autodesk/tremblp/MAYA-106088/fix_parent_…
ppt-adsk Dec 3, 2020
120ae47
Fix undo/redo crash when switching between layers.
Dec 3, 2020
6df223f
MAYA-108545: Prevent the crash when authoring edits to instance proxi…
Dec 4, 2020
cf67adf
Merge pull request #969 from Autodesk/sabrih/MAYA-108545/authoring_to…
Dec 4, 2020
3cbd472
Compilation fixes for Maya 2020.
ppt-adsk Dec 4, 2020
ba205a1
Merge pull request #971 from Autodesk/tremblp/MAYA-106088/preflight_m…
ppt-adsk Dec 4, 2020
2981cca
Revert "Fix undo/redo crash when switching between layers."
Dec 4, 2020
a87fc0b
Make sure the USD state delegate is registered for current existing PR.
Dec 4, 2020
677db40
Address feedback. Use a dynamic_cast to determine if a layer is alrea…
Dec 4, 2020
4e393cb
Fixes for pre-flight tests and clang-format.
ppt-adsk Dec 4, 2020
5f331cb
Merge pull request #975 from Autodesk/tremblp/MAYA-106088/preflight_f…
ppt-adsk Dec 4, 2020
49c5882
Merge pull request #965 from Autodesk/sabrih/MAYA-108549/fix_undo_cra…
HamedSabri-adsk Dec 4, 2020
416df80
Fix unused variables and clang-format errors.
ppt-adsk Dec 5, 2020
84c3b12
Merge pull request #976 from Autodesk/tremblp/MAYA-106088/more-prefli…
ppt-adsk Dec 5, 2020
edde5d5
Disable failing test on Linux.
ppt-adsk Dec 6, 2020
332e169
Merge pull request #977 from Autodesk/tremblp/MAYA-106088/disable-fai…
ppt-adsk Dec 6, 2020
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
12 changes: 12 additions & 0 deletions lib/mayaUsd/ufe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ if(CMAKE_UFE_V2_FEATURES_AVAILABLE)
target_sources(${PROJECT_NAME}
PRIVATE
ProxyShapeContextOpsHandler.cpp
RotationUtils.cpp
UsdAttribute.cpp
UsdAttributes.cpp
UsdAttributesHandler.cpp
UsdContextOps.cpp
UsdContextOpsHandler.cpp
UsdObject3d.cpp
UsdObject3dHandler.cpp
UsdTransform3dBase.cpp
UsdTransform3dCommonAPI.cpp
UsdTransform3dFallbackMayaXformStack.cpp
UsdTransform3dMatrixOp.cpp
UsdTransform3dMayaXformStack.cpp
UsdUndoAddNewPrimCommand.cpp
UsdUndoCreateGroupCommand.cpp
UsdUndoInsertChildCommand.cpp
Expand Down Expand Up @@ -83,13 +89,19 @@ set(HEADERS
if(CMAKE_UFE_V2_FEATURES_AVAILABLE)
list(APPEND HEADERS
ProxyShapeContextOpsHandler.h
RotationUtils.h
UsdAttribute.h
UsdAttributes.h
UsdAttributesHandler.h
UsdContextOps.h
UsdContextOpsHandler.h
UsdObject3d.h
UsdObject3dHandler.h
UsdTransform3dBase.h
UsdTransform3dCommonAPI.h
UsdTransform3dFallbackMayaXformStack.h
UsdTransform3dMatrixOp.h
UsdTransform3dMayaXformStack.h
UsdUIInfoHandler.h
UsdUndoAddNewPrimCommand.h
UsdUndoCreateGroupCommand.h
Expand Down
60 changes: 60 additions & 0 deletions lib/mayaUsd/ufe/RotationUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// 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.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#include "RotationUtils.h"

namespace {

inline double TO_DEG(double a) { return a * 180.0 / 3.141592654; }
inline double TO_RAD(double a) { return a * 3.141592654 / 180.0; }

}

namespace MAYAUSD_NS_DEF {
namespace ufe {

template <MEulerRotation::RotationOrder SRC_ROT_ORDER> Ufe::Vector3d fromRot(const VtValue& value)
{
auto v = value.Get<GfVec3f>();

MEulerRotation eulerRot(TO_RAD(v[0]), TO_RAD(v[1]), TO_RAD(v[2]), SRC_ROT_ORDER);
eulerRot.reorderIt(MEulerRotation::kXYZ);
return Ufe::Vector3d(TO_DEG(eulerRot.x), TO_DEG(eulerRot.y), TO_DEG(eulerRot.z));
}

template <MEulerRotation::RotationOrder DST_ROT_ORDER> VtValue toRot(double x, double y, double z)
{
MEulerRotation eulerRot(TO_RAD(x), TO_RAD(y), TO_RAD(z), MEulerRotation::kXYZ);
eulerRot.reorderIt(DST_ROT_ORDER);
VtValue v;
v = GfVec3f(TO_DEG(eulerRot.x), TO_DEG(eulerRot.y), TO_DEG(eulerRot.z));
return v;
}

template Ufe::Vector3d fromRot<MEulerRotation::kXZY>(const VtValue&);
template Ufe::Vector3d fromRot<MEulerRotation::kYXZ>(const VtValue&);
template Ufe::Vector3d fromRot<MEulerRotation::kYZX>(const VtValue&);
template Ufe::Vector3d fromRot<MEulerRotation::kZXY>(const VtValue&);
template Ufe::Vector3d fromRot<MEulerRotation::kZYX>(const VtValue&);

template VtValue toRot<MEulerRotation::kXZY>(double, double, double);
template VtValue toRot<MEulerRotation::kYXZ>(double, double, double);
template VtValue toRot<MEulerRotation::kYZX>(double, double, double);
template VtValue toRot<MEulerRotation::kZXY>(double, double, double);
template VtValue toRot<MEulerRotation::kZYX>(double, double, double);

} // namespace ufe
} // namespace MAYAUSD_NS_DEF
100 changes: 100 additions & 0 deletions lib/mayaUsd/ufe/RotationUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
//
// 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.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#pragma once
Copy link
Contributor

@HamedSabri-adsk HamedSabri-adsk Dec 3, 2020

Choose a reason for hiding this comment

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

@ppt-adsk Nit-pick: use include guard instead based on our coding guideline. Same thing in other files.


#include <mayaUsd/mayaUsd.h>

#include <pxr/base/gf/vec3d.h>
#include <pxr/base/vt/value.h>

#include <maya/MEulerRotation.h>
#include <ufe/types.h>

PXR_NAMESPACE_USING_DIRECTIVE

namespace MAYAUSD_NS_DEF {
namespace ufe {

//----------------------------------------------------------------------
// Conversion functions from RotXYZ to all supported rotation attributes.
//----------------------------------------------------------------------

inline VtValue toXYZ(double x, double y, double z)
{
// No rotation order conversion
VtValue v;
v = GfVec3f(x, y, z);
return v;
}

// Reorder argument RotXYZ rotation.
template <MEulerRotation::RotationOrder DST_ROT_ORDER> VtValue toRot(double x, double y, double z);

constexpr auto toXZY = toRot<MEulerRotation::kXZY>;
constexpr auto toYXZ = toRot<MEulerRotation::kYXZ>;
constexpr auto toYZX = toRot<MEulerRotation::kYZX>;
constexpr auto toZXY = toRot<MEulerRotation::kZXY>;
constexpr auto toZYX = toRot<MEulerRotation::kZYX>;

// Scalar float is the proper type for single-axis rotations.
inline VtValue toX(double x, double, double)
{
VtValue v;
v = float(x);
return v;
}

inline VtValue toY(double, double y, double)
{
VtValue v;
v = float(y);
return v;
}

inline VtValue toZ(double, double, double z)
{
VtValue v;
v = float(z);
return v;
}

//----------------------------------------------------------------------
// Conversion functions from all supported rotation attributes to RotXYZ.
//----------------------------------------------------------------------

inline Ufe::Vector3d fromXYZ(const VtValue& value)
{
// No rotation order conversion
auto v = value.Get<GfVec3f>();
return Ufe::Vector3d(v[0], v[1], v[2]);
}

template <MEulerRotation::RotationOrder SRC_ROT_ORDER> Ufe::Vector3d fromRot(const VtValue& value);

constexpr auto fromXZY = fromRot<MEulerRotation::kXZY>;
constexpr auto fromYXZ = fromRot<MEulerRotation::kYXZ>;
constexpr auto fromYZX = fromRot<MEulerRotation::kYZX>;
constexpr auto fromZXY = fromRot<MEulerRotation::kZXY>;
constexpr auto fromZYX = fromRot<MEulerRotation::kZYX>;

inline Ufe::Vector3d fromX(const VtValue& value) { return Ufe::Vector3d(value.Get<float>(), 0, 0); }

inline Ufe::Vector3d fromY(const VtValue& value) { return Ufe::Vector3d(0, value.Get<float>(), 0); }

inline Ufe::Vector3d fromZ(const VtValue& value) { return Ufe::Vector3d(0, 0, value.Get<float>()); }

} // namespace ufe
} // namespace MAYAUSD_NS_DEF
12 changes: 6 additions & 6 deletions lib/mayaUsd/ufe/StagesSubject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ void StagesSubject::stageChanged(
}
#endif

// We need to determine if the change is a Transform3d change.
// We must at least pick up xformOp:translate, xformOp:rotateXYZ,
// and xformOp:scale.
const TfToken nameToken = changedPath.GetNameToken();
if (nameToken == UsdGeomTokens->xformOpOrder || UsdGeomXformOp::IsXformOp(nameToken)) {
Ufe::Transform3d::notify(ufePath);
if (!InTransform3dChange::inTransform3dChange()) {
// Is the change a Transform3d change?
const TfToken nameToken = changedPath.GetNameToken();
if (nameToken == UsdGeomTokens->xformOpOrder || UsdGeomXformOp::IsXformOp(nameToken)) {
Ufe::Transform3d::notify(ufePath);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/mayaUsd/ufe/UsdRotateUndoableCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class MAYAUSD_CORE_PUBLIC UsdRotateUndoableCommand
create(const UsdSceneItem::Ptr& item, double x, double y, double z);
#endif

// Ufe::RotateUndoableCommand overrides. rotate() sets the command's
// Ufe::RotateUndoableCommand overrides. set() sets the command's
// rotation value and executes the command.
void undo() override;
void redo() override;
Expand Down
87 changes: 54 additions & 33 deletions lib/mayaUsd/ufe/UsdTransform3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,7 @@ 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 @@ -209,36 +205,35 @@ 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)
Ufe::TranslateUndoableCommand::Ptr
#ifdef UFE_V2_FEATURES_AVAILABLE
UsdTransform3d::rotatePivotCmd(double, double, double)
#else
UsdTransform3d::rotatePivotTranslateCmd()
#endif
{
// 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()
{
return UsdRotatePivotTranslateUndoableCommand::create(
#ifdef UFE_V2_FEATURES_AVAILABLE
return UsdRotatePivotTranslateUndoableCommand::create(fItem->path());
fItem->path()
#else
auto translateCmd
= UsdRotatePivotTranslateUndoableCommand::create(prim(), fItem->path(), fItem);
return translateCmd;
prim(), fItem->path(), fItem
#endif
);
}

void UsdTransform3d::rotatePivotTranslate(double x, double y, double z)
void
#ifdef UFE_V2_FEATURES_AVAILABLE
UsdTransform3d::rotatePivot(
#else
UsdTransform3d::rotatePivotTranslate(
#endif
double x, double y, double z
)
{
rotatePivotTranslateOp(prim(), path(), x, y, z);
}
#endif

Ufe::Vector3d UsdTransform3d::rotatePivot() const
{
Expand All @@ -256,27 +251,53 @@ 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)
Ufe::TranslateUndoableCommand::Ptr
#ifdef UFE_V2_FEATURES_AVAILABLE
UsdTransform3d::scalePivotCmd(double, double, double)
#else
UsdTransform3d::scalePivotTranslateCmd()
#endif
{
return nullptr;
}

void UsdTransform3d::scalePivot(double x, double y, double z) { return rotatePivot(x, y, z); }
void
#ifdef UFE_V2_FEATURES_AVAILABLE
UsdTransform3d::scalePivot(
#else
Ufe::TranslateUndoableCommand::Ptr UsdTransform3d::scalePivotTranslateCmd()
UsdTransform3d::scalePivotTranslate(
#endif
double, double, double
)
{}

Ufe::Vector3d UsdTransform3d::scalePivot() const { return rotatePivot(); }

#ifdef UFE_V2_FEATURES_AVAILABLE
Ufe::TranslateUndoableCommand::Ptr UsdTransform3d::translateRotatePivotCmd(double, double, double)
{
throw std::runtime_error("UsdTransform3d::scalePivotTranslateCmd() not implemented");
// USD common transform API does not support rotate pivot correction.
return nullptr;
}

void UsdTransform3d::scalePivotTranslate(double x, double y, double z)
Ufe::Vector3d UsdTransform3d::rotatePivotTranslation() const
{
return rotatePivotTranslate(x, y, z);
// USD common transform API does not support rotate pivot correction.
return Ufe::Vector3d(0, 0, 0);
}
#endif

Ufe::Vector3d UsdTransform3d::scalePivot() const { return rotatePivot(); }
Ufe::TranslateUndoableCommand::Ptr UsdTransform3d::translateScalePivotCmd(double, double, double)
{
// USD common transform API does not support scale pivot correction.
return nullptr;
}

Ufe::Vector3d UsdTransform3d::scalePivotTranslation() const
{
// USD common transform API does not support scale pivot correction.
return Ufe::Vector3d(0, 0, 0);
}
#endif

Ufe::Matrix4d UsdTransform3d::segmentInclusiveMatrix() const
{
Expand Down
Loading