OpenCoverage

qquickparticleaffector.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquickparticleaffector.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQuick module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qquickparticleaffector_p.h"-
41#include <QDebug>-
42#include <private/qqmlglobal_p.h>-
43QT_BEGIN_NAMESPACE-
44-
45/*!-
46 \qmltype Affector-
47 \instantiates QQuickParticleAffector-
48 \inqmlmodule QtQuick.Particles-
49 \brief Applies alterations to the attributes of logical particles at any-
50 point in their lifetime.-
51 \ingroup qtquick-particles-
52-
53 The base Affector does not alter any attributes, but can be used to emit a signal-
54 when a particle meets certain conditions.-
55-
56 If an affector has a defined size, then it will only affect particles within its size and position on screen.-
57-
58 Affectors have different performance characteristics to the other particle system elements. In particular,-
59 they have some simplifications to try to maintain a simulation at real-time or faster. When running a system-
60 with Affectors, irregular frame timings that grow too large ( > one second per frame) will cause the Affectors-
61 to try and cut corners with a faster but less accurate simulation. If the system has multiple affectors the order-
62 in which they are applied is not guaranteed, and when simulating larger time shifts they will simulate the whole-
63 shift each, which can lead to different results compared to smaller time shifts.-
64-
65 Accurate simulation for large numbers of particles (hundreds) with multiple affectors may be possible on some hardware,-
66 but on less capable hardware you should expect small irregularties in the simulation as simulates with worse granularity.-
67*/-
68/*!-
69 \qmlproperty ParticleSystem QtQuick.Particles::Affector::system-
70 This is the system which will be affected by the element.-
71 If the Affector is a direct child of a ParticleSystem, it will automatically be associated with it.-
72*/-
73/*!-
74 \qmlproperty list<string> QtQuick.Particles::Affector::groups-
75 Which logical particle groups will be affected.-
76-
77 If empty, it will affect all particles.-
78*/-
79/*!-
80 \qmlproperty list<string> QtQuick.Particles::Affector::whenCollidingWith-
81 If any logical particle groups are specified here, then the affector-
82 will only be triggered if the particle being examined intersects with-
83 a particle of one of these groups.-
84-
85 This is different from the groups property. The groups property selects which-
86 particles might be examined, and if they meet other criteria (including being-
87 within the bounds of the Affector, modified by shape) then they will be tested-
88 again to see if they intersect with a particles from one of the particle groups-
89 in whenCollidingWith.-
90-
91 By default, no groups are specified.-
92*/-
93/*!-
94 \qmlproperty bool QtQuick.Particles::Affector::enabled-
95 If enabled is set to false, this affector will not affect any particles.-
96-
97 Usually this is used to conditionally turn an affector on or off.-
98-
99 Default value is true.-
100*/-
101/*!-
102 \qmlproperty bool QtQuick.Particles::Affector::once-
103 If once is set to true, this affector will only affect each particle-
104 once in their lifetimes. If the affector normally simulates a continuous-
105 effect over time, then it will simulate the effect of one second of time-
106 the one instant it affects the particle.-
107-
108 Default value is false.-
109*/-
110/*!-
111 \qmlproperty Shape QtQuick.Particles::Affector::shape-
112 If a size has been defined, the shape property can be used to affect a-
113 non-rectangular area.-
114*/-
115/*!-
116 \qmlsignal QtQuick.Particles::Affector::affected(real x, real y)-
117-
118 This signal is emitted when a particle is selected to be affected. It will not be emitted-
119 if a particle is considered by the Affector but not actually altered in any way.-
120-
121 In the special case where an Affector has no possible effect (e.g. Affector {}), this signal-
122 will be emitted for all particles being considered if you connect to it. This allows you to-
123 execute arbitrary code in response to particles (use the Affector::onAffectParticles-
124 signal handler if you want to execute code which affects the particles-
125 themselves). As this executes JavaScript code per particle, it is not recommended to use this-
126 signal with a high-volume particle system.-
127-
128 x,y is the particle's current position.-
129-
130 The corresponding handler is \c onAffected.-
131*/-
132QQuickParticleAffector::QQuickParticleAffector(QQuickItem *parent) :-
133 QQuickItem(parent), m_needsReset(false), m_ignoresTime(false), m_onceOff(false), m_enabled(true)-
134 , m_system(nullptr), m_updateIntSet(false), m_shape(new QQuickParticleExtruder(this))-
135{-
136}
executed 94 times by 11 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
94
137-
138bool QQuickParticleAffector::isAffectedConnected()-
139{-
140 IS_SIGNAL_CONNECTED(this, QQuickParticleAffector, affected, (qreal,qreal));
executed 171823 times by 9 tests: return QObjectPrivate::get(sender)->isSignalConnected(signalIdx);
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
171823
141}
never executed: end of block
0
142-
143-
144void QQuickParticleAffector::componentComplete()-
145{-
146 if (!m_system && qobject_cast<QQuickParticleSystem*>(parentItem()))
!m_systemDescription
TRUEevaluated 62 times by 11 tests
Evaluated by:
  • tst_examples
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_examples
qobject_cast<Q...(parentItem())Description
TRUEevaluated 62 times by 11 tests
Evaluated by:
  • tst_examples
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
FALSEnever evaluated
0-62
147 setSystem(qobject_cast<QQuickParticleSystem*>(parentItem()));
executed 62 times by 11 tests: setSystem(qobject_cast<QQuickParticleSystem*>(parentItem()));
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
62
148 QQuickItem::componentComplete();-
149}
executed 94 times by 11 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
94
150-
151bool QQuickParticleAffector::activeGroup(int g) {-
152 if (m_updateIntSet){ //This can occur before group ids are properly assigned, but that resets the flag
m_updateIntSetDescription
TRUEevaluated 34 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
FALSEevaluated 726824 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
34-726824
153 m_groupIds.clear();-
154 foreach (const QString &p, m_groups)
_container_.controlDescription
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_qquickfriction
  • tst_qquickgroupgoal
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_qquickfriction
  • tst_qquickgroupgoal
_container_.controlDescription
TRUEevaluated 38 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
FALSEnever evaluated
_container_.i != _container_.eDescription
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_qquickfriction
  • tst_qquickgroupgoal
FALSEevaluated 34 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
0-38
155 m_groupIds << m_system->groupIds[p];
executed 4 times by 2 tests: m_groupIds << m_system->groupIds[p];
Executed by:
  • tst_qquickfriction
  • tst_qquickgroupgoal
4
156 m_updateIntSet = false;-
157 }
executed 34 times by 9 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
34
158 return m_groupIds.isEmpty() || m_groupIds.contains(g);
executed 726858 times by 9 tests: return m_groupIds.isEmpty() || m_groupIds.contains(g);
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
726858
159}-
160-
161bool QQuickParticleAffector::shouldAffect(QQuickParticleData* d)-
162{-
163 if (!d)
!dDescription
TRUEnever evaluated
FALSEevaluated 718940 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
0-718940
164 return false;
never executed: return false;
0
165 if (activeGroup(d->groupId)){
activeGroup(d->groupId)Description
TRUEevaluated 718940 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
FALSEnever evaluated
0-718940
166 if ((m_onceOff && m_onceOffed.contains(qMakePair(d->groupId, d->index)))
m_onceOffDescription
TRUEevaluated 202500 times by 2 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
FALSEevaluated 516440 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
m_onceOffed.co...Id, d->index))Description
TRUEevaluated 91881 times by 2 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
FALSEevaluated 110619 times by 2 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
91881-516440
167 || !d->stillAlive(m_system))
!d->stillAlive(m_system)Description
TRUEevaluated 336957 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
FALSEevaluated 290102 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
290102-336957
168 return false;
executed 428838 times by 9 tests: return false;
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
428838
169 //Need to have previous location for affected anyways-
170 if (width() == 0 || height() == 0
width() == 0Description
TRUEevaluated 266258 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
FALSEevaluated 23844 times by 1 test
Evaluated by:
  • tst_qquickturbulence
height() == 0Description
TRUEnever evaluated
FALSEevaluated 23844 times by 1 test
Evaluated by:
  • tst_qquickturbulence
0-266258
171 || m_shape->contains(QRectF(m_offset.x(), m_offset.y(), width(), height()), QPointF(d->curX(m_system), d->curY(m_system)))){
m_shape->conta...rY(m_system)))Description
TRUEevaluated 23844 times by 1 test
Evaluated by:
  • tst_qquickturbulence
FALSEnever evaluated
0-23844
172 if (m_whenCollidingWith.isEmpty() || isColliding(d)){
m_whenCollidingWith.isEmpty()Description
TRUEevaluated 290102 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
FALSEnever evaluated
isColliding(d)Description
TRUEnever evaluated
FALSEnever evaluated
0-290102
173 return true;
executed 290102 times by 9 tests: return true;
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
290102
174 }-
175 }
never executed: end of block
0
176 }
never executed: end of block
0
177 return false;
never executed: return false;
0
178-
179}-
180-
181void QQuickParticleAffector::postAffect(QQuickParticleData* d)-
182{-
183 m_system->needsReset << d;-
184 if (m_onceOff)
m_onceOffDescription
TRUEevaluated 3760 times by 2 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
FALSEevaluated 167902 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
3760-167902
185 m_onceOffed << qMakePair(d->groupId, d->index);
executed 3760 times by 2 tests: m_onceOffed << qMakePair(d->groupId, d->index);
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
3760
186 if (isAffectedConnected())
isAffectedConnected()Description
TRUEnever evaluated
FALSEevaluated 171662 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
0-171662
187 emit affected(d->curX(m_system), d->curY(m_system));
never executed: affected(d->curX(m_system), d->curY(m_system));
0
188}
executed 171662 times by 9 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
171662
189-
190const qreal QQuickParticleAffector::simulationDelta = 0.020;-
191const qreal QQuickParticleAffector::simulationCutoff = 1.000;//If this goes above 1.0, then m_once behaviour needs special codepath-
192-
193void QQuickParticleAffector::affectSystem(qreal dt)-
194{-
195 if (!m_enabled)
!m_enabledDescription
TRUEnever evaluated
FALSEevaluated 1116 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
0-1116
196 return;
never executed: return;
0
197 //If not reimplemented, calls affectParticle per particle-
198 //But only on particles in targeted system/area-
199 updateOffsets();//### Needed if an ancestor is transformed.-
200 if (m_onceOff)
m_onceOffDescription
TRUEevaluated 244 times by 2 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
FALSEevaluated 872 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
244-872
201 dt = 1.0;
executed 244 times by 2 tests: dt = 1.0;
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
244
202 foreach (QQuickParticleGroupData* gd, m_system->groupData) {
_container_.controlDescription
TRUEevaluated 1357 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
FALSEevaluated 1357 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
_container_.controlDescription
TRUEevaluated 2473 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
FALSEnever evaluated
_container_.i != _container_.eDescription
TRUEevaluated 1357 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
FALSEevaluated 1116 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
0-2473
203 if (activeGroup(gd->index)) {
activeGroup(gd->index)Description
TRUEevaluated 1194 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
FALSEevaluated 163 times by 2 tests
Evaluated by:
  • tst_qquickfriction
  • tst_qquickgroupgoal
163-1194
204 foreach (QQuickParticleData* d, gd->data) {
_container_.controlDescription
TRUEevaluated 598440 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
FALSEevaluated 598440 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
_container_.controlDescription
TRUEevaluated 599634 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
FALSEnever evaluated
_container_.i != _container_.eDescription
TRUEevaluated 598440 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
FALSEevaluated 1194 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
0-599634
205 if (shouldAffect(d)) {
shouldAffect(d)Description
TRUEevaluated 263746 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
FALSEevaluated 334694 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
263746-334694
206 bool affected = false;-
207 qreal myDt = dt;-
208 if (!m_ignoresTime && myDt < simulationCutoff) {
!m_ignoresTimeDescription
TRUEevaluated 240070 times by 6 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickpointattractor
  • tst_qquickwander
FALSEevaluated 23676 times by 2 tests
Evaluated by:
  • tst_qquickgroupgoal
  • tst_qquickspritegoal
myDt < simulationCutoffDescription
TRUEevaluated 212702 times by 6 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickpointattractor
  • tst_qquickwander
FALSEevaluated 27368 times by 2 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
23676-240070
209 int realTime = m_system->timeInt;-
210 m_system->timeInt -= myDt * 1000.0;-
211 while (myDt > simulationDelta) {
myDt > simulationDeltaDescription
TRUEnever evaluated
FALSEevaluated 212702 times by 6 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickpointattractor
  • tst_qquickwander
0-212702
212 m_system->timeInt += simulationDelta * 1000.0;-
213 if (d->alive(m_system))//Only affect during the parts it was alive for
d->alive(m_system)Description
TRUEnever evaluated
FALSEnever evaluated
0
214 affected = affectParticle(d, simulationDelta) || affected;
never executed: affected = affectParticle(d, simulationDelta) || affected;
affectParticle...mulationDelta)Description
TRUEnever evaluated
FALSEnever evaluated
affectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
215 myDt -= simulationDelta;-
216 }
never executed: end of block
0
217 m_system->timeInt = realTime;-
218 }
executed 212702 times by 6 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickpointattractor
  • tst_qquickwander
212702
219 if (myDt > 0.0)
myDt > 0.0Description
TRUEevaluated 263746 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
FALSEnever evaluated
0-263746
220 affected = affectParticle(d, myDt) || affected;
executed 263746 times by 8 tests: affected = affectParticle(d, myDt) || affected;
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
affectParticle(d, myDt)Description
TRUEevaluated 149722 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
FALSEevaluated 114024 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickspritegoal
affectedDescription
TRUEnever evaluated
FALSEevaluated 114024 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickspritegoal
0-263746
221 if (affected)
affectedDescription
TRUEevaluated 149722 times by 8 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
FALSEevaluated 114024 times by 3 tests
Evaluated by:
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickspritegoal
114024-149722
222 postAffect(d);
executed 149722 times by 8 tests: postAffect(d);
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
149722
223 }
executed 263746 times by 8 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
263746
224 }
executed 598440 times by 8 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
598440
225 }
executed 1194 times by 8 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
1194
226 }
executed 1357 times by 8 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
1357
227}
executed 1116 times by 8 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickwander
1116
228-
229bool QQuickParticleAffector::affectParticle(QQuickParticleData *, qreal )-
230{-
231 return true;
never executed: return true;
0
232}-
233-
234void QQuickParticleAffector::reset(QQuickParticleData* pd)-
235{//TODO: This, among other ones, should be restructured so they don't all need to remember to call the superclass-
236 if (m_onceOff)
m_onceOffDescription
TRUEevaluated 6320 times by 2 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
FALSEevaluated 1200 times by 1 test
Evaluated by:
  • tst_qquickwander
1200-6320
237 if (activeGroup(pd->groupId))
activeGroup(pd->groupId)Description
TRUEevaluated 6320 times by 2 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
FALSEnever evaluated
0-6320
238 m_onceOffed.remove(qMakePair(pd->groupId, pd->index));
executed 6320 times by 2 tests: m_onceOffed.remove(qMakePair(pd->groupId, pd->index));
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
6320
239}
executed 7520 times by 3 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickwander
7520
240-
241void QQuickParticleAffector::updateOffsets()-
242{-
243 if (m_system)
m_systemDescription
TRUEevaluated 1357 times by 9 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
FALSEnever evaluated
0-1357
244 m_offset = m_system->mapFromItem(this, QPointF(0, 0));
executed 1357 times by 9 tests: m_offset = m_system->mapFromItem(this, QPointF(0, 0));
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
1357
245}
executed 1357 times by 9 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
1357
246-
247bool QQuickParticleAffector::isColliding(QQuickParticleData *d) const-
248{-
249 qreal myCurX = d->curX(m_system);-
250 qreal myCurY = d->curY(m_system);-
251 qreal myCurSize = d->curSize(m_system) / 2;-
252 foreach (const QString &group, m_whenCollidingWith){
_container_.controlDescription
TRUEnever evaluated
FALSEnever evaluated
_container_.controlDescription
TRUEnever evaluated
FALSEnever evaluated
_container_.i != _container_.eDescription
TRUEnever evaluated
FALSEnever evaluated
0
253 foreach (QQuickParticleData* other, m_system->groupData[m_system->groupIds[group]]->data){
_container_.controlDescription
TRUEnever evaluated
FALSEnever evaluated
_container_.controlDescription
TRUEnever evaluated
FALSEnever evaluated
_container_.i != _container_.eDescription
TRUEnever evaluated
FALSEnever evaluated
0
254 if (!other->stillAlive(m_system))
!other->stillAlive(m_system)Description
TRUEnever evaluated
FALSEnever evaluated
0
255 continue;
never executed: continue;
0
256 qreal otherCurX = other->curX(m_system);-
257 qreal otherCurY = other->curY(m_system);-
258 qreal otherCurSize = other->curSize(m_system) / 2;-
259 if ((myCurX + myCurSize > otherCurX - otherCurSize
myCurX + myCur...- otherCurSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
260 && myCurX - myCurSize < otherCurX + otherCurSize)
myCurX - myCur...+ otherCurSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
261 && (myCurY + myCurSize > otherCurY - otherCurSize
myCurY + myCur...- otherCurSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
262 && myCurY - myCurSize < otherCurY + otherCurSize))
myCurY - myCur...+ otherCurSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
263 return true;
never executed: return true;
0
264 }
never executed: end of block
0
265 }
never executed: end of block
0
266 return false;
never executed: return false;
0
267}-
268-
269QT_END_NAMESPACE-
270-
271#include "moc_qquickparticleaffector_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0