diff options
Diffstat (limited to 'src/particles/qquickitemparticle.cpp')
-rw-r--r-- | src/particles/qquickitemparticle.cpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/particles/qquickitemparticle.cpp b/src/particles/qquickitemparticle.cpp index 4cd8ee9db8..ba6c6f915d 100644 --- a/src/particles/qquickitemparticle.cpp +++ b/src/particles/qquickitemparticle.cpp @@ -231,10 +231,10 @@ void QQuickItemParticle::reset() // delete all managed items which had their logical particles cleared // but leave it alone if the logical particle is maintained QSet<QQuickItem*> lost = QSet<QQuickItem*>::fromList(m_managed); - foreach (const QString group, m_groups){ - int gIdx = m_system->groupIds[group]; - foreach (QQuickParticleData* d, m_system->groupData[gIdx]->data) - lost.remove(d->delegate); + for (auto groupId : groupIds()) { + for (QQuickParticleData* d : qAsConst(m_system->groupData[groupId]->data)) { + lost.remove(d->delegate); + } } m_deletables.append(lost.toList()); //TODO: This doesn't yet handle calling detach on taken particles in the system reset case @@ -249,11 +249,12 @@ QSGNode* QQuickItemParticle::updatePaintNode(QSGNode* n, UpdatePaintNodeData* d) m_pleaseReset = false; //Refill loadables, delayed here so as to only happen once per frame max //### Constant resetting might lead to m_loadables never being populated when tick() occurs - foreach (const QString group, m_groups){ - int gIdx = m_system->groupIds[group]; - foreach (QQuickParticleData* d, m_system->groupData[gIdx]->data) - if (!d->delegate && d->t != -1 && d->stillAlive()) + for (auto groupId : groupIds()) { + for (QQuickParticleData* d : qAsConst(m_system->groupData[groupId]->data)) { + if (!d->delegate && d->t != -1 && d->stillAlive()) { m_loadables << d; + } + } } } prepareNextFrame(); @@ -276,31 +277,26 @@ void QQuickItemParticle::prepareNextFrame() return; //TODO: Size, better fade? - foreach (const QString &str, m_groups){ - const int gIdx = m_system->groupIds[str]; - const QVector<QQuickParticleData*> dataVector = m_system->groupData[gIdx]->data; - const int count = dataVector.size(); - - for (int i=0; i<count; i++){ - QQuickParticleData* data = dataVector.at(i); + for (auto groupId : groupIds()) { + for (QQuickParticleData* data : qAsConst(m_system->groupData[groupId]->data)) { QQuickItem* item = data->delegate; if (!item) continue; - qreal t = ((timeStamp/1000.0) - data->t) / data->lifeSpan; + float t = ((timeStamp / 1000.0f) - data->t) / data->lifeSpan; if (m_stasis.contains(item)) { data->t += dt;//Stasis effect continue; } - if (t >= 1.0){//Usually happens from load + if (t >= 1.0f){//Usually happens from load m_deletables << item; data->delegate = 0; }else{//Fade data->delegate->setVisible(true); if (m_fade){ - qreal o = 1.; - if (t<0.2) - o = t*5; - if (t>0.8) + float o = 1.f; + if (t <0.2f) + o = t * 5; + if (t > 0.8f) o = (1-t)*5; item->setOpacity(o); } |