summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/render/lights/qspotlight.cpp5
-rw-r--r--tests/auto/render/qabstractlight/tst_qabstractlight.cpp2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/render/lights/qspotlight.cpp b/src/render/lights/qspotlight.cpp
index 54ed8da63..81c18387b 100644
--- a/src/render/lights/qspotlight.cpp
+++ b/src/render/lights/qspotlight.cpp
@@ -221,8 +221,9 @@ void QSpotLight::setLocalDirection(const QVector3D &direction)
{
Q_D(QSpotLight);
if (localDirection() != direction) {
- d->m_shaderData->setProperty("direction", direction);
- emit localDirectionChanged(direction);
+ const QVector3D dir = direction.normalized();
+ d->m_shaderData->setProperty("direction", dir);
+ emit localDirectionChanged(dir);
}
}
diff --git a/tests/auto/render/qabstractlight/tst_qabstractlight.cpp b/tests/auto/render/qabstractlight/tst_qabstractlight.cpp
index 68fc2cd30..bc67148d2 100644
--- a/tests/auto/render/qabstractlight/tst_qabstractlight.cpp
+++ b/tests/auto/render/qabstractlight/tst_qabstractlight.cpp
@@ -276,7 +276,7 @@ private Q_SLOTS:
change = arbiter.events[2].staticCast<Qt3DCore::QPropertyUpdatedChange>();
QCOMPARE(change->propertyName(), "localDirection");
QCOMPARE(change->subjectId(), spotLight->id());
- QCOMPARE(change->value().value<QVector3D>(), QVector3D(0.5f, 0.0f, -1.0f));
+ QCOMPARE(change->value().value<QVector3D>(), QVector3D(0.5f, 0.0f, -1.0f).normalized());
QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
change = arbiter.events[3].staticCast<Qt3DCore::QPropertyUpdatedChange>();
QCOMPARE(change->propertyName(), "cutOffAngle");