OpenCoverage

qquickcustomaffector.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquickcustomaffector.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2QQuickCustomAffector::QQuickCustomAffector(QQuickItem *parent) :-
3 QQuickParticleAffector(parent)-
4 , m_position(&m_nullVector)-
5 , m_velocity(&m_nullVector)-
6 , m_acceleration(&m_nullVector)-
7 , m_relative(true)-
8{-
9}
executed 24 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickcustomaffector
  • tst_qquickparticlesystem
24
10-
11bool QQuickCustomAffector::isAffectConnected()-
12{-
13 do { QObject *sender = (this); void (QQuickCustomAffector::*signal)(QQmlV4Handle,qreal) = &QQuickCustomAffector::affectParticles; static QMetaMethod method = QMetaMethod::fromSignal(signal); static int signalIdx = QMetaObjectPrivate::signalIndex(method); return
executed 324 times by 1 test: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx);
Executed by:
  • tst_qquickcustomaffector
QObjectPrivate::get(sender)->isSignalConnected(signalIdx);
executed 324 times by 1 test: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx);
Executed by:
  • tst_qquickcustomaffector
} while (0);
324
14}
never executed: end of block
0
15-
16void QQuickCustomAffector::affectSystem(qreal dt)-
17{-
18-
19 bool justAffected = (m_acceleration == &m_nullVector
m_acceleration... &m_nullVectorDescription
TRUEevaluated 243 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 81 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
81-243
20 && m_velocity == &m_nullVector
m_velocity == &m_nullVectorDescription
TRUEevaluated 243 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEnever evaluated
0-243
21 && m_position == &m_nullVector
m_position == &m_nullVectorDescription
TRUEevaluated 161 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 82 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
82-161
22 && isAffectedConnected()
isAffectedConnected()Description
TRUEevaluated 82 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 79 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
);
79-82
23 if (!isAffectConnected()
!isAffectConnected()Description
TRUEevaluated 245 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 79 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
&& !justAffected
!justAffectedDescription
TRUEevaluated 163 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 82 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
) {
79-245
24 QQuickParticleAffector::affectSystem(dt);-
25 return;
executed 163 times by 1 test: return;
Executed by:
  • tst_qquickcustomaffector
163
26 }-
27 if (!m_enabled
!m_enabledDescription
TRUEnever evaluated
FALSEevaluated 161 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
)
0-161
28 return;
never executed: return;
0
29 updateOffsets();-
30-
31 QList<QQuickParticleData*> toAffect;-
32 for (auto _container_ = QtPrivate::qMakeForeachContainer(m_system->groupData); _container_.control
_container_.controlDescription
TRUEevaluated 322 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEnever evaluated
&& _container_.i != _container_.e
_container_.i != _container_.eDescription
TRUEevaluated 161 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 161 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
; ++_container_.i, _container_.control ^= 1) for (QQuickParticleGroupData* gd = *_container_.i; _container_.control
_container_.controlDescription
TRUEevaluated 161 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 161 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
; _container_.control = 0) {
0-322
33 if (activeGroup(gd->index)
activeGroup(gd->index)Description
TRUEevaluated 161 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEnever evaluated
) {
0-161
34 for (auto _container_ = QtPrivate::qMakeForeachContainer(gd->data); _container_.control
_container_.controlDescription
TRUEevaluated 80661 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEnever evaluated
&& _container_.i != _container_.e
_container_.i != _container_.eDescription
TRUEevaluated 80500 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 161 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
; ++_container_.i, _container_.control ^= 1) for (QQuickParticleData* d = *_container_.i; _container_.control
_container_.controlDescription
TRUEevaluated 80500 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 80500 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
; _container_.control = 0) {
0-80661
35 if (shouldAffect(d)
shouldAffect(d)Description
TRUEevaluated 2512 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 77988 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
) {
2512-77988
36 toAffect << d;-
37 }
executed 2512 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
2512
38 }
executed 80500 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
80500
39 }
executed 161 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
161
40 }
executed 161 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
161
41-
42 if (toAffect.isEmpty()
toAffect.isEmpty()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 157 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
)
4-157
43 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_qquickcustomaffector
4
44-
45 if (justAffected
justAffectedDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 77 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
) {
77-80
46 for (auto _container_ = QtPrivate::qMakeForeachContainer(toAffect); _container_.control
_container_.controlDescription
TRUEevaluated 1360 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEnever evaluated
&& _container_.i != _container_.e
_container_.i != _container_.eDescription
TRUEevaluated 1280 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
; ++_container_.i, _container_.control ^= 1) for (QQuickParticleData* d = *_container_.i; _container_.control
_container_.controlDescription
TRUEevaluated 1280 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 1280 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
; _container_.control = 0) {
0-1360
47 if (m_onceOff
m_onceOffDescription
TRUEevaluated 1280 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEnever evaluated
)
0-1280
48 m_onceOffed << qMakePair(d->groupId, d->index);
executed 1280 times by 1 test: m_onceOffed << qMakePair(d->groupId, d->index);
Executed by:
  • tst_qquickcustomaffector
1280
49 affected(d->curX(m_system), d->curY(m_system));-
50 }
executed 1280 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
1280
51 return;
executed 80 times by 1 test: return;
Executed by:
  • tst_qquickcustomaffector
80
52 }-
53-
54 if (m_onceOff
m_onceOffDescription
TRUEevaluated 77 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEnever evaluated
)
0-77
55 dt = 1.0;
executed 77 times by 1 test: dt = 1.0;
Executed by:
  • tst_qquickcustomaffector
77
56-
57 QQmlEngine *qmlEngine = ::qmlEngine(this);-
58 QV4::ExecutionEngine *v4 = qmlEngine->handle();-
59-
60 QV4::Scope scope(v4);-
61 QV4::ScopedArrayObject array(scope, v4->newArrayObject(toAffect.size()));-
62 QV4::ScopedValue v(scope);-
63 for (int i=0; i<toAffect.size()
i<toAffect.size()Description
TRUEevaluated 1232 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 77 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
; i++)
77-1232
64 array->put(i, (v = toAffect[i]->v4Value(m_system)));
executed 1232 times by 1 test: array->put(i, (v = toAffect[i]->v4Value(m_system)));
Executed by:
  • tst_qquickcustomaffector
1232
65-
66 if (dt >= simulationCutoff
dt >= simulationCutoffDescription
TRUEevaluated 77 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEnever evaluated
|| dt <= simulationDelta
dt <= simulationDeltaDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0-77
67 affectProperties(toAffect, dt);-
68 affectParticles(QQmlV4Handle(array), dt);-
69 }
executed 77 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
else {
77
70 int realTime = m_system->timeInt;-
71 m_system->timeInt -= dt * 1000.0;-
72 while (dt > simulationDelta
dt > simulationDeltaDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
73 m_system->timeInt += simulationDelta * 1000.0;-
74 dt -= simulationDelta;-
75 affectProperties(toAffect, simulationDelta);-
76 affectParticles(QQmlV4Handle(array), simulationDelta);-
77 }
never executed: end of block
0
78 m_system->timeInt = realTime;-
79 if (dt > 0.0
dt > 0.0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
80 affectProperties(toAffect, dt);-
81 affectParticles(QQmlV4Handle(array), dt);-
82 }
never executed: end of block
0
83 }
never executed: end of block
0
84-
85 for (auto _container_ = QtPrivate::qMakeForeachContainer(toAffect); _container_.control
_container_.controlDescription
TRUEevaluated 1309 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEnever evaluated
&& _container_.i != _container_.e
_container_.i != _container_.eDescription
TRUEevaluated 1232 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 77 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
; ++_container_.i, _container_.control ^= 1) for (QQuickParticleData* d = *_container_.i; _container_.control
_container_.controlDescription
TRUEevaluated 1232 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 1232 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
; _container_.control = 0)
0-1309
86 if (d->update == 1.0
d->update == 1.0Description
TRUEevaluated 1232 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEnever evaluated
)
0-1232
87 postAffect(d);
executed 1232 times by 1 test: postAffect(d);
Executed by:
  • tst_qquickcustomaffector
1232
88}
executed 77 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
77
89-
90bool QQuickCustomAffector::affectParticle(QQuickParticleData *d, qreal dt)-
91{-
92-
93 bool changed = false;-
94 QPointF curPos(d->curX(m_system), d->curY(m_system));-
95-
96 if (m_acceleration != &m_nullVector
m_acceleration... &m_nullVectorDescription
TRUEevaluated 24342 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 26072 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
){
24342-26072
97 QPointF pos = m_acceleration->sample(curPos);-
98 QPointF curAcc = QPointF(d->curAX(), d->curAY());-
99 if (m_relative
m_relativeDescription
TRUEnever evaluated
FALSEevaluated 24342 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
) {
0-24342
100 pos *= dt;-
101 pos += curAcc;-
102 }
never executed: end of block
0
103 if (pos != curAcc
pos != curAccDescription
TRUEevaluated 1264 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 23078 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
) {
1264-23078
104 d->setInstantaneousAX(pos.x(), m_system);-
105 d->setInstantaneousAY(pos.y(), m_system);-
106 changed = true;-
107 }
executed 1264 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
1264
108 }
executed 24342 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
24342
109-
110 if (m_velocity != &m_nullVector
m_velocity != &m_nullVectorDescription
TRUEevaluated 24342 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 26072 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
){
24342-26072
111 QPointF pos = m_velocity->sample(curPos);-
112 QPointF curVel = QPointF(d->curVX(m_system), d->curVY(m_system));-
113 if (m_relative
m_relativeDescription
TRUEnever evaluated
FALSEevaluated 24342 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
) {
0-24342
114 pos *= dt;-
115 pos += curVel;-
116 }
never executed: end of block
0
117 if (pos != curVel
pos != curVelDescription
TRUEevaluated 24342 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEnever evaluated
) {
0-24342
118 d->setInstantaneousVX(pos.x(), m_system);-
119 d->setInstantaneousVY(pos.y(), m_system);-
120 changed = true;-
121 }
executed 24342 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
24342
122 }
executed 24342 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
24342
123-
124 if (m_position != &m_nullVector
m_position != &m_nullVectorDescription
TRUEevaluated 49182 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 1232 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
){
1232-49182
125 QPointF pos = m_position->sample(curPos);-
126 if (m_relative
m_relativeDescription
TRUEnever evaluated
FALSEevaluated 49182 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
) {
0-49182
127 pos *= dt;-
128 pos += curPos;-
129 }
never executed: end of block
0
130 if (pos != curPos
pos != curPosDescription
TRUEevaluated 24342 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 24840 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
) {
24342-24840
131 d->setInstantaneousX(pos.x(), m_system);-
132 d->setInstantaneousY(pos.y(), m_system);-
133 changed = true;-
134 }
executed 24342 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
24342
135 }
executed 49182 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
49182
136-
137 return
executed 50414 times by 1 test: return changed;
Executed by:
  • tst_qquickcustomaffector
changed;
executed 50414 times by 1 test: return changed;
Executed by:
  • tst_qquickcustomaffector
50414
138}-
139-
140void QQuickCustomAffector::affectProperties(const QList<QQuickParticleData*> particles, qreal dt)-
141{-
142 for (auto _container_ = QtPrivate::qMakeForeachContainer(particles); _container_.control
_container_.controlDescription
TRUEevaluated 1309 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEnever evaluated
&& _container_.i != _container_.e
_container_.i != _container_.eDescription
TRUEevaluated 1232 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 77 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
; ++_container_.i, _container_.control ^= 1) for (QQuickParticleData* d = *_container_.i; _container_.control
_container_.controlDescription
TRUEevaluated 1232 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
FALSEevaluated 1232 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
; _container_.control = 0)
0-1309
143 if ( affectParticle(d, dt)
affectParticle(d, dt)Description
TRUEnever evaluated
FALSEevaluated 1232 times by 1 test
Evaluated by:
  • tst_qquickcustomaffector
)
0-1232
144 d->update = 1.0;
never executed: d->update = 1.0;
0
145}
executed 77 times by 1 test: end of block
Executed by:
  • tst_qquickcustomaffector
77
146-
147-
148-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0