Commit 5cc071d4 authored by Damien de Lemeny's avatar Damien de Lemeny Committed by Dmitry Kazakov
Browse files

Values in KisPaintInformation are interpolated between event's paint info

for each dab, time should be decimal rather than integer to be correctly
interpolated on high velocity strokes.

Note : this patch is not enough to completely fix the speed sensor as
       KisPaintInformation's timestamps are still garbage.
parent f698373a
......@@ -67,7 +67,7 @@ struct KisPaintInformation::Private {
qreal rotation;
qreal tangentialPressure;
qreal perspective;
int time;
qreal time;
bool isHoveringMode;
QScopedPointer<qreal> drawingAngleOverride;
......@@ -101,7 +101,7 @@ KisPaintInformation::KisPaintInformation(const QPointF & pos_,
qreal rotation_,
qreal tangentialPressure_,
qreal perspective_,
int time)
qreal time)
: d(new Private)
{
d->pos = pos_;
......@@ -178,7 +178,7 @@ KisPaintInformation KisPaintInformation::fromXML(const QDomElement& e)
qreal perspective = qreal(e.attribute("perspective", "0.0").toDouble());
qreal xTilt = qreal(e.attribute("xTilt", "0.0").toDouble());
qreal yTilt = qreal(e.attribute("yTilt", "0.0").toDouble());
int time = e.attribute("time", "0").toInt();
qreal time = e.attribute("time", "0").toDouble();
return KisPaintInformation(QPointF(pointX, pointY), pressure, xTilt, yTilt,
rotation, tangentialPressure, perspective, time);
......@@ -280,7 +280,7 @@ qreal KisPaintInformation::drawingSpeed() const
return 0.5;
}
int timeDiff = currentTime() - d->currentDistanceInfo->lastTime();
qreal timeDiff = currentTime() - d->currentDistanceInfo->lastTime();
if (timeDiff <= 0) {
return 0.5;
......@@ -305,7 +305,7 @@ qreal KisPaintInformation::perspective() const
return d->perspective;
}
int KisPaintInformation::currentTime() const
qreal KisPaintInformation::currentTime() const
{
return d->time;
}
......@@ -369,7 +369,7 @@ KisPaintInformation KisPaintInformation::mix(const QPointF& p, qreal t, const Ki
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();
qreal time = (1 - t) * pi1.currentTime() + t * pi2.currentTime();
KisPaintInformation result(p, pressure, xTilt, yTilt, rotation, tangentialPressure, perspective, time);
KIS_ASSERT_RECOVER_NOOP(pi1.isHoveringMode() == pi2.isHoveringMode());
......
......@@ -85,7 +85,7 @@ public:
qreal rotation = 0.0,
qreal tangentialPressure = 0.0,
qreal perspective = 1.0,
int time = 0);
qreal time = 0.0);
KisPaintInformation(const KisPaintInformation& rhs);
......@@ -168,7 +168,7 @@ public:
qreal perspective() const;
/// Number of ms since the beginning of the stroke
int currentTime() const;
qreal currentTime() const;
/**
* The paint information may be generated not only during real
......
......@@ -31,7 +31,7 @@ struct KisDistanceInformation::Private {
QPointF distance;
KisSpacingInformation spacing;
QPointF lastPosition;
int lastTime;
qreal lastTime;
bool lastDabInfoValid;
KisPaintInformation lastPaintInformation;
......@@ -45,7 +45,7 @@ KisDistanceInformation::KisDistanceInformation()
}
KisDistanceInformation::KisDistanceInformation(const QPointF &lastPosition,
int lastTime)
qreal lastTime)
: m_d(new Private)
{
m_d->lastPosition = lastPosition;
......@@ -86,7 +86,7 @@ QPointF KisDistanceInformation::lastPosition() const
return m_d->lastPosition;
}
int KisDistanceInformation::lastTime() const
qreal KisDistanceInformation::lastTime() const
{
return m_d->lastTime;
}
......
......@@ -74,7 +74,7 @@ private:
class KRITAIMAGE_EXPORT KisDistanceInformation {
public:
KisDistanceInformation();
KisDistanceInformation(const QPointF &lastPosition, int lastTime);
KisDistanceInformation(const QPointF &lastPosition, qreal lastTime);
KisDistanceInformation(const KisDistanceInformation &rhs);
KisDistanceInformation& operator=(const KisDistanceInformation &rhs);
......@@ -83,7 +83,7 @@ public:
const KisSpacingInformation& currentSpacing() const;
bool hasLastDabInformation() const;
QPointF lastPosition() const;
int lastTime() const;
qreal lastTime() const;
qreal lastDrawingAngle() const;
bool hasLastPaintInformation() const;
......
......@@ -448,10 +448,10 @@ void KisToolFreehandHelper::paint(KoPointerEvent *event)
m_d->haveTangent = true;
m_d->previousTangent =
(info.pos() - m_d->previousPaintInformation.pos()) /
qMax(1, info.currentTime() - m_d->previousPaintInformation.currentTime());
qMax(1.0, info.currentTime() - m_d->previousPaintInformation.currentTime());
} else {
QPointF newTangent = (info.pos() - m_d->olderPaintInformation.pos()) /
qMax(1, info.currentTime() - m_d->olderPaintInformation.currentTime());
qMax(1.0, info.currentTime() - m_d->olderPaintInformation.currentTime());
paintBezierSegment(m_d->olderPaintInformation, m_d->previousPaintInformation,
m_d->previousTangent, newTangent);
......
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