Skip to content

Commit

Permalink
RotoStrokeItem: remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed Apr 8, 2021
1 parent 4e8727e commit 96e4e3a
Showing 1 changed file with 0 additions and 49 deletions.
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

0 comments on commit 96e4e3a

Please sign in to comment.