[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/calligra/2.9] krita/plugins/paintops/libpaintop/sensors: BUG:339357 Time dynamic doesn't s
From: Aleksander Demko <ademko () gmail ! com>
Date: 2015-03-08 18:11:35
Message-ID: E1YUffr-00081L-63 () scm ! kde ! org
[Download RAW message or body]
Git commit 89dcd14eb5c0a41591bfe1f101a0c269c3082f36 by Aleksander Demko.
Committed on 08/03/2015 at 18:11.
Pushed by ademko into branch 'calligra/2.9'.
BUG:339357 Time dynamic doesn't start reliably
M +14 -5 krita/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_time.cc
http://commits.kde.org/calligra/89dcd14eb5c0a41591bfe1f101a0c269c3082f36
diff --git a/krita/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_time.cc \
b/krita/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_time.cc index \
115c501..b4ac2a4 100644
--- a/krita/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_time.cc
+++ b/krita/plugins/paintops/libpaintop/sensors/kis_dynamic_sensor_time.cc
@@ -24,7 +24,7 @@
#include "kis_paint_information.h"
-KisDynamicSensorTime::KisDynamicSensorTime() : KisDynamicSensor(TimeId), \
m_time(0.0), m_length(3 * 1000), m_periodic(true) \
+KisDynamicSensorTime::KisDynamicSensorTime() : KisDynamicSensor(TimeId), m_time(0), \
m_length(3 * 1000), m_periodic(true), m_lastTime(0) {
setMinimumLabel(i18n("0 s"));
setLength(3);
@@ -32,17 +32,26 @@ KisDynamicSensorTime::KisDynamicSensorTime() : \
KisDynamicSensor(TimeId), m_time(
qreal KisDynamicSensorTime::value(const KisPaintInformation& pi)
{
- m_time += pi.currentTime() - m_lastTime;
- m_lastTime = pi.currentTime();
+ qreal curtime = pi.currentTime();
+
+ if (curtime >= m_lastTime) {
+ m_time += curtime - m_lastTime;
+ } else {
+ // safely handle the situation when currentTime() < m_lastTime
+ m_time = 0;
+ }
+
+ m_lastTime = curtime;
+
if (m_time > m_length) {
if (m_periodic) {
- m_time = (int)fmod((float)m_time, (float)m_length);
+ m_time = m_time % m_length;
}
else {
m_time = m_length;
}
}
- return 1.0 - m_time / float(m_length);
+ return 1.0 - m_time / qreal(m_length);
}
void KisDynamicSensorTime::reset()
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic