summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2015-10-26 20:14:56 +0000
committerAndy Nichols <andy.nichols@theqtcompany.com>2015-11-16 16:10:43 +0000
commit642dfa0e16dcd5844c544255d8f1b55ac4ec7914 (patch)
treed70e51afc0afee34e08a576527adf2c866c173f5
parentc81352d80fe903c0701127fe7ed130325e29437f (diff)
Change scale property to scale3D and provide uniform scale property
Change-Id: I34625b2b8beab9b7bd5b2dde44666614c35632e7 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
-rw-r--r--src/core/transforms/qtransform.cpp25
-rw-r--r--src/core/transforms/qtransform.h10
-rw-r--r--src/render/backend/transform.cpp4
3 files changed, 30 insertions, 9 deletions
diff --git a/src/core/transforms/qtransform.cpp b/src/core/transforms/qtransform.cpp
index 3409b8a03..b7f925c5b 100644
--- a/src/core/transforms/qtransform.cpp
+++ b/src/core/transforms/qtransform.cpp
@@ -122,7 +122,7 @@ void QTransform::copy(const QNode *ref)
// transformations applied
d_func()->m_matrix = transform->matrix();
d_func()->m_rotation = transform->rotation();
- d_func()->m_scale = transform->scale();
+ d_func()->m_scale = transform->scale3D();
d_func()->m_translation = transform->translation();
}
@@ -165,21 +165,38 @@ QMatrix4x4 QTransform::matrix() const
return d->m_matrix;
}
-void QTransform::setScale(const QVector3D &scale)
+void QTransform::setScale3D(const QVector3D &scale)
{
Q_D(QTransform);
if (scale != d->m_scale) {
d->m_scale = scale;
- emit scaleChanged();
+ emit scale3DChanged();
}
}
-QVector3D QTransform::scale() const
+QVector3D QTransform::scale3D() const
{
Q_D(const QTransform);
return d->m_scale;
}
+void QTransform::setScale(float scale)
+{
+ Q_D(QTransform);
+ if (scale != d->m_scale.x()) {
+ setScale3D(QVector3D(scale, scale, scale));
+ const bool wasBlocked = blockNotifications(true);
+ emit scaleChanged();
+ blockNotifications(wasBlocked);
+ }
+}
+
+float QTransform::scale() const
+{
+ Q_D(const QTransform);
+ return d->m_scale.x();
+}
+
void QTransform::setRotation(const QQuaternion &rotation)
{
Q_D(QTransform);
diff --git a/src/core/transforms/qtransform.h b/src/core/transforms/qtransform.h
index 70f991425..6b7c1dbb2 100644
--- a/src/core/transforms/qtransform.h
+++ b/src/core/transforms/qtransform.h
@@ -54,7 +54,8 @@ class QT3DCORESHARED_EXPORT QTransform : public QComponent
{
Q_OBJECT
Q_PROPERTY(QMatrix4x4 matrix READ matrix NOTIFY matrixChanged)
- Q_PROPERTY(QVector3D scale READ scale WRITE setScale NOTIFY scaleChanged)
+ Q_PROPERTY(float scale READ scale WRITE setScale NOTIFY scaleChanged)
+ Q_PROPERTY(QVector3D scale3D READ scale3D WRITE setScale3D NOTIFY scale3DChanged)
Q_PROPERTY(QQuaternion rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(QVector3D translation READ translation WRITE setTranslation NOTIFY translationChanged)
@@ -70,12 +71,14 @@ public:
QMatrix4x4 matrix() const;
- QVector3D scale() const;
+ float scale() const;
+ QVector3D scale3D() const;
QQuaternion rotation() const;
QVector3D translation() const;
public Q_SLOTS:
- void setScale(const QVector3D &scale);
+ void setScale(float scale);
+ void setScale3D(const QVector3D &scale);
void setRotation(const QQuaternion &rotation);
void setTranslation(const QVector3D &translation);
@@ -84,6 +87,7 @@ Q_SIGNALS:
void transformsChanged();
void scaleChanged();
+ void scale3DChanged();
void rotationChanged();
void translationChanged();
diff --git a/src/render/backend/transform.cpp b/src/render/backend/transform.cpp
index 7af120233..c5cc52671 100644
--- a/src/render/backend/transform.cpp
+++ b/src/render/backend/transform.cpp
@@ -60,7 +60,7 @@ void Transform::updateFromPeer(Qt3DCore::QNode *peer)
Qt3DCore::QTransform *transform = static_cast<Qt3DCore::QTransform *>(peer);
m_rotation = transform->rotation();
- m_scale = transform->scale();
+ m_scale = transform->scale3D();
m_translation = transform->translation();
updateMatrix();
m_enabled = transform->isEnabled();
@@ -76,7 +76,7 @@ void Transform::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
// TODO: Flag the matrix as dirty and update all matrices batched in a job
if (e->type() == NodeUpdated) {
const QScenePropertyChangePtr &propertyChange = qSharedPointerCast<QScenePropertyChange>(e);
- if (propertyChange->propertyName() == QByteArrayLiteral("scale")) {
+ if (propertyChange->propertyName() == QByteArrayLiteral("scale3D")) {
m_scale = propertyChange->value().value<QVector3D>();
updateMatrix();
} else if (propertyChange->propertyName() == QByteArrayLiteral("rotation")) {