5#include <QtQuick/qsgnode.h>
9#include <private/qquickspriteengine_p.h>
10#include <private/qquicksprite_p.h>
15#include <private/qqmlengine_p.h>
16#include <private/qqmlglobal_p.h>
175 m_data.reserve(1000);
179void QQuickParticleDataHeap::grow()
193 m_data[m_lookups[
time]].data <<
data;
196 if (m_end == (1 << m_size))
198 m_data[m_end].time =
time;
199 m_data[m_end].data.clear();
200 m_data[m_end].data.insert(
data);
209 return m_data[0].time;
221 m_data[0] = m_data[--m_end];
238 for (
int i=0;
i<m_end;
i++)
239 if (m_data[
i].
data.contains(
d))
244void QQuickParticleDataHeap::swap(
int a,
int b)
247 m_data[
a] = m_data[
b];
249 m_lookups[m_data[
a].time] =
a;
253void QQuickParticleDataHeap::bubbleUp(
int idx)
264void QQuickParticleDataHeap::bubbleDown(
int idx)
266 int left = idx*2 + 1;
270 int right = idx*2 + 2;
275 if (m_data[idx].
time > m_data[lesser].
time) {
302 if (newSize == m_size)
305 data.resize(newSize);
307 for (
int i=m_size;
i<newSize;
i++) {
312 int delta = newSize - m_size;
315 p->setCount(
p->count() + delta);
336 while (
freeList.hasUnusedEntries()) {
338 if (
data[idx]->stillAlive(m_system)) {
347 int oldSize = m_size;
356 m_latestAliveParticles.clear();
360 if (!datum->stillAlive(m_system)) {
363 m_latestAliveParticles.push_back(datum);
368 for (
auto particle : m_latestAliveParticles)
377 if (
d->lifeSpan*1000 < m_system->
maxLife) {
380 int extend = 2 * m_system->
maxLife / 3;
382 d->extendLife(m_system->
maxLife / 3000.0, m_system);
499 <<
"Pos: " <<
x <<
"," <<
y
500 <<
"Vel: " <<
vx <<
"," <<
vy
501 <<
"Acc: " <<
ax <<
"," <<
ay
503 <<
"Time: " <<
t <<
"," <<
lifeSpan <<
";" << (particleSystem->
timeInt / 1000.0) ;
537 m_componentComplete(
false),
550void QQuickParticleSystem::initGroups()
552 m_reusableIndexes.
clear();
560 for (
auto e :
std::as_const(m_emitters)) {
561 e->reclaculateGroupId();
564 p->recalculateGroupIds();
575 qDebug() <<
"Registering Painter" <<
p <<
"to" <<
this;
577 m_painters << QPointer<QQuickParticlePainter>(
p);
586 qDebug() <<
"Registering Emitter" <<
e <<
"to" <<
this;
587 m_emitters << QPointer<QQuickParticleEmitter>(
e);
593 this,
SLOT(emittersChanged()));
595 this,
SLOT(emittersChanged()));
596 if (m_componentComplete)
604 qDebug() <<
"Registering Affector" <<
a <<
"to" <<
this;
606 m_affectors << QPointer<QQuickParticleAffector>(
a);
612 qDebug() <<
"Registering Group" <<
g <<
"to" <<
this;
613 m_groups << QPointer<QQuickParticleGroup>(
g);
630 if (m_paused !=
arg) {
661 a->setParentItem(sys);
675 e->setParentItem(sys);
676 e->setGroup(
group->name());
682 p->setParentItem(sys);
687 qWarning() <<
value <<
" was placed inside a particle system state but cannot be taken into the particle system. It will be lost.";
702 searchNextFreeGroupId();
708void QQuickParticleSystem::searchNextFreeGroupId()
722 m_componentComplete =
true;
729 if (!m_componentComplete)
770 if (!m_componentComplete || !
painter)
774 sg->painters.removeOne(
painter);
778 if (
painter->groups().isEmpty()) {
795void QQuickParticleSystem::emittersChanged()
797 if (!m_componentComplete)
810 for (
int i = 0;
i < m_emitters.
size(); ) {
817 int groupId =
e->groupId();
823 newSizes[groupId] +=
e->particleCount();
844 a->m_updateIntSet =
true;
856void QQuickParticleSystem::createEngine()
858 if (!m_componentComplete)
861 qDebug() <<
"Resetting Existing Sprite Engine...";
876 if (m_groups.
size()) {
884 if (existing->name() ==
name) {
906 this,
SLOT(particleStateChange(
int)));
916void QQuickParticleSystem::particleStateChange(
int idx)
923 if (!
d || newGIdx ==
d->groupId)
939 if (!m_reusableIndexes.
isEmpty()) {
940 int ret = *(m_reusableIndexes.
begin());
944 if (m_nextIndex >=
bySysIdx.size()) {
950 return m_nextIndex++;
961 if (sysIndex == -1) {
962 if (
ret->systemIndex == -1)
965 if (
ret->systemIndex != -1) {
968 m_reusableIndexes <<
ret->systemIndex;
971 ret->systemIndex = sysIndex;
989 t.map(pd->
x, pd->
y, &tx, &
ty);
1003 if (
a &&
a->m_needsReset)
1026 bool oldClear = m_empty;
1029 m_empty = gd->recycle() && m_empty;
1037 a->affectSystem(dt);
1042 if (oldClear != m_empty)
1052 p->performPendingCommits();
1059#include "moc_qquickparticlesystem_p.cpp"
State state
state of the animation.
void resume()
Resumes the animation after it was paused.
void stop()
Stops the animation.
void start(QAbstractAnimation::DeletionPolicy policy=KeepWhenStopped)
Starts the animation.
void pause()
Pauses the animation.
key_iterator keyEnd() const noexcept
bool remove(const Key &key)
Removes the item that has the key from the hash.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
key_iterator keyBegin() const noexcept
Key key(const T &value) const noexcept
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
qsizetype size() const noexcept
bool isEmpty() const noexcept
void removeAt(qsizetype i)
const_reference at(qsizetype i) const noexcept
qsizetype removeAll(const AT &t)
void reserve(qsizetype size)
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
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 setParentItem(QQuickItem *parent)
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
QTransform itemTransform(QQuickItem *, bool *) const
\qmlmethod point QtQuick::Item::mapFromItem(Item item, real x, real y) \qmlmethod point QtQuick::Item...
void stateChanged(const QString &)
QSet< QQuickParticleData * > pop()
void insertTimed(QQuickParticleData *data, int time)
void insert(QQuickParticleData *data)
bool contains(QQuickParticleData *)
QQuickImageParticle * deformationOwner
QQuickImageParticle * colorOwner
QQuickParticleGroupData::ID groupId
float curY(QQuickParticleSystem *particleSystem) const
void extendLife(float time, QQuickParticleSystem *particleSystem)
float curVY(QQuickParticleSystem *particleSystem) const
QQuickImageParticle * animationOwner
bool stillAlive(QQuickParticleSystem *particleSystem) const
QQuickParticleData & operator=(const QQuickParticleData &other)
QQuickImageParticle * rotationOwner
void clone(const QQuickParticleData &other)
void debugDump(QQuickParticleSystem *particleSystem) const
float curVX(QQuickParticleSystem *particleSystem) const
float curX(QQuickParticleSystem *particleSystem) const
QV4::ReturnedValue v4Value(QQuickParticleSystem *particleSystem)
void setSystem(QQuickParticleSystem *arg)
void prepareRecycler(QQuickParticleData *d)
QQuickParticleData * newDatum(bool respectsLimits)
QQuickParticleVarLengthArray< QQuickParticlePainter *, 4 > painters
QQuickParticleGroupData(const QString &name, QQuickParticleSystem *sys)
QQuickParticleDataHeap dataHeap
~QQuickParticleGroupData()
void kill(QQuickParticleData *d)
void setSize(int newSize)
void groupsChanged(const QStringList &arg)
void registerParticleEmitter(QQuickParticleEmitter *e)
QQuickStochasticEngine * stateEngine
void runningChanged(bool arg)
void finishRegisteringParticleEmitter(QQuickParticleEmitter *e)
int registerParticleGroupData(const QString &name, QQuickParticleGroupData *pgd)
void registerParticlePainter(QQuickParticlePainter *p)
void emitParticle(QQuickParticleData *p, QQuickParticleEmitter *particleEmitter)
QVarLengthArray< QQuickParticleGroupData *, 32 > groupData
QQuickParticleSystem(QQuickItem *parent=nullptr)
QQuickParticleSystemAnimation * m_animation
void registerParticleGroup(QQuickParticleGroup *g)
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
void setRunning(bool arg)
static void stateRedirect(QQuickParticleGroup *group, QQuickParticleSystem *sys, QObject *value)
QHash< QString, int > groupIds
void pausedChanged(bool arg)
QQuickParticleData * newDatum(int groupId, bool respectLimits=true, int sysIdx=-1)
QVector< QQuickParticleData * > bySysIdx
static void statePropertyRedirect(QQmlListProperty< QObject > *prop, QObject *value)
void finishNewDatum(QQuickParticleData *)
void registerParticleAffector(QQuickParticleAffector *a)
void updateCurrentTime(int currentTime)
void moveGroups(QQuickParticleData *d, int newGIdx)
void emptyChanged(bool arg)
int systemSync(QQuickParticlePainter *p)
QSet< QQuickParticleData * > needsReset
void start(int index=0, int state=0)
QList< QQuickStochasticState * > m_states
uint updateSprites(uint time)
int curState(int index=0) const
void setFollow(const QString &arg)
QV4::ReturnedValue v4Value() const
bool remove(const T &value)
\macro QT_RESTRICTED_CAST_FROM_ASCII
constexpr size_type size() const noexcept
void push_back(const T &t)
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
constexpr const T & qMax(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLuint64 GLenum void * handle
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
QQmlEngine * qmlEngine(const QObject *obj)
#define DEFINE_BOOL_CONFIG_OPTION(name, var)
static QT_BEGIN_NAMESPACE int roundedTime(qreal a)
A system which includes particle painter, emitter, and affector types.
static double elapsed(qint64 after, qint64 before)
static double currentTime()
bool contains(const AT &t) const noexcept
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent