| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquickfriction.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | static qreal sign(qreal a) | - | ||||||||||||
| 4 | { | - | ||||||||||||
| 5 | return executed 98808 times by 1 test: a >= 0 ? 1 : -1;return a >= 0 ? 1 : -1;Executed by:
executed 98808 times by 1 test: return a >= 0 ? 1 : -1;Executed by:
| 98808 | ||||||||||||
| 6 | } | - | ||||||||||||
| 7 | - | |||||||||||||
| 8 | static const qreal epsilon = 0.00001; | - | ||||||||||||
| 9 | - | |||||||||||||
| 10 | QQuickFrictionAffector::QQuickFrictionAffector(QQuickItem *parent) : | - | ||||||||||||
| 11 | QQuickParticleAffector(parent), m_factor(0.0), m_threshold(0.0) | - | ||||||||||||
| 12 | { | - | ||||||||||||
| 13 | } executed 10 times by 2 tests: end of blockExecuted by:
| 10 | ||||||||||||
| 14 | - | |||||||||||||
| 15 | bool QQuickFrictionAffector::affectParticle(QQuickParticleData *d, qreal dt) | - | ||||||||||||
| 16 | { | - | ||||||||||||
| 17 | if (!m_factor
| 0-93378 | ||||||||||||
| 18 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||
| 19 | qreal curVX = d->curVX(m_system); | - | ||||||||||||
| 20 | qreal curVY = d->curVY(m_system); | - | ||||||||||||
| 21 | if (!curVX
| 0-48902 | ||||||||||||
| 22 | return executed 44476 times by 1 test: false;return false;Executed by:
executed 44476 times by 1 test: return false;Executed by:
| 44476 | ||||||||||||
| 23 | qreal newVX = curVX + (curVX * m_factor * -1 * dt); | - | ||||||||||||
| 24 | qreal newVY = curVY + (curVY * m_factor * -1 * dt); | - | ||||||||||||
| 25 | - | |||||||||||||
| 26 | if (!m_threshold
| 24062-24840 | ||||||||||||
| 27 | if (sign(curVX) != sign(newVX)
| 1216-22846 | ||||||||||||
| 28 | newVX = 0; executed 1216 times by 1 test: newVX = 0;Executed by:
| 1216 | ||||||||||||
| 29 | if (sign(curVY) != sign(newVY)
| 0-24062 | ||||||||||||
| 30 | newVY = 0; never executed: newVY = 0; | 0 | ||||||||||||
| 31 | } executed 24062 times by 1 test: else {end of blockExecuted by:
| 24062 | ||||||||||||
| 32 | qreal curMag = qSqrt(curVX*curVX + curVY*curVY); | - | ||||||||||||
| 33 | if (curMag <= m_threshold + epsilon
| 1280-23560 | ||||||||||||
| 34 | return executed 23560 times by 1 test: false;return false;Executed by:
executed 23560 times by 1 test: return false;Executed by:
| 23560 | ||||||||||||
| 35 | qreal newMag = qSqrt(newVX*newVX + newVY*newVY); | - | ||||||||||||
| 36 | if (newMag <= m_threshold + epsilon
| 0-1280 | ||||||||||||
| 37 | sign(curVX) != sign(newVX)
| 0-1280 | ||||||||||||
| 38 | sign(curVY) != sign(newVY)
| 0 | ||||||||||||
| 39 | qreal theta = qAtan2(curVY, curVX); | - | ||||||||||||
| 40 | newVX = m_threshold * qCos(theta); | - | ||||||||||||
| 41 | newVY = m_threshold * qSin(theta); | - | ||||||||||||
| 42 | } executed 1280 times by 1 test: end of blockExecuted by:
| 1280 | ||||||||||||
| 43 | } executed 1280 times by 1 test: end of blockExecuted by:
| 1280 | ||||||||||||
| 44 | - | |||||||||||||
| 45 | d->setInstantaneousVX(newVX, m_system); | - | ||||||||||||
| 46 | d->setInstantaneousVY(newVY, m_system); | - | ||||||||||||
| 47 | return executed 25342 times by 1 test: true;return true;Executed by:
executed 25342 times by 1 test: return true;Executed by:
| 25342 | ||||||||||||
| 48 | } | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | - | |||||||||||||
| Switch to Source code | Preprocessed file |