Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Disregard repeated positions in speed smoother

Carsten Hartenfelse451439bfa05
diff --git a/libs/ui/tool/kis_speed_smoother.cpp b/libs/ui/tool/kis_speed_smoother.cpp
index 061ab053c9..7973701dae 100644
--- a/libs/ui/tool/kis_speed_smoother.cpp
+++ b/libs/ui/tool/kis_speed_smoother.cpp
@@ -106,8 +106,6 @@ void KisSpeedSmoother::updateSettings()
qreal KisSpeedSmoother::getNextSpeedImpl(const QPointF &pt, qreal time)
{
- const qreal dist = kisDistance(pt, m_d->lastPoint);
-
if (m_d->lastPoint.isNull()) {
m_d->lastPoint = pt;
m_d->lastTime = time;
@@ -115,6 +113,13 @@ qreal KisSpeedSmoother::getNextSpeedImpl(const QPointF &pt, qreal time)
return 0.0;
}
+ const qreal dist = kisDistance(pt, m_d->lastPoint);
+ // Getting the exact same position is bogus, it is probably just a previous
+ // point reported again. On Android, this happens all the time. Skip them.
+ if (qFuzzyIsNull(dist)) {
+ return m_d->lastSpeed;
+ }
+
const qreal timeDiff = time - m_d->lastTime;
m_d->timeDiffsMean.addValue(timeDiff);