diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-12-04 15:56:24 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-12-07 08:04:14 +0000 |
commit | 99779070942cf6ff34f7c558fbd256696a993e5d (patch) | |
tree | 2360216bd8e81f69008a3097ea603fa9c3a175af /tests | |
parent | bd58f31f23711acda2462f1c1d05728307e625ca (diff) |
Indicate light type
Having a dedicated type field is required not just to make the shaders
cleaner but also to avoid incorrect results when lights get moved around in
the scene. Currently the shaders rely on the direction uniform to distinguish
directional lights from the others, but this cannot work when the elements
in the lights uniform array change, potentially leaving type-specific members
like direction set when a point light takes the same index.
Change-Id: I170e4b471c8cd9b4a23eca49690239c01944b3e6
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/render/qlight/tst_qlight.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/auto/render/qlight/tst_qlight.cpp b/tests/auto/render/qlight/tst_qlight.cpp index 1858f149b..62508beb2 100644 --- a/tests/auto/render/qlight/tst_qlight.cpp +++ b/tests/auto/render/qlight/tst_qlight.cpp @@ -73,12 +73,14 @@ private Q_SLOTS: void checkPointLightCloning() { Qt3DRender::QPointLight pointLight; + QCOMPARE(pointLight.type(), Qt3DRender::QLight::PointLight); pointLight.setColor(Qt::green); pointLight.setIntensity(0.5f); pointLight.setAttenuation(QVector3D(0.5f, 0.0f, 1.0f)); QScopedPointer<Qt3DRender::QPointLight> pointLightClone(static_cast<Qt3DRender::QPointLight *>(QNode::clone(&pointLight))); QVERIFY(pointLightClone.data()); + QCOMPARE(pointLightClone->type(), Qt3DRender::QLight::PointLight); QCOMPARE(pointLight.color(), pointLightClone->color()); QCOMPARE(pointLight.intensity(), pointLightClone->intensity()); QCOMPARE(pointLight.attenuation(), pointLightClone->attenuation()); @@ -87,12 +89,14 @@ private Q_SLOTS: void checkDirectionalLightCloning() { Qt3DRender::QDirectionalLight dirLight; + QCOMPARE(dirLight.type(), Qt3DRender::QLight::DirectionalLight); dirLight.setColor(Qt::blue); dirLight.setIntensity(0.5f); dirLight.setDirection(QVector3D(0, 0, -1)); QScopedPointer<Qt3DRender::QDirectionalLight> dirLightClone(static_cast<Qt3DRender::QDirectionalLight *>(QNode::clone(&dirLight))); QVERIFY(dirLightClone.data()); + QCOMPARE(dirLightClone->type(), Qt3DRender::QLight::DirectionalLight); QCOMPARE(dirLight.color(), dirLightClone->color()); QCOMPARE(dirLight.intensity(), dirLightClone->intensity()); QCOMPARE(dirLight.direction(), dirLightClone->direction()); @@ -101,6 +105,7 @@ private Q_SLOTS: void checkSpotLightCloning() { Qt3DRender::QSpotLight spotLight; + QCOMPARE(spotLight.type(), Qt3DRender::QLight::SpotLight); spotLight.setColor(Qt::lightGray); spotLight.setIntensity(0.5f); spotLight.setDirection(QVector3D(0, 0, -1)); @@ -108,6 +113,7 @@ private Q_SLOTS: QScopedPointer<Qt3DRender::QSpotLight> spotLightClone(static_cast<Qt3DRender::QSpotLight *>(QNode::clone(&spotLight))); QVERIFY(spotLightClone.data()); + QCOMPARE(spotLightClone->type(), Qt3DRender::QLight::SpotLight); QCOMPARE(spotLight.color(), spotLightClone->color()); QCOMPARE(spotLight.intensity(), spotLightClone->intensity()); QCOMPARE(spotLight.direction(), spotLightClone->direction()); |