| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquickcustomaffector.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | QQuickCustomAffector::QQuickCustomAffector(QQuickItem *parent) : | - | ||||||||||||||||||
| 3 | QQuickParticleAffector(parent) | - | ||||||||||||||||||
| 4 | , m_position(&m_nullVector) | - | ||||||||||||||||||
| 5 | , m_velocity(&m_nullVector) | - | ||||||||||||||||||
| 6 | , m_acceleration(&m_nullVector) | - | ||||||||||||||||||
| 7 | , m_relative(true) | - | ||||||||||||||||||
| 8 | { | - | ||||||||||||||||||
| 9 | } executed 24 times by 3 tests: end of blockExecuted by:
| 24 | ||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | bool QQuickCustomAffector::isAffectConnected() | - | ||||||||||||||||||
| 12 | { | - | ||||||||||||||||||
| 13 | do { QObject *sender = (this); void (QQuickCustomAffector::*signal)(QQmlV4Handle,qreal) = &QQuickCustomAffector::affectParticles; static QMetaMethod method = QMetaMethod::fromSignal(signal); static int signalIdx = QMetaObjectPrivate::signalIndex(method); return executed 324 times by 1 test: QObjectPrivate::get(sender)->isSignalConnected(signalIdx);return QObjectPrivate::get(sender)->isSignalConnected(signalIdx);Executed by:
executed 324 times by 1 test: } while (0);return QObjectPrivate::get(sender)->isSignalConnected(signalIdx);Executed by:
| 324 | ||||||||||||||||||
| 14 | } never executed: end of block | 0 | ||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | void QQuickCustomAffector::affectSystem(qreal dt) | - | ||||||||||||||||||
| 17 | { | - | ||||||||||||||||||
| 18 | - | |||||||||||||||||||
| 19 | bool justAffected = (m_acceleration == &m_nullVector
| 81-243 | ||||||||||||||||||
| 20 | && m_velocity == &m_nullVector
| 0-243 | ||||||||||||||||||
| 21 | && m_position == &m_nullVector
| 82-161 | ||||||||||||||||||
| 22 | && isAffectedConnected()
| 79-82 | ||||||||||||||||||
| 23 | if (!isAffectConnected()
| 79-245 | ||||||||||||||||||
| 24 | QQuickParticleAffector::affectSystem(dt); | - | ||||||||||||||||||
| 25 | return; executed 163 times by 1 test: return;Executed by:
| 163 | ||||||||||||||||||
| 26 | } | - | ||||||||||||||||||
| 27 | if (!m_enabled
| 0-161 | ||||||||||||||||||
| 28 | return; never executed: return; | 0 | ||||||||||||||||||
| 29 | updateOffsets(); | - | ||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | QList<QQuickParticleData*> toAffect; | - | ||||||||||||||||||
| 32 | for (auto _container_ = QtPrivate::qMakeForeachContainer(m_system->groupData); _container_.control
| 0-322 | ||||||||||||||||||
| 33 | if (activeGroup(gd->index)
| 0-161 | ||||||||||||||||||
| 34 | for (auto _container_ = QtPrivate::qMakeForeachContainer(gd->data); _container_.control
| 0-80661 | ||||||||||||||||||
| 35 | if (shouldAffect(d)
| 2512-77988 | ||||||||||||||||||
| 36 | toAffect << d; | - | ||||||||||||||||||
| 37 | } executed 2512 times by 1 test: end of blockExecuted by:
| 2512 | ||||||||||||||||||
| 38 | } executed 80500 times by 1 test: end of blockExecuted by:
| 80500 | ||||||||||||||||||
| 39 | } executed 161 times by 1 test: end of blockExecuted by:
| 161 | ||||||||||||||||||
| 40 | } executed 161 times by 1 test: end of blockExecuted by:
| 161 | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | if (toAffect.isEmpty()
| 4-157 | ||||||||||||||||||
| 43 | return; executed 4 times by 1 test: return;Executed by:
| 4 | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | if (justAffected
| 77-80 | ||||||||||||||||||
| 46 | for (auto _container_ = QtPrivate::qMakeForeachContainer(toAffect); _container_.control
| 0-1360 | ||||||||||||||||||
| 47 | if (m_onceOff
| 0-1280 | ||||||||||||||||||
| 48 | m_onceOffed << qMakePair(d->groupId, d->index); executed 1280 times by 1 test: m_onceOffed << qMakePair(d->groupId, d->index);Executed by:
| 1280 | ||||||||||||||||||
| 49 | affected(d->curX(m_system), d->curY(m_system)); | - | ||||||||||||||||||
| 50 | } executed 1280 times by 1 test: end of blockExecuted by:
| 1280 | ||||||||||||||||||
| 51 | return; executed 80 times by 1 test: return;Executed by:
| 80 | ||||||||||||||||||
| 52 | } | - | ||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | if (m_onceOff
| 0-77 | ||||||||||||||||||
| 55 | dt = 1.0; executed 77 times by 1 test: dt = 1.0;Executed by:
| 77 | ||||||||||||||||||
| 56 | - | |||||||||||||||||||
| 57 | QQmlEngine *qmlEngine = ::qmlEngine(this); | - | ||||||||||||||||||
| 58 | QV4::ExecutionEngine *v4 = qmlEngine->handle(); | - | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | QV4::Scope scope(v4); | - | ||||||||||||||||||
| 61 | QV4::ScopedArrayObject array(scope, v4->newArrayObject(toAffect.size())); | - | ||||||||||||||||||
| 62 | QV4::ScopedValue v(scope); | - | ||||||||||||||||||
| 63 | for (int i=0; i<toAffect.size()
| 77-1232 | ||||||||||||||||||
| 64 | array->put(i, (v = toAffect[i]->v4Value(m_system))); executed 1232 times by 1 test: array->put(i, (v = toAffect[i]->v4Value(m_system)));Executed by:
| 1232 | ||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | if (dt >= simulationCutoff
| 0-77 | ||||||||||||||||||
| 67 | affectProperties(toAffect, dt); | - | ||||||||||||||||||
| 68 | affectParticles(QQmlV4Handle(array), dt); | - | ||||||||||||||||||
| 69 | } executed 77 times by 1 test: else {end of blockExecuted by:
| 77 | ||||||||||||||||||
| 70 | int realTime = m_system->timeInt; | - | ||||||||||||||||||
| 71 | m_system->timeInt -= dt * 1000.0; | - | ||||||||||||||||||
| 72 | while (dt > simulationDelta
| 0 | ||||||||||||||||||
| 73 | m_system->timeInt += simulationDelta * 1000.0; | - | ||||||||||||||||||
| 74 | dt -= simulationDelta; | - | ||||||||||||||||||
| 75 | affectProperties(toAffect, simulationDelta); | - | ||||||||||||||||||
| 76 | affectParticles(QQmlV4Handle(array), simulationDelta); | - | ||||||||||||||||||
| 77 | } never executed: end of block | 0 | ||||||||||||||||||
| 78 | m_system->timeInt = realTime; | - | ||||||||||||||||||
| 79 | if (dt > 0.0
| 0 | ||||||||||||||||||
| 80 | affectProperties(toAffect, dt); | - | ||||||||||||||||||
| 81 | affectParticles(QQmlV4Handle(array), dt); | - | ||||||||||||||||||
| 82 | } never executed: end of block | 0 | ||||||||||||||||||
| 83 | } never executed: end of block | 0 | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | for (auto _container_ = QtPrivate::qMakeForeachContainer(toAffect); _container_.control
| 0-1309 | ||||||||||||||||||
| 86 | if (d->update == 1.0
| 0-1232 | ||||||||||||||||||
| 87 | postAffect(d); executed 1232 times by 1 test: postAffect(d);Executed by:
| 1232 | ||||||||||||||||||
| 88 | } executed 77 times by 1 test: end of blockExecuted by:
| 77 | ||||||||||||||||||
| 89 | - | |||||||||||||||||||
| 90 | bool QQuickCustomAffector::affectParticle(QQuickParticleData *d, qreal dt) | - | ||||||||||||||||||
| 91 | { | - | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | bool changed = false; | - | ||||||||||||||||||
| 94 | QPointF curPos(d->curX(m_system), d->curY(m_system)); | - | ||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | if (m_acceleration != &m_nullVector
| 24342-26072 | ||||||||||||||||||
| 97 | QPointF pos = m_acceleration->sample(curPos); | - | ||||||||||||||||||
| 98 | QPointF curAcc = QPointF(d->curAX(), d->curAY()); | - | ||||||||||||||||||
| 99 | if (m_relative
| 0-24342 | ||||||||||||||||||
| 100 | pos *= dt; | - | ||||||||||||||||||
| 101 | pos += curAcc; | - | ||||||||||||||||||
| 102 | } never executed: end of block | 0 | ||||||||||||||||||
| 103 | if (pos != curAcc
| 1264-23078 | ||||||||||||||||||
| 104 | d->setInstantaneousAX(pos.x(), m_system); | - | ||||||||||||||||||
| 105 | d->setInstantaneousAY(pos.y(), m_system); | - | ||||||||||||||||||
| 106 | changed = true; | - | ||||||||||||||||||
| 107 | } executed 1264 times by 1 test: end of blockExecuted by:
| 1264 | ||||||||||||||||||
| 108 | } executed 24342 times by 1 test: end of blockExecuted by:
| 24342 | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | if (m_velocity != &m_nullVector
| 24342-26072 | ||||||||||||||||||
| 111 | QPointF pos = m_velocity->sample(curPos); | - | ||||||||||||||||||
| 112 | QPointF curVel = QPointF(d->curVX(m_system), d->curVY(m_system)); | - | ||||||||||||||||||
| 113 | if (m_relative
| 0-24342 | ||||||||||||||||||
| 114 | pos *= dt; | - | ||||||||||||||||||
| 115 | pos += curVel; | - | ||||||||||||||||||
| 116 | } never executed: end of block | 0 | ||||||||||||||||||
| 117 | if (pos != curVel
| 0-24342 | ||||||||||||||||||
| 118 | d->setInstantaneousVX(pos.x(), m_system); | - | ||||||||||||||||||
| 119 | d->setInstantaneousVY(pos.y(), m_system); | - | ||||||||||||||||||
| 120 | changed = true; | - | ||||||||||||||||||
| 121 | } executed 24342 times by 1 test: end of blockExecuted by:
| 24342 | ||||||||||||||||||
| 122 | } executed 24342 times by 1 test: end of blockExecuted by:
| 24342 | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | if (m_position != &m_nullVector
| 1232-49182 | ||||||||||||||||||
| 125 | QPointF pos = m_position->sample(curPos); | - | ||||||||||||||||||
| 126 | if (m_relative
| 0-49182 | ||||||||||||||||||
| 127 | pos *= dt; | - | ||||||||||||||||||
| 128 | pos += curPos; | - | ||||||||||||||||||
| 129 | } never executed: end of block | 0 | ||||||||||||||||||
| 130 | if (pos != curPos
| 24342-24840 | ||||||||||||||||||
| 131 | d->setInstantaneousX(pos.x(), m_system); | - | ||||||||||||||||||
| 132 | d->setInstantaneousY(pos.y(), m_system); | - | ||||||||||||||||||
| 133 | changed = true; | - | ||||||||||||||||||
| 134 | } executed 24342 times by 1 test: end of blockExecuted by:
| 24342 | ||||||||||||||||||
| 135 | } executed 49182 times by 1 test: end of blockExecuted by:
| 49182 | ||||||||||||||||||
| 136 | - | |||||||||||||||||||
| 137 | return executed 50414 times by 1 test: changed;return changed;Executed by:
executed 50414 times by 1 test: return changed;Executed by:
| 50414 | ||||||||||||||||||
| 138 | } | - | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | void QQuickCustomAffector::affectProperties(const QList<QQuickParticleData*> particles, qreal dt) | - | ||||||||||||||||||
| 141 | { | - | ||||||||||||||||||
| 142 | for (auto _container_ = QtPrivate::qMakeForeachContainer(particles); _container_.control
| 0-1309 | ||||||||||||||||||
| 143 | if ( affectParticle(d, dt)
| 0-1232 | ||||||||||||||||||
| 144 | d->update = 1.0; never executed: d->update = 1.0; | 0 | ||||||||||||||||||
| 145 | } executed 77 times by 1 test: end of blockExecuted by:
| 77 | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |