Commit ffc794b9 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Fix artifacts when rotation stylus sensor is activated

The angular stylus function is wrapped nead 2 * pi point
so we should use a bit more complicated algorithm to fix handle it

BUG:331358
parent 0e7cf00c
......@@ -326,7 +326,17 @@ KisPaintInformation KisPaintInformation::mix(const QPointF& p, qreal t, const Ki
qreal pressure = (1 - t) * pi1.pressure() + t * pi2.pressure();
qreal xTilt = (1 - t) * pi1.xTilt() + t * pi2.xTilt();
qreal yTilt = (1 - t) * pi1.yTilt() + t * pi2.yTilt();
qreal rotation = (1 - t) * pi1.rotation() + t * pi2.rotation();
qreal rotation = pi1.rotation();
if (pi1.rotation() != pi2.rotation()) {
qreal a1 = kisDegreesToRadians(pi1.rotation());
qreal a2 = kisDegreesToRadians(pi2.rotation());
qreal distance = shortestAngularDistance(a2, a1);
rotation = kisRadiansToDegrees(incrementInDirection(a1, t * distance, a2));
}
qreal tangentialPressure = (1 - t) * pi1.tangentialPressure() + t * pi2.tangentialPressure();
qreal perspective = (1 - t) * pi1.perspective() + t * pi2.perspective();
int time = (1 - t) * pi1.currentTime() + t * pi2.currentTime();
......
......@@ -89,6 +89,15 @@ inline qreal normalizeAngle(qreal a) {
return a > 2 * M_PI ? fmod(a, 2 * M_PI) : a;
}
// converts \p a to [0, 360.0) range
inline qreal normalizeAngleDegrees(qreal a) {
if (a < 0.0) {
a = 360.0 + fmod(a, 360.0);
}
return a > 360.0 ? fmod(a, 360.0) : a;
}
inline qreal shortestAngularDistance(qreal a, qreal b) {
qreal dist = fmod(qAbs(a - b), 2 * M_PI);
if (dist > M_PI) dist = 2 * M_PI - dist;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment