diff options
-rw-r--r-- | src/core/transforms/qtransform.cpp | 25 | ||||
-rw-r--r-- | src/core/transforms/qtransform.h | 10 | ||||
-rw-r--r-- | src/render/backend/transform.cpp | 4 |
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")) { |