aboutsummaryrefslogtreecommitdiffstats
path: root/src/particles
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-02-13 12:02:19 +0100
committerSean Harmer <sean.harmer@kdab.com>2015-02-19 10:49:03 +0000
commit373ce8878321aa561b55131bada78ad4a2ce8427 (patch)
tree0b64429ea79163f1f13b4073bbe60040047d0540 /src/particles
parent6f264b755501fd322d1e357187b42120210a7ba3 (diff)
Cleanup math function includes and usage
Use std::math on floats and doubles, and qMath on qreals, and only include the math headers actually needed. Change-Id: I1d511d7b1bac0050eaa947c7baee760b736858bf Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/particles')
-rw-r--r--src/particles/qquickangledirection.cpp10
-rw-r--r--src/particles/qquickellipseextruder.cpp10
-rw-r--r--src/particles/qquickfriction.cpp12
-rw-r--r--src/particles/qquickv4particledata.cpp2
4 files changed, 14 insertions, 20 deletions
diff --git a/src/particles/qquickangledirection.cpp b/src/particles/qquickangledirection.cpp
index 81c92f8bfa..3fa5d21108 100644
--- a/src/particles/qquickangledirection.cpp
+++ b/src/particles/qquickangledirection.cpp
@@ -33,10 +33,8 @@
#include "qquickangledirection_p.h"
#include <stdlib.h>
-#include <cmath>
-#ifdef Q_OS_QNX
-#include <math.h>
-#endif
+#include <qmath.h>
+
QT_BEGIN_NAMESPACE
const qreal CONV = 0.017453292519943295;
/*!
@@ -106,8 +104,8 @@ const QPointF QQuickAngleDirection::sample(const QPointF &from)
QPointF ret;
qreal theta = m_angle*CONV - m_angleVariation*CONV + rand()/float(RAND_MAX) * m_angleVariation*CONV * 2;
qreal mag = m_magnitude- m_magnitudeVariation + rand()/float(RAND_MAX) * m_magnitudeVariation * 2;
- ret.setX(mag * cos(theta));
- ret.setY(mag * sin(theta));
+ ret.setX(mag * qCos(theta));
+ ret.setY(mag * qSin(theta));
return ret;
}
diff --git a/src/particles/qquickellipseextruder.cpp b/src/particles/qquickellipseextruder.cpp
index cc854b8362..6d4e25197f 100644
--- a/src/particles/qquickellipseextruder.cpp
+++ b/src/particles/qquickellipseextruder.cpp
@@ -32,12 +32,8 @@
****************************************************************************/
#include "qquickellipseextruder_p.h"
+#include <qmath.h>
#include <stdlib.h>
-#include <cmath>
-
-#ifdef Q_OS_QNX
-#include <math.h>
-#endif
QT_BEGIN_NAMESPACE
/*!
@@ -68,8 +64,8 @@ QPointF QQuickEllipseExtruder::extrude(const QRectF & r)
{
qreal theta = ((qreal)rand()/RAND_MAX) * 6.2831853071795862;
qreal mag = m_fill ? ((qreal)rand()/RAND_MAX) : 1;
- return QPointF(r.x() + r.width()/2 + mag * (r.width()/2) * cos(theta),
- r.y() + r.height()/2 + mag * (r.height()/2) * sin(theta));
+ return QPointF(r.x() + r.width()/2 + mag * (r.width()/2) * qCos(theta),
+ r.y() + r.height()/2 + mag * (r.height()/2) * qSin(theta));
}
bool QQuickEllipseExtruder::contains(const QRectF &bounds, const QPointF &point)
diff --git a/src/particles/qquickfriction.cpp b/src/particles/qquickfriction.cpp
index 84f6d5a80d..8f46575e1c 100644
--- a/src/particles/qquickfriction.cpp
+++ b/src/particles/qquickfriction.cpp
@@ -32,7 +32,7 @@
****************************************************************************/
#include "qquickfriction_p.h"
-#include <math.h>
+#include <qmath.h>
QT_BEGIN_NAMESPACE
/*!
@@ -87,16 +87,16 @@ bool QQuickFrictionAffector::affectParticle(QQuickParticleData *d, qreal dt)
if (sign(curVY) != sign(newVY))
newVY = 0;
} else {
- qreal curMag = sqrt(curVX*curVX + curVY*curVY);
+ qreal curMag = qSqrt(curVX*curVX + curVY*curVY);
if (curMag <= m_threshold + epsilon)
return false;
- qreal newMag = sqrt(newVX*newVX + newVY*newVY);
+ qreal newMag = qSqrt(newVX*newVX + newVY*newVY);
if (newMag <= m_threshold + epsilon || //went past the threshold, stop there instead
sign(curVX) != sign(newVX) || //went so far past maybe it came out the other side!
sign(curVY) != sign(newVY)) {
- qreal theta = atan2(curVY, curVX);
- newVX = m_threshold * cos(theta);
- newVY = m_threshold * sin(theta);
+ qreal theta = qAtan2(curVY, curVX);
+ newVX = m_threshold * qCos(theta);
+ newVY = m_threshold * qSin(theta);
}
}
diff --git a/src/particles/qquickv4particledata.cpp b/src/particles/qquickv4particledata.cpp
index 08953fd490..fcab455cce 100644
--- a/src/particles/qquickv4particledata.cpp
+++ b/src/particles/qquickv4particledata.cpp
@@ -338,7 +338,7 @@ static QV4::ReturnedValue particleData_set_ ## NAME (QV4::CallContext *ctx)\
ctx->engine()->throwError(QStringLiteral("Not a valid ParticleData object"));\
\
double d = ctx->argc() ? ctx->args()[0].toNumber() : 0; \
- r->d()->datum->color. VAR = qMin(255, qMax(0, (int)floor(d * 255.0)));\
+ r->d()->datum->color. VAR = qMin(255, qMax(0, (int)::floor(d * 255.0)));\
return QV4::Encode::undefined(); \
}