4#ifndef PARTICLESYSTEM_H
5#define PARTICLESYSTEM_H
18#include <QtQuick/QQuickItem>
19#include <QElapsedTimer>
21#include <QVarLengthArray>
25#include <private/qquicksprite_p.h>
26#include <QAbstractAnimation>
27#include <QtQml/qqml.h>
28#include <private/qv4util_p.h>
29#include <private/qv4global_p.h>
30#include <private/qv4staticvalue_p.h>
35template<
class T,
int Prealloc>
48 for (
int i = 0;
i < this->
size(); ++
i) {
49 if (this->
at(
i) == element) {
112 int oldSize = isUnused.size();
113 isUnused.resize(newSize,
true);
114 if (newSize > oldSize) {
115 if (firstUnused == UINT_MAX) {
116 firstUnused = oldSize;
118 firstUnused = std::min(firstUnused,
unsigned(oldSize));
120 }
else if (firstUnused >=
unsigned(newSize)) {
121 firstUnused = UINT_MAX;
127 isUnused.setBit(
index);
128 firstUnused = std::min(firstUnused,
unsigned(
index));
133 {
return allocated; }
135 bool hasUnusedEntries()
const
136 {
return firstUnused != UINT_MAX; }
140 if (hasUnusedEntries()) {
141 int nextFree = firstUnused;
142 isUnused.clearBit(firstUnused);
143 firstUnused = isUnused.findNext(firstUnused,
true,
false);
144 if (firstUnused >=
unsigned(isUnused.size())) {
145 firstUnused = UINT_MAX;
156 unsigned firstUnused = UINT_MAX;
162 enum { InvalidID = -1, DefaultGroupID = 0 };
177 void setSize(
int newSize);
306 static inline constexpr float EPSILON() noexcept {
return 0.001f; }
316 Q_PROPERTY(
bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged FINAL)
317 Q_PROPERTY(
bool empty READ isEmpty NOTIFY emptyChanged FINAL)
332 return particleCount;
335 static const int maxLife = 600000;
346 void stop(){setRunning(
false);}
347 void restart(){setRunning(
false);setRunning(
true);}
352 void setRunning(
bool arg);
353 void setPaused(
bool arg);
360 void componentComplete()
override;
363 void emittersChanged();
366 void particleStateChange(
int idx);
371 QQuickParticleData* newDatum(
int groupId,
bool respectLimits =
true,
int sysIdx = -1);
374 int nextSystemIndex();
418 void searchNextFreeGroupId();
421 void initializeSystem();
430 bool m_componentComplete;
462 float t = (particleSystem->
timeInt / 1000.0f) - this->t;
464 float vx = (this->vx +
t * this->
ax) - t *
ax;
465 float ex = this->
x + this->vx *
t + 0.5f * this->ax * t_sq;
466 float x = ex -
t *
vx - 0.5f * t_sq *
ax;
475 float t = (particleSystem->
timeInt / 1000.0f) - this->t;
477 float evx =
vx -
t * this->
ax;
478 float ex = this->
x + this->vx *
t + 0.5f * this->ax * t_sq;
479 float x = ex -
t * evx - 0.5f * t_sq * this->
ax;
487 float t = (particleSystem->
timeInt / 1000.0f) - this->t;
489 this->x =
x -
t * this->
vx - 0.5f * t_sq * this->
ax;
494 float t = (particleSystem->
timeInt / 1000.0f) - this->t;
496 float vy = (this->vy +
t * this->
ay) - t *
ay;
497 float ey = this->
y + this->vy *
t + 0.5f * this->ay * t_sq;
498 float y = ey -
t *
vy - 0.5f * t_sq *
ay;
507 float t = (particleSystem->
timeInt / 1000.0f) - this->t;
509 float evy =
vy -
t * this->
ay;
510 float ey = this->
y + this->vy *
t + 0.5f * this->ay * t_sq;
511 float y = ey -
t*evy - 0.5f * t_sq * this->
ay;
519 float t = (particleSystem->
timeInt / 1000.0f) - this->t;
521 this->y =
y -
t * this->
vy - 0.5f * t_sq * this->
ay;
526 float t = (particleSystem->
timeInt / 1000.0f) - this->t;
528 return this->
x + this->
vx * t + 0.5f * this->
ax * t_sq;
533 float t = (particleSystem->
timeInt / 1000.0f) - this->t;
534 return this->
vx + t * this->
ax;
539 float t = (particleSystem->
timeInt / 1000.0f) - this->t;
541 return y +
vy *
t + 0.5f *
ay * t_sq;
546 float t = (particleSystem->
timeInt / 1000.0f) - this->t;
561 float st = (system->
timeInt / 1000.0f);
574 if (!particleSystem ||
lifeSpan == 0.0f)
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setInstantaneousVY(float vy, QQuickParticleSystem *particleSystem)
QQuickImageParticle * deformationOwner
QQuickImageParticle * colorOwner
void setInstantaneousVX(float vx, QQuickParticleSystem *particleSystem)
QQuickParticleGroupData::ID groupId
float curY(QQuickParticleSystem *particleSystem) const
void setInstantaneousX(float x, QQuickParticleSystem *particleSystem)
void setInstantaneousAY(float ay, QQuickParticleSystem *particleSystem)
void setInstantaneousAX(float ax, QQuickParticleSystem *particleSystem)
float curVY(QQuickParticleSystem *particleSystem) const
void setInstantaneousY(float y, QQuickParticleSystem *particleSystem)
float curAX(QQuickParticleSystem *) const
QQuickImageParticle * animationOwner
bool stillAlive(QQuickParticleSystem *particleSystem) const
QQuickImageParticle * rotationOwner
float curAY(QQuickParticleSystem *) const
float curVX(QQuickParticleSystem *particleSystem) const
static constexpr float EPSILON() noexcept
bool alive(QQuickParticleSystem *particleSystem) const
float curX(QQuickParticleSystem *particleSystem) const
float lifeLeft(QQuickParticleSystem *particleSystem) const
float curSize(QQuickParticleSystem *particleSystem) const
QVector< QQuickParticleData * > data
QQuickParticleVarLengthArray< QQuickParticlePainter *, 4 > painters
QQuickParticleDataHeap dataHeap
QQuickParticleSystemAnimation(QQuickParticleSystem *system)
void updateCurrentTime(int t) override
This pure virtual function is called every time the animation's currentTime changes.
int duration() const override
This pure virtual function returns the duration of the animation, and defines for how long QAbstractA...
QQuickStochasticEngine * stateEngine
void runningChanged(bool arg)
QVarLengthArray< QQuickParticleGroupData *, 32 > groupData
QQuickParticleSystemAnimation * m_animation
virtual int duration() const
QHash< QString, int > groupIds
void pausedChanged(bool arg)
QVector< QQuickParticleData * > bySysIdx
void updateCurrentTime(int currentTime)
void emptyChanged(bool arg)
QSet< QQuickParticleData * > needsReset
void insert(const T &element)
bool removeOne(const T &element)
\macro QT_RESTRICTED_CAST_FROM_ASCII
constexpr size_type size() const noexcept
void remove(qsizetype i, qsizetype n=1)
bool contains(const AT &t) const
cache insert(employee->id(), employee)
Combined button and popup list for selecting options.
static int grow(QLayoutStruct &ls, int delta)
static Q_CONSTINIT QBasicAtomicInt running
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
Engine * createEngine(QGeoServiceProviderPrivate *)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
static double currentTime()
QSet< QQuickParticleData * > data
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent