diff --git a/Card3D/Card3D.cpp b/Card3D/Card3D.cpp index bcadd849..a361e6dd 100644 --- a/Card3D/Card3D.cpp +++ b/Card3D/Card3D.cpp @@ -2001,7 +2001,10 @@ Card3DPlugin::changedParam(const InstanceChangedArgs &args, { //const double time = args.time; if ( (paramName == kParamPremult) && (args.reason == eChangeUserEdit) ) { - _srcClipChanged->setValue(true); + // Only set if necessary + if (!_srcClipChanged->getValue()) { + _srcClipChanged->setValue(true); + } } else if (paramName == kParamCamEnable) { updateVisibility(); } else if (paramName == kParamOutputFormat) { diff --git a/GodRays/GodRays.cpp b/GodRays/GodRays.cpp index 6b790d2e..2fea49f6 100644 --- a/GodRays/GodRays.cpp +++ b/GodRays/GodRays.cpp @@ -713,6 +713,7 @@ GodRaysPlugin::getInverseTransformCanonical(double time, void GodRaysPlugin::resetCenter(double time) { + // Note: same code as TransformPlugin::resetCenter() if (!_srcClip || !_srcClip->isConnected()) { return; } @@ -774,28 +775,36 @@ GodRaysPlugin::resetCenter(double time) OfxPointD newCenter; newCenter.x = (rod.x1 + rod.x2) / 2; newCenter.y = (rod.y1 + rod.y2) / 2; - EditBlock eb(*this, "resetCenter"); - if (_center) { - _center->setValue(newCenter.x, newCenter.y); - } - if (_translate) { - double dxrot = newCenter.x - center.x; - double dyrot = newCenter.y - center.y; - Point3D dRot; - dRot.x = dxrot; - dRot.y = dyrot; - dRot.z = 1; - dRot = Rinv * dRot; - if (dRot.z != 0) { - dRot.x /= dRot.z; - dRot.y /= dRot.z; + if (newCenter.x != center.x || newCenter.y != center.y) { + bool editBlockNecessary = false; + OfxPointD newTranslate = {0., 0.}; + if (_translate) { + double dxrot = newCenter.x - center.x; + double dyrot = newCenter.y - center.y; + Point3D dRot; + dRot.x = dxrot; + dRot.y = dyrot; + dRot.z = 1; + dRot = Rinv * dRot; + if (dRot.z != 0) { + dRot.x /= dRot.z; + dRot.y /= dRot.z; + } + double dx = dRot.x; + double dy = dRot.y; + newTranslate.x = translate.x + dx - dxrot; + newTranslate.y = translate.y + dy - dyrot; + if (newTranslate.x != translate.x || newTranslate.y != translate.y) { + editBlockNecessary = true; + } + } + EditBlock eb(*this, "resetCenter", editBlockNecessary); + if (_center) { + _center->setValue(newCenter.x, newCenter.y); + } + if (_translate) { + _translate->setValue(newTranslate.x, newTranslate.y); } - double dx = dRot.x; - double dy = dRot.y; - OfxPointD newTranslate; - newTranslate.x = translate.x + dx - dxrot; - newTranslate.y = translate.y + dy - dyrot; - _translate->setValue(newTranslate.x, newTranslate.y); } } // GodRaysPlugin::resetCenter @@ -805,7 +814,10 @@ GodRaysPlugin::changedParam(const InstanceChangedArgs &args, { if (paramName == kParamTransformResetCenterOld) { resetCenter(args.time); - _centerChanged->setValue(false); + // Only set if necessary + if (_centerChanged->getValue()) { + _centerChanged->setValue(false); + } } else if ( (paramName == kParamTransformTranslateOld) || ( paramName == kParamTransformRotateOld) || ( paramName == kParamTransformScaleOld) || @@ -816,7 +828,10 @@ GodRaysPlugin::changedParam(const InstanceChangedArgs &args, ( paramName == kParamTransformCenterOld) ) { if ( (paramName == kParamTransformCenterOld) && ( (args.reason == eChangeUserEdit) || (args.reason == eChangePluginEdit) ) ) { - _centerChanged->setValue(true); + // Only set if necessary + if (!_centerChanged->getValue()) { + _centerChanged->setValue(true); + } } changedTransform(args); } else if ( (paramName == kParamPremult) && (args.reason == eChangeUserEdit) ) { diff --git a/SupportExt b/SupportExt index fcd777bb..8aff0b0a 160000 --- a/SupportExt +++ b/SupportExt @@ -1 +1 @@ -Subproject commit fcd777bb2b3ca00def5e5693cbf09f8df9e2304b +Subproject commit 8aff0b0ae59f50fd9a06abb560367ef7534730cf diff --git a/Transform/Transform.cpp b/Transform/Transform.cpp index 83f09b5a..57ad5488 100644 --- a/Transform/Transform.cpp +++ b/Transform/Transform.cpp @@ -330,28 +330,36 @@ TransformPlugin::resetCenter(double time) OfxPointD newCenter; newCenter.x = (rod.x1 + rod.x2) / 2; newCenter.y = (rod.y1 + rod.y2) / 2; - EditBlock eb(*this, "resetCenter"); - if (_center) { - _center->setValue(newCenter.x, newCenter.y); - } - if (_translate) { - double dxrot = newCenter.x - center.x; - double dyrot = newCenter.y - center.y; - Point3D dRot; - dRot.x = dxrot; - dRot.y = dyrot; - dRot.z = 1; - dRot = Rinv * dRot; - if (dRot.z != 0) { - dRot.x /= dRot.z; - dRot.y /= dRot.z; + if (newCenter.x != center.x || newCenter.y != center.y) { + bool editBlockNecessary = false; + OfxPointD newTranslate = {0., 0.}; + if (_translate) { + double dxrot = newCenter.x - center.x; + double dyrot = newCenter.y - center.y; + Point3D dRot; + dRot.x = dxrot; + dRot.y = dyrot; + dRot.z = 1; + dRot = Rinv * dRot; + if (dRot.z != 0) { + dRot.x /= dRot.z; + dRot.y /= dRot.z; + } + double dx = dRot.x; + double dy = dRot.y; + newTranslate.x = translate.x + dx - dxrot; + newTranslate.y = translate.y + dy - dyrot; + if (newTranslate.x != translate.x || newTranslate.y != translate.y) { + editBlockNecessary = true; + } + } + EditBlock eb(*this, "resetCenter", editBlockNecessary); + if (_center) { + _center->setValue(newCenter.x, newCenter.y); + } + if (_translate) { + _translate->setValue(newTranslate.x, newTranslate.y); } - double dx = dRot.x; - double dy = dRot.y; - OfxPointD newTranslate; - newTranslate.x = translate.x + dx - dxrot; - newTranslate.y = translate.y + dy - dyrot; - _translate->setValue(newTranslate.x, newTranslate.y); } } // TransformPlugin::resetCenter @@ -361,7 +369,10 @@ TransformPlugin::changedParam(const InstanceChangedArgs &args, { if (paramName == kParamTransformResetCenterOld) { resetCenter(args.time); - _centerChanged->setValue(false); + // Only set if necessary + if (_centerChanged->getValue()) { + _centerChanged->setValue(false); + } } else if ( (paramName == kParamTransformTranslateOld) || ( paramName == kParamTransformRotateOld) || ( paramName == kParamTransformScaleOld) || @@ -372,11 +383,17 @@ TransformPlugin::changedParam(const InstanceChangedArgs &args, ( paramName == kParamTransformCenterOld) ) { if ( (paramName == kParamTransformCenterOld) && ( (args.reason == eChangeUserEdit) || (args.reason == eChangePluginEdit) ) ) { - _centerChanged->setValue(true); + // Only set if necessary + if (!_centerChanged->getValue()) { + _centerChanged->setValue(true); + } } changedTransform(args); } else if ( (paramName == kParamPremult) && (args.reason == eChangeUserEdit) ) { - _srcClipChanged->setValue(true); + // Only set if necessary + if (!_srcClipChanged->getValue()) { + _srcClipChanged->setValue(true); + } } else { Transform3x3Plugin::changedParam(args, paramName); } @@ -388,7 +405,7 @@ TransformPlugin::changedClip(const InstanceChangedArgs &args, { if ( (clipName == kOfxImageEffectSimpleSourceClipName) && _srcClip && _srcClip->isConnected() && - !_centerChanged->getValueAtTime(args.time) && + !_centerChanged->getValue() && ( args.reason == eChangeUserEdit) ) { resetCenter(args.time); }