aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-09-22 13:42:21 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-22 07:22:09 +0200
commitcc3f830c030e271f258bb330e5bc1fc400196389 (patch)
treeb352a4144fb62e9304e23d8f5e00fcf3416f67e5 /src
parent7100a74def3a82bc52c93b800cec973bf312b1b3 (diff)
Tighter bounding box check
Because the gernic check works on floats and how .toPoint rounds, we need to redo the bounds checking inside Turbulence Task-number: QTBUG-21564 Change-Id: Ib56a8d420d9abf8035360b7908e89e28938799a8 Reviewed-on: http://codereview.qt-project.org/5343 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/particles/qsgturbulence.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/declarative/particles/qsgturbulence.cpp b/src/declarative/particles/qsgturbulence.cpp
index aa5dfeb0bc..ac1306bd82 100644
--- a/src/declarative/particles/qsgturbulence.cpp
+++ b/src/declarative/particles/qsgturbulence.cpp
@@ -136,7 +136,9 @@ void QSGTurbulenceAffector::initializeGrid()
for (int i=0; i<m_gridSize; i++)
m_vectorField[i] = (QPointF*)malloc(m_gridSize * sizeof(QPointF));
- QImage image = QImage(m_noiseSource.toLocalFile()).scaled(QSize(m_gridSize, m_gridSize));
+ QImage image;
+ if (!m_noiseSource.isEmpty())
+ image = QImage(m_noiseSource.toLocalFile()).scaled(QSize(m_gridSize, m_gridSize));
if (image.isNull())
image = QImage(":defaultshaders/noise.png").scaled(QSize(m_gridSize, m_gridSize));
@@ -177,9 +179,12 @@ void QSGTurbulenceAffector::affectSystem(qreal dt)
if (!m_system || !m_enabled)
return;
ensureInit();
+ if (!m_gridSize)
+ return;
+
updateOffsets();//### Needed if an ancestor is transformed.
- QRectF boundsRect(0, 0, width()-1, height()-1);
+ QRect boundsRect(0,0,m_gridSize,m_gridSize);
foreach (QSGParticleGroupData *gd, m_system->m_groupData){
if (!activeGroup(m_system->m_groupData.key(gd)))
continue;
@@ -187,6 +192,8 @@ void QSGTurbulenceAffector::affectSystem(qreal dt)
if (!shouldAffect(d))
continue;
QPoint pos = (QPointF(d->curX(), d->curY()) - m_offset).toPoint();
+ if (!boundsRect.contains(pos,true))//Need to redo bounds checking due to quantization.
+ continue;
qreal fx = 0.0;
qreal fy = 0.0;
fx += m_vectorField[pos.x()][pos.y()].x() * m_strength;