From 00f603a73b9383fbeda37800cb928a700a161f59 Mon Sep 17 00:00:00 2001 From: Paul Molodowitch Date: Thu, 6 Sep 2018 12:33:13 -0700 Subject: [PATCH 1/2] Revert "use standard MVector / MPoint / MQuaternion constants for zero/one" This reverts commit 56eaf2cc2af088bb12fe2b6181b8f4c72807c6a6. Done in response to Rob's comment here: https://github.com/AnimalLogic/AL_USDMaya/pull/112#pullrequestreview-152336003 --- .../AL/usdmaya/nodes/TransformationMatrix.cpp | 62 +++++++++++-------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp b/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp index 5b8c6079..8b93a0c0 100644 --- a/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp +++ b/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp @@ -1862,33 +1862,38 @@ void TransformationMatrix::enableReadAnimatedValues(bool enabled) // of nothing. This will call my code that will magically construct the transform ops in the right order. if(enabled) { + const MVector nullVec(0, 0, 0); + const MVector oneVec(1.0, 1.0, 1.0); + const MPoint nullPoint(0, 0, 0); + const MQuaternion nullQuat(0, 0, 0, 1.0); + if(!pushPrimToMatrix()) { - if(primHasTranslation() || translation() != MVector::zero) - translateBy(MVector::zero); + if(primHasTranslation() || translation() != nullVec) + translateBy(nullVec); - if(primHasScale() || scale() != MVector::one) - scaleBy(MVector::one); + if(primHasScale() || scale() != oneVec) + scaleBy(oneVec); - if(primHasShear() || shear() != MVector::zero) - shearBy(MVector::zero); + if(primHasShear() || shear() != nullVec) + shearBy(nullVec); - if(primHasScalePivot() || scalePivot() != MPoint::origin) + if(primHasScalePivot() || scalePivot() != nullPoint) setScalePivot(scalePivot(), MSpace::kTransform, false); - if(primHasScalePivot() || scalePivot() != MPoint::origin) + if(primHasScalePivot() || scalePivot() != nullPoint) setScalePivotTranslation(scalePivotTranslation(), MSpace::kTransform); - if(primHasRotatePivot() || rotatePivot() != MPoint::origin) + if(primHasRotatePivot() || rotatePivot() != nullPoint) setRotatePivot(rotatePivot(), MSpace::kTransform, false); - if(primHasRotatePivotTranslate() || rotatePivotTranslation() != MVector::zero) + if(primHasRotatePivotTranslate() || rotatePivotTranslation() != nullVec) setRotatePivotTranslation(rotatePivotTranslation(), MSpace::kTransform); - if(primHasRotation() || rotation() != MQuaternion::identity) - rotateBy(MQuaternion::identity); + if(primHasRotation() || rotation() != nullQuat) + rotateBy(nullQuat); - if(primHasRotateAxes() || rotateOrientation() != MQuaternion::identity) + if(primHasRotateAxes() || rotateOrientation() != nullQuat) setRotateOrientation(rotateOrientation(), MSpace::kTransform, false); } else @@ -1926,33 +1931,38 @@ void TransformationMatrix::enablePushToPrim(bool enabled) // of nothing. This will call my code that will magically construct the transform ops in the right order. if(enabled && getTimeCode() == UsdTimeCode::Default()) { + const MVector nullVec(0, 0, 0); + const MVector oneVec(1.0, 1.0, 1.0); + const MPoint nullPoint(0, 0, 0); + const MQuaternion nullQuat(0, 0, 0, 1.0); + if(!pushPrimToMatrix()) { - if(primHasTranslation() || translation() != MVector::zero) - translateBy(MVector::zero); + if(primHasTranslation() || translation() != nullVec) + translateBy(nullVec); - if(primHasScale() || scale() != MVector::one) - scaleBy(MVector::one); + if(primHasScale() || scale() != oneVec) + scaleBy(oneVec); - if(primHasShear() || shear() != MVector::zero) - shearBy(MVector::zero); + if(primHasShear() || shear() != nullVec) + shearBy(nullVec); - if(primHasScalePivot() || scalePivot() != MPoint::origin) + if(primHasScalePivot() || scalePivot() != nullPoint) setScalePivot(scalePivot(), MSpace::kTransform, false); - if(primHasScalePivotTranslate() || scalePivotTranslation() != MPoint::origin) + if(primHasScalePivotTranslate() || scalePivotTranslation() != nullPoint) setScalePivotTranslation(scalePivotTranslation(), MSpace::kTransform); - if(primHasRotatePivot() || rotatePivot() != MPoint::origin) + if(primHasRotatePivot() || rotatePivot() != nullPoint) setRotatePivot(rotatePivot(), MSpace::kTransform, false); - if(primHasRotatePivotTranslate() || rotatePivotTranslation() != MVector::zero) + if(primHasRotatePivotTranslate() || rotatePivotTranslation() != nullVec) setRotatePivotTranslation(rotatePivotTranslation(), MSpace::kTransform); - if(primHasRotation() || rotation() != MQuaternion::identity) - rotateBy(MQuaternion::identity); + if(primHasRotation() || rotation() != nullQuat) + rotateBy(nullQuat); - if(primHasRotateAxes() || rotateOrientation() != MQuaternion::identity) + if(primHasRotateAxes() || rotateOrientation() != nullQuat) setRotateOrientation(rotateOrientation(), MSpace::kTransform, false); } else From 9f999224c4d6a81dbb43eadcb886eeec7603e5cc Mon Sep 17 00:00:00 2001 From: Paul Molodowitch Date: Thu, 6 Sep 2018 12:54:48 -0700 Subject: [PATCH 2/2] fix check for non-zero scalePivotTranslate when enableReadAnimatedValues is changed --- lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp b/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp index 8b93a0c0..d39a5788 100644 --- a/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp +++ b/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp @@ -1881,7 +1881,7 @@ void TransformationMatrix::enableReadAnimatedValues(bool enabled) if(primHasScalePivot() || scalePivot() != nullPoint) setScalePivot(scalePivot(), MSpace::kTransform, false); - if(primHasScalePivot() || scalePivot() != nullPoint) + if(primHasScalePivotTranslate() || scalePivotTranslation() != nullVec) setScalePivotTranslation(scalePivotTranslation(), MSpace::kTransform); if(primHasRotatePivot() || rotatePivot() != nullPoint) @@ -1950,7 +1950,7 @@ void TransformationMatrix::enablePushToPrim(bool enabled) if(primHasScalePivot() || scalePivot() != nullPoint) setScalePivot(scalePivot(), MSpace::kTransform, false); - if(primHasScalePivotTranslate() || scalePivotTranslation() != nullPoint) + if(primHasScalePivotTranslate() || scalePivotTranslation() != nullVec) setScalePivotTranslation(scalePivotTranslation(), MSpace::kTransform); if(primHasRotatePivot() || rotatePivot() != nullPoint)