aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/particles/particleaffector.cpp
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-05-03 10:23:21 +1000
committerAlan Alpert <alan.alpert@nokia.com>2011-05-03 10:24:30 +1000
commit94c1a9d0e137a7c2adfd3ac86f3a439759306dc7 (patch)
tree312fbad7bb32036a02a26e1014afa18bc581ba1f /src/imports/particles/particleaffector.cpp
parentfc345a6c356fdcdd28a67d212bb6750b2f494634 (diff)
Affector Augmentation
Affectors gained shape and signal properties, and the affected(x,y) signal (turned on by the signal property, a theorized performance improvement).
Diffstat (limited to 'src/imports/particles/particleaffector.cpp')
-rw-r--r--src/imports/particles/particleaffector.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/imports/particles/particleaffector.cpp b/src/imports/particles/particleaffector.cpp
index 0d7bab577d..73564a940a 100644
--- a/src/imports/particles/particleaffector.cpp
+++ b/src/imports/particles/particleaffector.cpp
@@ -43,7 +43,8 @@
#include <QDebug>
QT_BEGIN_NAMESPACE
ParticleAffector::ParticleAffector(QSGItem *parent) :
- QSGItem(parent), m_needsReset(false), m_system(0), m_active(true), m_updateIntSet(false)
+ QSGItem(parent), m_needsReset(false), m_system(0), m_active(true)
+ , m_updateIntSet(false), m_shape(new ParticleExtruder(this)), m_signal(false)
{
connect(this, SIGNAL(systemChanged(ParticleSystem*)),
this, SLOT(updateOffsets()));
@@ -82,11 +83,16 @@ void ParticleAffector::affectSystem(qreal dt)
if(!d || (m_onceOff && m_onceOffed.contains(d->systemIndex)))
continue;
if(m_groups.isEmpty() || m_groups.contains(d->group)){
- if(width() == 0 || height() == 0 || QRectF(m_offset.x(), m_offset.y(), width(), height()).contains(d->curX(), d->curY())){
+ //Need to have previous location for affected. if signal || shape might be faster?
+ QPointF curPos = QPointF(d->curX(), d->curY());
+ if(width() == 0 || height() == 0
+ || m_shape->contains(QRectF(m_offset.x(), m_offset.y(), width(), height()),curPos)){
if(affectParticle(d, dt)){
m_system->m_needsReset << d;
if(m_onceOff)
m_onceOffed << d->systemIndex;
+ if(m_signal)
+ emit affected(curPos.x(), curPos.y());
}
}
}