Skip to content

Commit

Permalink
Merge 96e4e3a into 6140190
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed Apr 8, 2021
2 parents 6140190 + 96e4e3a commit 3e46eb0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 57 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
- Tabs UI adjustments. #564
- Do not allow Python keywords as node name or scriptname. #588
- Always serialize nodes with an expression or a link, even if they have the default value. #585
- Support cloned group nodes or hard links between groups #568 #579 #594 #598
- Support cloned group nodes or hard links between groups. #568 #579 #594 #598
- Default keyframe interpolation method for strokes and shapes is now "Smooth" (was "Linear"). #597

### Plugins

Expand Down
14 changes: 8 additions & 6 deletions Engine/BezierCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

NATRON_NAMESPACE_ENTER

// Was eKeyframeTypeLinear until Natron 2.3.15.
#define BEZIER_KEYFRAME_INTERPOLATION_TYPE eKeyframeTypeSmooth

////////////////////////////////////ControlPoint////////////////////////////////////

Expand Down Expand Up @@ -112,15 +114,15 @@ BezierCP::setPositionAtTime(bool useGuiCurves,
{
{
KeyFrame k(time, x);
k.setInterpolation(eKeyframeTypeLinear);
k.setInterpolation(BEZIER_KEYFRAME_INTERPOLATION_TYPE);
if (!useGuiCurves) {
_imp->curveX->addKeyFrame(k);
}
_imp->guiCurveX->addKeyFrame(k);
}
{
KeyFrame k(time, y);
k.setInterpolation(eKeyframeTypeLinear);
k.setInterpolation(BEZIER_KEYFRAME_INTERPOLATION_TYPE);
if (!useGuiCurves) {
_imp->curveY->addKeyFrame(k);
}
Expand Down Expand Up @@ -267,7 +269,7 @@ BezierCP::setLeftBezierPointAtTime(bool useGuiCurves,
{
{
KeyFrame k(time, x);
k.setInterpolation(eKeyframeTypeLinear);
k.setInterpolation(BEZIER_KEYFRAME_INTERPOLATION_TYPE);
if (!useGuiCurves) {
_imp->curveLeftBezierX->addKeyFrame(k);
} else {
Expand All @@ -276,7 +278,7 @@ BezierCP::setLeftBezierPointAtTime(bool useGuiCurves,
}
{
KeyFrame k(time, y);
k.setInterpolation(eKeyframeTypeLinear);
k.setInterpolation(BEZIER_KEYFRAME_INTERPOLATION_TYPE);
if (!useGuiCurves) {
_imp->curveLeftBezierY->addKeyFrame(k);
} else {
Expand All @@ -293,15 +295,15 @@ BezierCP::setRightBezierPointAtTime(bool useGuiCurves,
{
{
KeyFrame k(time, x);
k.setInterpolation(eKeyframeTypeLinear);
k.setInterpolation(BEZIER_KEYFRAME_INTERPOLATION_TYPE);
if (!useGuiCurves) {
_imp->curveRightBezierX->addKeyFrame(k);
}
_imp->guiCurveRightBezierX->addKeyFrame(k);
}
{
KeyFrame k(time, y);
k.setInterpolation(eKeyframeTypeLinear);
k.setInterpolation(BEZIER_KEYFRAME_INTERPOLATION_TYPE);
if (!useGuiCurves) {
_imp->curveRightBezierY->addKeyFrame(k);
}
Expand Down
49 changes: 0 additions & 49 deletions Engine/RotoStrokeItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,55 +384,6 @@ RotoStrokeItem::appendPoint(bool newStroke,
_imp->lastTimestamp = t;
qDebug("t[%d]=%g", nk, t);

#if 0 // the following was disabled because it creates oscillations.

// if it's at least the 3rd point in curve, add intermediate point if
// the time since last keyframe is larger that the time to the previous one...
// This avoids overshooting when the pen suddenly stops, and restarts much later
if (nk >= 2) {
KeyFrame xp, xpp;
bool valid;
valid = _imp->xCurve.getKeyFrameWithIndex(nk - 1, &xp);
assert(valid);
valid = _imp->xCurve.getKeyFrameWithIndex(nk - 2, &xpp);
assert(valid);

double tp = xp.getTime();
double tpp = xpp.getTime();
if ( (t != tp) && (tp != tpp) && ( (t - tp) > (tp - tpp) ) ) {
//printf("adding extra keyframe, %g > %g\n", t - tp, tp - tpp);
// add a keyframe to avoid overshoot when the pen stops suddenly and starts again much later
KeyFrame yp, ypp;
valid = _imp->yCurve.getKeyFrameWithIndex(nk - 1, &yp);
assert(valid);
valid = _imp->yCurve.getKeyFrameWithIndex(nk - 2, &ypp);
assert(valid);
KeyFrame pp, ppp;
valid = _imp->pressureCurve.getKeyFrameWithIndex(nk - 1, &pp);
assert(valid);
valid = _imp->pressureCurve.getKeyFrameWithIndex(nk - 2, &ppp);
assert(valid);
double tn = tp + (tp - tpp);
KeyFrame xn, yn, pn;
double alpha = (tp - tpp) / (t - tp);
assert(0 < alpha && alpha < 1);
xn.setTime(tn);
yn.setTime(tn);
pn.setTime(tn);
xn.setValue(xp.getValue() * (1 - alpha) + p.pos.x * alpha);
yn.setValue(yp.getValue() * (1 - alpha) + p.pos.y * alpha);
pn.setValue(pp.getValue() * (1 - alpha) + p.pressure * alpha);
_imp->xCurve.addKeyFrame(xn);
_imp->xCurve.setKeyFrameInterpolation(eKeyframeTypeCatmullRom, nk);
_imp->yCurve.addKeyFrame(yn);
_imp->yCurve.setKeyFrameInterpolation(eKeyframeTypeCatmullRom, nk);
_imp->pressureCurve.addKeyFrame(pn);
_imp->pressureCurve.setKeyFrameInterpolation(eKeyframeTypeCatmullRom, nk);
++nk;
}
}
#endif

bool addKeyFrameOk; // did we add a new keyframe (normally yes, but just in case)
int ki; // index of the new keyframe (normally nk, but just in case)
{
Expand Down
2 changes: 1 addition & 1 deletion libs/OpenFX
Submodule OpenFX updated 152 files

0 comments on commit 3e46eb0

Please sign in to comment.