diff options
author | Robert Brock <robert.brock@kdab.com> | 2016-04-18 12:08:23 +0100 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@theqtcompany.com> | 2016-04-19 04:07:45 +0000 |
commit | d5b665cb40c25ff8ddb5ad7ebe74e04dd91c045b (patch) | |
tree | dbef72318b5a9c23fdff84813aab20be9d5c1106 /src | |
parent | 22fc2e750d88708691a33a54798a665b0c05a32f (diff) |
QSpotLight API inconsistency addressed
The access of attenuation values for both
QSpotLight and QPointLight were different.
This has now been addressed and QSpotLight
works like QPointLight.
Change-Id: I79c64e0a58c234326a7c6b01e15c49034586769a
Task-number: QTBUG-52646
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/render/lights/qspotlight.cpp | 75 | ||||
-rw-r--r-- | src/render/lights/qspotlight.h | 17 | ||||
-rw-r--r-- | src/render/lights/qspotlight_p.h | 7 |
3 files changed, 45 insertions, 54 deletions
diff --git a/src/render/lights/qspotlight.cpp b/src/render/lights/qspotlight.cpp index a91a828dc..caf8d943e 100644 --- a/src/render/lights/qspotlight.cpp +++ b/src/render/lights/qspotlight.cpp @@ -67,7 +67,9 @@ namespace Qt3DRender { QSpotLightPrivate::QSpotLightPrivate() : QLightPrivate(QLight::SpotLight) - , m_attenuation(0.0f, 0.0f, 0.002f) + , m_constantAttenuation(0.0f) + , m_linearAttenuation(0.0f) + , m_quadraticAttenuation(0.002f) , m_localDirection(0.0f, -1.0f, 0.0f) , m_cutOffAngle(45.0f) { @@ -127,28 +129,49 @@ QSpotLight::QSpotLight(QSpotLightPrivate &dd, QNode *parent) */ -QVector3D QSpotLight::attenuation() const +float QSpotLight::constantAttenuation() const { Q_D(const QSpotLight); - return d->m_attenuation; + return d->m_constantAttenuation; } -float QSpotLight::constantAttenuation() const +void QSpotLight::setConstantAttenuation(float value) { - Q_D(const QSpotLight); - return d->m_attenuation.x(); + Q_D(QSpotLight); + if (d->m_constantAttenuation != value) { + d->m_constantAttenuation = value; + emit constantAttenuationChanged(value); + } } float QSpotLight::linearAttenuation() const { Q_D(const QSpotLight); - return d->m_attenuation.y(); + return d->m_linearAttenuation; +} + +void QSpotLight::setLinearAttenuation(float value) +{ + Q_D(QSpotLight); + if (d->m_linearAttenuation != value) { + d->m_linearAttenuation = value; + emit linearAttenuationChanged(value); + } } float QSpotLight::quadraticAttenuation() const { Q_D(const QSpotLight); - return d->m_attenuation.z(); + return d->m_quadraticAttenuation; +} + +void QSpotLight::setQuadraticAttenuation(float value) +{ + Q_D(QSpotLight); + if (d->m_quadraticAttenuation != value) { + d->m_quadraticAttenuation = value; + emit quadraticAttenuationChanged(value); + } } QVector3D QSpotLight::localDirection() const @@ -173,42 +196,6 @@ float QSpotLight::cutOffAngle() const return d->m_cutOffAngle; } -void QSpotLight::setAttenuation(const QVector3D &value) -{ - Q_D(QSpotLight); - if (d->m_attenuation != value) { - d->m_attenuation = value; - emit attenuationChanged(value); - } -} - -void QSpotLight::setConstantAttenuation(float value) -{ - Q_D(QSpotLight); - if (d->m_attenuation.x() != value) { - d->m_attenuation.setX(value); - emit attenuationChanged(d->m_attenuation); - } -} - -void QSpotLight::setLinearAttenuation(float value) -{ - Q_D(QSpotLight); - if (d->m_attenuation.y() != value) { - d->m_attenuation.setY(value); - emit attenuationChanged(d->m_attenuation); - } -} - -void QSpotLight::setQuadraticAttenuation(float value) -{ - Q_D(QSpotLight); - if (d->m_attenuation.z() != value) { - d->m_attenuation.setZ(value); - emit attenuationChanged(d->m_attenuation); - } -} - void QSpotLight::setLocalDirection(const QVector3D &localDirection) { Q_D(QSpotLight); diff --git a/src/render/lights/qspotlight.h b/src/render/lights/qspotlight.h index 3a477c4e4..a02809082 100644 --- a/src/render/lights/qspotlight.h +++ b/src/render/lights/qspotlight.h @@ -51,7 +51,9 @@ class QSpotLightPrivate; class QT3DRENDERSHARED_EXPORT QSpotLight : public QLight { Q_OBJECT - Q_PROPERTY(QVector3D attenuation READ attenuation WRITE setAttenuation NOTIFY attenuationChanged) + Q_PROPERTY(float constantAttenuation READ constantAttenuation WRITE setConstantAttenuation NOTIFY constantAttenuationChanged) + Q_PROPERTY(float linearAttenuation READ linearAttenuation WRITE setLinearAttenuation NOTIFY linearAttenuationChanged) + Q_PROPERTY(float quadraticAttenuation READ quadraticAttenuation WRITE setQuadraticAttenuation NOTIFY quadraticAttenuationChanged) Q_PROPERTY(QVector3D localDirection READ localDirection WRITE setLocalDirection NOTIFY localDirectionChanged) Q_PROPERTY(float cutOffAngle READ cutOffAngle WRITE setCutOffAngle NOTIFY cutOffAngleChanged) @@ -63,21 +65,20 @@ public: float cutOffAngle() const; float constantAttenuation() const; - void setConstantAttenuation(float value); - float linearAttenuation() const; - void setLinearAttenuation(float value); - float quadraticAttenuation() const; - void setQuadraticAttenuation(float value); public Q_SLOTS: - void setAttenuation(const QVector3D &value); + void setConstantAttenuation(float value); + void setLinearAttenuation(float value); + void setQuadraticAttenuation(float value); void setLocalDirection(const QVector3D &localDirection); void setCutOffAngle(float cutOffAngle); Q_SIGNALS: - void attenuationChanged(const QVector3D &attenuation); + void constantAttenuationChanged(float constantAttenuation); + void linearAttenuationChanged(float linearAttenuation); + void quadraticAttenuationChanged(float quadraticAttenuation); void localDirectionChanged(const QVector3D &localDirection); void cutOffAngleChanged(float cutOffAngle); diff --git a/src/render/lights/qspotlight_p.h b/src/render/lights/qspotlight_p.h index 5279a131a..20d9b6042 100644 --- a/src/render/lights/qspotlight_p.h +++ b/src/render/lights/qspotlight_p.h @@ -64,11 +64,14 @@ class QSpotLightPrivate : public QLightPrivate public: QSpotLightPrivate(); - Q_DECLARE_PUBLIC(QSpotLight) - QVector3D m_attenuation; + float m_constantAttenuation; + float m_linearAttenuation; + float m_quadraticAttenuation; QVector3D m_localDirection; float m_cutOffAngle; + Q_DECLARE_PUBLIC(QSpotLight) + }; } // namespace Qt3DRender |