OpenCoverage

qquickparticlesystem_p.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquickparticlesystem_p.h
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#ifndef PARTICLESYSTEM_H-
41#define PARTICLESYSTEM_H-
42-
43//-
44// W A R N I N G-
45// --------------
46//-
47// This file is not part of the Qt API. It exists purely as an-
48// implementation detail. This header file may change from version to-
49// version without notice, or even be removed.-
50//-
51// We mean it.-
52//-
53-
54#include <QtQuick/QQuickItem>-
55#include <QElapsedTimer>-
56#include <QVector>-
57#include <QHash>-
58#include <QPointer>-
59#include <private/qquicksprite_p.h>-
60#include <QAbstractAnimation>-
61#include <QtQml/qqml.h>-
62#include <private/qv8engine_p.h> //For QQmlV4Handle-
63#include <private/qv4util_p.h>-
64#include "qtquickparticlesglobal_p.h"-
65-
66QT_BEGIN_NAMESPACE-
67-
68template<class T, int Prealloc>-
69class QQuickParticleVarLengthArray: public QVarLengthArray<T, Prealloc>-
70{-
71public:-
72 void insert(const T &element)-
73 {-
74 if (!this->contains(element)) {
!this->contains(element)Description
TRUEnever evaluated
FALSEnever evaluated
0
75 this->append(element);-
76 }
never executed: end of block
0
77 }
never executed: end of block
0
78-
79 bool removeOne(const T &element)-
80 {-
81 for (int i = 0; i < this->size(); ++i) {
i < this->size()Description
TRUEevaluated 1100 times by 24 tests
Evaluated by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
FALSEevaluated 1182 times by 24 tests
Evaluated by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
1100-1182
82 if (this->at(i) == element) {
this->at(i) == elementDescription
TRUEevaluated 464 times by 24 tests
Evaluated by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
FALSEevaluated 636 times by 1 test
Evaluated by:
  • tst_examples
464-636
83 this->remove(i);-
84 return true;
executed 464 times by 24 tests: return true;
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
464
85 }-
86 }
executed 636 times by 1 test: end of block
Executed by:
  • tst_examples
636
87-
88 return false;
executed 1182 times by 24 tests: return false;
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
1182
89 }-
90};-
91-
92class QQuickParticleSystem;-
93class QQuickParticleAffector;-
94class QQuickParticleEmitter;-
95class QQuickParticlePainter;-
96class QQuickParticleData;-
97class QQuickParticleSystemAnimation;-
98class QQuickStochasticEngine;-
99class QQuickSprite;-
100class QQuickV4ParticleData;-
101class QQuickParticleGroup;-
102class QQuickImageParticle;-
103-
104struct QQuickParticleDataHeapNode{-
105 int time;//in ms-
106 QSet<QQuickParticleData*> data;//Set ptrs instead?-
107};-
108-
109class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleDataHeap {-
110 //Idea is to do a binary heap, but which also stores a set of int,Node* so that if the int already exists, you can-
111 //add it to the data* list. Pops return the whole list at once.-
112public:-
113 QQuickParticleDataHeap();-
114 void insert(QQuickParticleData* data);-
115 void insertTimed(QQuickParticleData* data, int time);-
116-
117 int top();-
118-
119 QSet<QQuickParticleData*> pop();-
120-
121 void clear();-
122-
123 bool contains(QQuickParticleData*);//O(n), for debugging purposes only-
124private:-
125 void grow();-
126 void swap(int, int);-
127 void bubbleUp(int);-
128 void bubbleDown(int);-
129 int m_size;-
130 int m_end;-
131 QQuickParticleDataHeapNode m_tmp;-
132 QVector<QQuickParticleDataHeapNode> m_data;-
133 QHash<int,int> m_lookups;-
134};-
135-
136class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleGroupData {-
137 class FreeList-
138 {-
139 public:-
140 FreeList() {}-
141-
142 void resize(int newSize)-
143 {-
144 Q_ASSERT(newSize >= 0);-
145 int oldSize = isUnused.size();-
146 isUnused.resize(newSize, true);-
147 if (newSize > oldSize) {
newSize > oldSizeDescription
TRUEevaluated 470 times by 24 tests
Evaluated by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
FALSEnever evaluated
0-470
148 if (firstUnused == UINT_MAX) {
firstUnused ==...fff * 2U + 1U)Description
TRUEevaluated 438 times by 24 tests
Evaluated by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquicktrailemitter
32-438
149 firstUnused = oldSize;-
150 } else {
executed 438 times by 24 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
438
151 firstUnused = std::min(firstUnused, unsigned(oldSize));-
152 }
executed 32 times by 2 tests: end of block
Executed by:
  • tst_examples
  • tst_qquicktrailemitter
32
153 } else if (firstUnused >= unsigned(newSize)) {
firstUnused >=...igned(newSize)Description
TRUEnever evaluated
FALSEnever evaluated
0
154 firstUnused = UINT_MAX;-
155 }
never executed: end of block
0
156 }
executed 470 times by 24 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
470
157-
158 void free(int index)-
159 {-
160 isUnused.setBit(index);-
161 firstUnused = std::min(firstUnused, unsigned(index));-
162 --allocated;-
163 }
executed 14020 times by 23 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
14020
164-
165 int count() const-
166 { return allocated; }
executed 3483 times by 23 tests: return allocated;
Executed by:
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
3483
167-
168 bool hasUnusedEntries() const-
169 { return firstUnused != UINT_MAX; }
executed 108572 times by 23 tests: return firstUnused != (0x7fffffff * 2U + 1U) ;
Executed by:
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
108572
170-
171 int alloc()-
172 {-
173 if (hasUnusedEntries()) {
hasUnusedEntries()Description
TRUEevaluated 54286 times by 23 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
FALSEnever evaluated
0-54286
174 int nextFree = firstUnused;-
175 isUnused.clearBit(firstUnused);-
176 firstUnused = isUnused.findNext(firstUnused, true, false);-
177 if (firstUnused >= unsigned(isUnused.size())) {
firstUnused >=...Unused.size())Description
TRUEevaluated 226 times by 3 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickgroupgoal
  • tst_qquickparticlegroup
FALSEevaluated 54060 times by 23 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
226-54060
178 firstUnused = UINT_MAX;-
179 }
executed 226 times by 3 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickgroupgoal
  • tst_qquickparticlegroup
226
180 ++allocated;-
181 return nextFree;
executed 54286 times by 23 tests: return nextFree;
Executed by:
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
54286
182 } else {-
183 return -1;
never executed: return -1;
0
184 }-
185 }-
186-
187 private:-
188 QV4::BitVector isUnused;-
189 unsigned firstUnused = UINT_MAX;-
190 int allocated = 0;-
191 };-
192-
193public: // types-
194 typedef int ID;-
195 enum { InvalidID = -1, DefaultGroupID = 0 };-
196-
197public:-
198 QQuickParticleGroupData(const QString &name, QQuickParticleSystem* sys);-
199 ~QQuickParticleGroupData();-
200-
201 int size()-
202 { return m_size; }
executed 1618 times by 24 tests: return m_size;
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
1618
203-
204 QString name();-
205-
206 void setSize(int newSize);-
207-
208 const ID index;-
209 QQuickParticleVarLengthArray<QQuickParticlePainter*, 4> painters;//TODO: What if they are dynamically removed?-
210-
211 //TODO: Refactor particle data list out into a separate class-
212 QVector<QQuickParticleData*> data;-
213 FreeList freeList;-
214 QQuickParticleDataHeap dataHeap;-
215 bool recycle(); //Force recycling round, returns true if all indexes are now reusable-
216-
217 void initList();-
218 void kill(QQuickParticleData* d);-
219-
220 //After calling this, initialize, then call prepareRecycler(d)-
221 QQuickParticleData* newDatum(bool respectsLimits);-
222-
223 //TODO: Find and clean up those that don't get added to the recycler (currently they get lost)-
224 void prepareRecycler(QQuickParticleData* d);-
225-
226private:-
227 int m_size;-
228 QQuickParticleSystem* m_system;-
229};-
230-
231struct Color4ub {-
232 uchar r;-
233 uchar g;-
234 uchar b;-
235 uchar a;-
236};-
237-
238class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleData {-
239public:-
240 //TODO: QObject like memory management (without the cost, just attached to system)-
241 QQuickParticleData();-
242 ~QQuickParticleData();-
243-
244 QQuickParticleData(const QQuickParticleData &other);-
245 QQuickParticleData &operator=(const QQuickParticleData &other);-
246-
247 //Convenience functions for working backwards, because parameters are from the start of particle life-
248 //If setting multiple parameters at once, doing the conversion yourself will be faster.-
249-
250 //sets the x accleration without affecting the instantaneous x velocity or position-
251 void setInstantaneousAX(float ax, QQuickParticleSystem *particleSystem);-
252 //sets the x velocity without affecting the instantaneous x postion-
253 void setInstantaneousVX(float vx, QQuickParticleSystem *particleSystem);-
254 //sets the instantaneous x postion-
255 void setInstantaneousX(float x, QQuickParticleSystem *particleSystem);-
256 //sets the y accleration without affecting the instantaneous y velocity or position-
257 void setInstantaneousAY(float ay, QQuickParticleSystem *particleSystem);-
258 //sets the y velocity without affecting the instantaneous y postion-
259 void setInstantaneousVY(float vy, QQuickParticleSystem *particleSystem);-
260 //sets the instantaneous Y postion-
261 void setInstantaneousY(float y, QQuickParticleSystem *particleSystem);-
262-
263 //TODO: Slight caching?-
264 float curX(QQuickParticleSystem *particleSystem) const;-
265 float curVX(QQuickParticleSystem *particleSystem) const;-
266 float curAX() const { return ax; }
executed 27584 times by 2 tests: return ax;
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
27584
267 float curAX(QQuickParticleSystem *) const { return ax; } // used by the macros in qquickv4particledata.cpp
never executed: return ax;
0
268 float curY(QQuickParticleSystem *particleSystem) const;-
269 float curVY(QQuickParticleSystem *particleSystem) const;-
270 float curAY() const { return ay; }
executed 27584 times by 2 tests: return ay;
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
27584
271 float curAY(QQuickParticleSystem *) const { return ay; } // used by the macros in qquickv4particledata.cpp
never executed: return ay;
0
272-
273 int index;-
274 int systemIndex;-
275-
276 //General Position Stuff-
277 float x;-
278 float y;-
279 float t;-
280 float lifeSpan;-
281 float size;-
282 float endSize;-
283 float vx;-
284 float vy;-
285 float ax;-
286 float ay;-
287-
288 //Painter-specific stuff, now universally shared-
289 //Used by ImageParticle color mode-
290 Color4ub color;-
291 //Used by ImageParticle deform mode-
292 float xx;-
293 float xy;-
294 float yx;-
295 float yy;-
296 float rotation;-
297 float rotationVelocity;-
298 float autoRotate;//Assume that GPUs prefer floats to bools-
299 //Used by ImageParticle Sprite mode-
300 float animIdx;-
301 float frameDuration;-
302 float frameAt;//Used for duration -1-
303 float frameCount;-
304 float animT;-
305 float animX;-
306 float animY;-
307 float animWidth;-
308 float animHeight;-
309-
310 QQuickParticleGroupData::ID groupId;-
311-
312 //Used by ImageParticle data shadowing-
313 QQuickImageParticle* colorOwner;-
314 QQuickImageParticle* rotationOwner;-
315 QQuickImageParticle* deformationOwner;-
316 QQuickImageParticle* animationOwner;-
317-
318 //Used by ItemParticle-
319 QQuickItem* delegate;-
320 int modelIndex;-
321 //Used by custom affectors-
322 float update;-
323 //Used by CustomParticle-
324 float r;-
325-
326 // 4 bytes wasted-
327-
328-
329 void debugDump(QQuickParticleSystem *particleSystem) const;-
330 bool stillAlive(QQuickParticleSystem *particleSystem) const; //Only checks end, because usually that's all you need and it's a little faster.-
331 bool alive(QQuickParticleSystem *particleSystem) const;-
332 float lifeLeft(QQuickParticleSystem *particleSystem) const;-
333-
334 float curSize(QQuickParticleSystem *particleSystem) const;-
335 void clone(const QQuickParticleData& other);//Not =, leaves meta-data like index-
336 QQmlV4Handle v4Value(QQuickParticleSystem *particleSystem);-
337 void extendLife(float time, QQuickParticleSystem *particleSystem);-
338-
339 static inline Q_DECL_CONSTEXPR float EPSILON() Q_DECL_NOTHROW { return 0.001f; }-
340-
341private:-
342 QQuickV4ParticleData* v8Datum;-
343};-
344-
345class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleSystem : public QQuickItem-
346{-
347 Q_OBJECT-
348 Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)-
349 Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)-
350 Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)-
351-
352public:-
353 explicit QQuickParticleSystem(QQuickItem *parent = nullptr);-
354 ~QQuickParticleSystem();-
355-
356 bool isRunning() const-
357 {-
358 return m_running;
executed 4598 times by 23 tests: return m_running;
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
4598
359 }-
360-
361 int count(){ return particleCount; }
never executed: return particleCount;
0
362-
363 static const int maxLife = 600000;-
364-
365Q_SIGNALS:-
366-
367 void systemInitialized();-
368 void runningChanged(bool arg);-
369 void pausedChanged(bool arg);-
370 void emptyChanged(bool arg);-
371-
372public Q_SLOTS:-
373 void start(){setRunning(true);}
never executed: end of block
0
374 void stop(){setRunning(false);}
never executed: end of block
0
375 void restart(){setRunning(false);setRunning(true);}
never executed: end of block
0
376 void pause(){setPaused(true);}
never executed: end of block
0
377 void resume(){setPaused(false);}
never executed: end of block
0
378-
379 void reset();-
380 void setRunning(bool arg);-
381 void setPaused(bool arg);-
382-
383 virtual int duration() const { return -1; }
never executed: return -1;
0
384-
385-
386protected:-
387 //This one only once per frame (effectively)-
388 void componentComplete() override;-
389-
390private Q_SLOTS:-
391 void emittersChanged();-
392 void loadPainter(QQuickParticlePainter *p);-
393 void createEngine(); //Not invoked by sprite engine, unlike Sprite uses-
394 void particleStateChange(int idx);-
395-
396public:-
397 //These can be called multiple times per frame, performance critical-
398 void emitParticle(QQuickParticleData* p, QQuickParticleEmitter *particleEmitter);-
399 QQuickParticleData* newDatum(int groupId, bool respectLimits = true, int sysIdx = -1);-
400 void finishNewDatum(QQuickParticleData*);-
401 void moveGroups(QQuickParticleData *d, int newGIdx);-
402 int nextSystemIndex();-
403-
404 //This one only once per painter per frame-
405 int systemSync(QQuickParticlePainter* p);-
406-
407 //Data members here for ease of related class and auto-test usage. Not "public" API. TODO: d_ptrize-
408 QSet<QQuickParticleData*> needsReset;-
409 QVector<QQuickParticleData*> bySysIdx; //Another reference to the data (data owned by group), but by sysIdx-
410 QQuickStochasticEngine* stateEngine;-
411-
412 QHash<QString, int> groupIds;-
413 QVarLengthArray<QQuickParticleGroupData*, 32> groupData;-
414 int nextFreeGroupId;-
415 int registerParticleGroupData(const QString &name, QQuickParticleGroupData *pgd);-
416-
417 //Also only here for auto-test usage-
418 void updateCurrentTime( int currentTime );-
419 QQuickParticleSystemAnimation* m_animation;-
420 bool m_running;-
421 bool m_debugMode;-
422-
423 int timeInt;-
424 bool initialized;-
425 int particleCount;-
426-
427 void registerParticlePainter(QQuickParticlePainter* p);-
428 void registerParticleEmitter(QQuickParticleEmitter* e);-
429 void finishRegisteringParticleEmitter(QQuickParticleEmitter *e);-
430 void registerParticleAffector(QQuickParticleAffector* a);-
431 void registerParticleGroup(QQuickParticleGroup* g);-
432-
433 static void statePropertyRedirect(QQmlListProperty<QObject> *prop, QObject *value);-
434 static void stateRedirect(QQuickParticleGroup* group, QQuickParticleSystem* sys, QObject *value);-
435 bool isPaused() const-
436 {-
437 return m_paused;
executed 4586 times by 23 tests: return m_paused;
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
4586
438 }-
439-
440 bool isEmpty() const-
441 {-
442 return m_empty;
never executed: return m_empty;
0
443 }-
444-
445private:-
446 void searchNextFreeGroupId();-
447-
448private:-
449 void initializeSystem();-
450 void initGroups();-
451 QList<QPointer<QQuickParticleEmitter> > m_emitters;-
452 QList<QPointer<QQuickParticleAffector> > m_affectors;-
453 QList<QPointer<QQuickParticlePainter> > m_painters;-
454 QList<QPointer<QQuickParticlePainter> > m_syncList;-
455 QList<QQuickParticleGroup*> m_groups;-
456 int m_nextIndex;-
457 QSet<int> m_reusableIndexes;-
458 bool m_componentComplete;-
459-
460 bool m_paused;-
461 bool m_allDead;-
462 bool m_empty;-
463};-
464-
465// Internally, this animation drives all the timing. Painters sync up in their updatePaintNode-
466class QQuickParticleSystemAnimation : public QAbstractAnimation-
467{-
468 Q_OBJECT-
469public:-
470 QQuickParticleSystemAnimation(QQuickParticleSystem* system)-
471 : QAbstractAnimation(static_cast<QObject*>(system)), m_system(system)-
472 { }
executed 166 times by 24 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
166
473protected:-
474 void updateCurrentTime(int t) override-
475 {-
476 m_system->updateCurrentTime(t);-
477 }
executed 3084 times by 24 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
3084
478-
479 int duration() const override-
480 {-
481 return -1;
executed 3084 times by 24 tests: return -1;
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
3084
482 }-
483-
484private:-
485 QQuickParticleSystem* m_system;-
486};-
487-
488inline void QQuickParticleData::setInstantaneousAX(float ax, QQuickParticleSystem* particleSystem)-
489{-
490 float t = (particleSystem->timeInt / 1000.0f) - this->t;-
491 float t_sq = t * t;-
492 float vx = (this->vx + t * this->ax) - t * ax;-
493 float ex = this->x + this->vx * t + 0.5f * this->ax * t_sq;-
494 float x = ex - t * vx - 0.5f * t_sq * ax;-
495-
496 this->ax = ax;-
497 this->vx = vx;-
498 this->x = x;-
499}
executed 2512 times by 2 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
2512
500-
501inline void QQuickParticleData::setInstantaneousVX(float vx, QQuickParticleSystem* particleSystem)-
502{-
503 float t = (particleSystem->timeInt / 1000.0f) - this->t;-
504 float t_sq = t * t;-
505 float evx = vx - t * this->ax;-
506 float ex = this->x + this->vx * t + 0.5f * this->ax * t_sq;-
507 float x = ex - t * evx - 0.5f * t_sq * this->ax;-
508-
509 this->vx = evx;-
510 this->x = x;-
511}
executed 116336 times by 6 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickturbulence
  • tst_qquickwander
116336
512-
513inline void QQuickParticleData::setInstantaneousX(float x, QQuickParticleSystem* particleSystem)-
514{-
515 float t = (particleSystem->timeInt / 1000.0f) - this->t;-
516 float t_sq = t * t;-
517 this->x = x - t * this->vx - 0.5f * t_sq * this->ax;-
518}
executed 25590 times by 2 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
25590
519-
520inline void QQuickParticleData::setInstantaneousAY(float ay, QQuickParticleSystem* particleSystem)-
521{-
522 float t = (particleSystem->timeInt / 1000.0f) - this->t;-
523 float t_sq = t * t;-
524 float vy = (this->vy + t * this->ay) - t * ay;-
525 float ey = this->y + this->vy * t + 0.5f * this->ay * t_sq;-
526 float y = ey - t * vy - 0.5f * t_sq * ay;-
527-
528 this->ay = ay;-
529 this->vy = vy;-
530 this->y = y;-
531}
executed 2512 times by 2 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
2512
532-
533inline void QQuickParticleData::setInstantaneousVY(float vy, QQuickParticleSystem* particleSystem)-
534{-
535 float t = (particleSystem->timeInt / 1000.0f) - this->t;-
536 float t_sq = t * t;-
537 float evy = vy - t * this->ay;-
538 float ey = this->y + this->vy * t + 0.5f * this->ay * t_sq;-
539 float y = ey - t*evy - 0.5f * t_sq * this->ay;-
540-
541 this->vy = evy;-
542 this->y = y;-
543}
executed 116336 times by 6 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickturbulence
  • tst_qquickwander
116336
544-
545inline void QQuickParticleData::setInstantaneousY(float y, QQuickParticleSystem *particleSystem)-
546{-
547 float t = (particleSystem->timeInt / 1000.0f) - this->t;-
548 float t_sq = t * t;-
549 this->y = y - t * this->vy - 0.5f * t_sq * this->ay;-
550}
executed 25590 times by 2 tests: end of block
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
25590
551-
552inline float QQuickParticleData::curX(QQuickParticleSystem *particleSystem) const-
553{-
554 float t = (particleSystem->timeInt / 1000.0f) - this->t;-
555 float t_sq = t * t;-
556 return this->x + this->vx * t + 0.5f * this->ax * t_sq;
executed 181633 times by 5 tests: return this->x + this->vx * t + 0.5f * this->ax * t_sq;
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickitemparticle
  • tst_qquickpointattractor
  • tst_qquickturbulence
181633
557}-
558-
559inline float QQuickParticleData::curVX(QQuickParticleSystem *particleSystem) const-
560{-
561 float t = (particleSystem->timeInt / 1000.0f) - this->t;-
562 return this->vx + t * this->ax;
executed 186366 times by 6 tests: return this->vx + t * this->ax;
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickturbulence
  • tst_qquickwander
186366
563}-
564-
565inline float QQuickParticleData::curY(QQuickParticleSystem *particleSystem) const-
566{-
567 float t = (particleSystem->timeInt / 1000.0f) - this->t;-
568 float t_sq = t * t;-
569 return y + vy * t + 0.5f * ay * t_sq;
executed 181633 times by 5 tests: return y + vy * t + 0.5f * ay * t_sq;
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickitemparticle
  • tst_qquickpointattractor
  • tst_qquickturbulence
181633
570}-
571-
572inline float QQuickParticleData::curVY(QQuickParticleSystem *particleSystem) const-
573{-
574 float t = (particleSystem->timeInt / 1000.0f) - this->t;-
575 return vy + t*ay;
executed 186366 times by 6 tests: return vy + t*ay;
Executed by:
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickturbulence
  • tst_qquickwander
186366
576}-
577-
578inline bool QQuickParticleData::stillAlive(QQuickParticleSystem* system) const-
579{-
580 if (!system)
!systemDescription
TRUEnever evaluated
FALSEevaluated 764177 times by 23 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
0-764177
581 return false;
never executed: return false;
0
582 return (t + lifeSpan - EPSILON()) > (system->timeInt / 1000.0f);
executed 764177 times by 23 tests: return (t + lifeSpan - EPSILON()) > (system->timeInt / 1000.0f);
Executed by:
  • tst_qquickage
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • tst_qquickcustomparticle
  • tst_qquickellipseextruder
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquicklineextruder
  • tst_qquickmaskextruder
  • tst_qquickparticlegroup
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickpointdirection
  • tst_qquickrectangleextruder
  • tst_qquickspritegoal
  • tst_qquicktargetdirection
  • tst_qquicktrailemitter
  • tst_qquickturbulence
  • tst_qquickwander
764177
583}-
584-
585inline bool QQuickParticleData::alive(QQuickParticleSystem* system) const-
586{-
587 if (!system)
!systemDescription
TRUEnever evaluated
FALSEnever evaluated
0
588 return false;
never executed: return false;
0
589 float st = (system->timeInt / 1000.0f);-
590 return (t + EPSILON()) < st && (t + lifeSpan - EPSILON()) > st;
never executed: return (t + EPSILON()) < st && (t + lifeSpan - EPSILON()) > st;
0
591}-
592-
593inline float QQuickParticleData::lifeLeft(QQuickParticleSystem *particleSystem) const-
594{-
595 if (!particleSystem)
!particleSystemDescription
TRUEnever evaluated
FALSEnever evaluated
0
596 return 0.0f;
never executed: return 0.0f;
0
597 return (t + lifeSpan) - (particleSystem->timeInt / 1000.0f);
never executed: return (t + lifeSpan) - (particleSystem->timeInt / 1000.0f);
0
598}-
599-
600inline float QQuickParticleData::curSize(QQuickParticleSystem *particleSystem) const-
601{-
602 if (!particleSystem || lifeSpan == 0.0f)
!particleSystemDescription
TRUEnever evaluated
FALSEnever evaluated
lifeSpan == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
0
603 return 0.0f;
never executed: return 0.0f;
0
604 return size + (endSize - size) * (1 - (lifeLeft(particleSystem) / lifeSpan));
never executed: return size + (endSize - size) * (1 - (lifeLeft(particleSystem) / lifeSpan));
0
605}-
606-
607QT_END_NAMESPACE-
608-
609#endif // PARTICLESYSTEM_H-
610-
611-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0