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

A piece of PR183 - approximate equality checks #294

Merged
merged 1 commit into from Feb 24, 2020
Merged
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
64 changes: 52 additions & 12 deletions plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ void TransformationMatrix::initialiseToPrim(bool readFromPrim, Scope* transformN
MPlug(transformNode->thisMObject(), MPxTransform::shearXZ).setValue(tempShear.y);
MPlug(transformNode->thisMObject(), MPxTransform::shearYZ).setValue(tempShear.z);
m_shearTweak[0] = m_shearTweak[1] = m_shearTweak[2] = 0;
m_shearFromUsd = tempShear;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, this would be on it's own PR or at least commit - both because it's obviously different than the rest of the changes, and because it seems like an important enough bug fix to deserve splitting out.

Having said that - this does seem like a needed fix, and you've already been good enough to split things out into two separate commits, so I'm not going to hold things up over this.

}
}
}
Expand Down Expand Up @@ -1329,7 +1330,14 @@ MStatus TransformationMatrix::translateTo(const MVector& vector, MSpace::Space s
{
insertTranslateOp();
}
pushTranslateToPrim();

// Push new value to prim, but only if it's changing, otherwise extra work and unintended
// side effects will happen.
//
if (!vector.isEquivalent(m_translationFromUsd))
{
pushTranslateToPrim();
}
}
return status;
}
Expand Down Expand Up @@ -1377,7 +1385,11 @@ MStatus TransformationMatrix::scaleTo(const MVector& scale, MSpace::Space space)
// rare case: add a new scale op into the prim
insertScaleOp();
}
pushScaleToPrim();
// Push new value to prim, but only if it's changing.
if (!scale.isEquivalent(m_scaleFromUsd))
{
pushScaleToPrim();
}
}
return status;
}
Expand Down Expand Up @@ -1423,7 +1435,11 @@ MStatus TransformationMatrix::shearTo(const MVector& shear, MSpace::Space space)
// rare case: add a new scale op into the prim
insertShearOp();
}
pushShearToPrim();
// Push new value to prim, but only if it's changing.
if (!shear.isEquivalent(m_shearFromUsd))
{
pushShearToPrim();
}
}
return status;
}
Expand Down Expand Up @@ -1468,11 +1484,15 @@ MStatus TransformationMatrix::setScalePivot(const MPoint& sp, MSpace::Space spac
{
}
else
if(!pushPrimToMatrix() && sp != MPoint(0.0, 0.0, 0.0, 1.0))
if(!pushPrimToMatrix() && sp != MPoint(0.0, 0.0, 0.0))
{
insertScalePivotOp();
}
pushScalePivotToPrim();
// Push new value to prim, but only if it's changing.
if (!sp.isEquivalent(m_scalePivotFromUsd))
{
pushScalePivotToPrim();
}
}
return status;
}
Expand Down Expand Up @@ -1512,7 +1532,11 @@ MStatus TransformationMatrix::setScalePivotTranslation(const MVector& sp, MSpace
{
insertScalePivotTranslationOp();
}
pushScalePivotTranslateToPrim();
// Push new value to prim, but only if it's changing.
if (!sp.isEquivalent(m_scalePivotTranslationFromUsd))
{
pushScalePivotTranslateToPrim();
}
}
return status;
}
Expand Down Expand Up @@ -1557,11 +1581,15 @@ MStatus TransformationMatrix::setRotatePivot(const MPoint& pivot, MSpace::Space
{
}
else
if(!pushPrimToMatrix() && pivot != MPoint(0.0, 0.0, 0.0, 1.0))
if(!pushPrimToMatrix() && pivot != MPoint(0.0, 0.0, 0.0))
{
insertRotatePivotOp();
}
pushRotatePivotToPrim();
// Push new value to prim, but only if it's changing.
if (!pivot.isEquivalent(m_rotatePivotFromUsd))
{
pushRotatePivotToPrim();
}
}
return status;
}
Expand Down Expand Up @@ -1597,11 +1625,15 @@ MStatus TransformationMatrix::setRotatePivotTranslation(const MVector &vector, M
{
}
else
if(!pushPrimToMatrix() && vector != MPoint(0.0, 0.0, 0.0, 1.0))
if(!pushPrimToMatrix() && vector != MVector(0.0, 0.0, 0.0))
{
insertRotatePivotTranslationOp();
}
pushRotatePivotTranslateToPrim();
// Push new value to prim, but only if it's changing.
if (!vector.isEquivalent(m_rotatePivotTranslationFromUsd))
{
pushRotatePivotTranslateToPrim();
}
}
return status;
}
Expand Down Expand Up @@ -1680,7 +1712,11 @@ MStatus TransformationMatrix::rotateTo(const MQuaternion &q, MSpace::Space space
}
if(m_enableUsdWriteback)
{
pushRotateToPrim();
// Push new value to prim, but only if it's changing.
if (!MPxTransformationMatrix::rotationValue.isEquivalent(m_rotationFromUsd))
{
pushRotateToPrim();
}
}
}
return status;
Expand Down Expand Up @@ -1711,7 +1747,11 @@ MStatus TransformationMatrix::rotateTo(const MEulerRotation &e, MSpace::Space sp
}
if(m_enableUsdWriteback)
{
pushRotateToPrim();
// Push new value to prim, but only if it's changing.
if (!e.isEquivalent(m_rotationFromUsd))
{
pushRotateToPrim();
}
}
}
return status;
Expand Down