diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2016-06-07 13:49:37 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2016-06-08 05:53:56 +0000 |
commit | b1ace55369a4f4659b4eb6326142a50c2d279424 (patch) | |
tree | f717fc395af6c300e12a93164bd86a032c394e4e /src/core/transforms | |
parent | e6ba9998b11ace2b875eebda62d44ea91c74d0b0 (diff) |
QTransform: remove parameter from matrixChanged
In order to reduce the overhead cost of composing the matrix when the
rotation, scale and/or translation are changed, it is only performed when the
getter matrix() is called.
That means that emitting a signal matrixChanged(QMatrix4x4) would force
the composition when setting the scale, rotation or translation which defeats
the purpose.
The parameter was therefore removed from the matrixChanged signal so that it
can be emitted whenever scale, rotation, translation are changed without the
overhead cost of computing the matrix.
Change-Id: I2e69fb24b4ac1dadc4af3bc5474467e4853a83ed
Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
Diffstat (limited to 'src/core/transforms')
-rw-r--r-- | src/core/transforms/qtransform.cpp | 26 | ||||
-rw-r--r-- | src/core/transforms/qtransform.h | 2 |
2 files changed, 26 insertions, 2 deletions
diff --git a/src/core/transforms/qtransform.cpp b/src/core/transforms/qtransform.cpp index f96267b74..22e48b266 100644 --- a/src/core/transforms/qtransform.cpp +++ b/src/core/transforms/qtransform.cpp @@ -215,7 +215,8 @@ void QTransform::setMatrix(const QMatrix4x4 &m) emit translationChanged(t); const bool wasBlocked = blockNotifications(true); - emit matrixChanged(m); + emit matrixChanged(); + emit scaleChanged(d->m_scale.x()); emit rotationXChanged(d->m_eulerRotationAngles.x()); emit rotationYChanged(d->m_eulerRotationAngles.y()); emit rotationZChanged(d->m_eulerRotationAngles.z()); @@ -240,6 +241,7 @@ void QTransform::setRotationX(float rotationX) const bool wasBlocked = blockNotifications(true); emit rotationXChanged(rotationX); + emit matrixChanged(); blockNotifications(wasBlocked); } @@ -260,6 +262,7 @@ void QTransform::setRotationY(float rotationY) const bool wasBlocked = blockNotifications(true); emit rotationYChanged(rotationY); + emit matrixChanged(); blockNotifications(wasBlocked); } @@ -279,6 +282,7 @@ void QTransform::setRotationZ(float rotationZ) const bool wasBlocked = blockNotifications(true); emit rotationZChanged(rotationZ); + emit matrixChanged(); blockNotifications(wasBlocked); } @@ -337,6 +341,10 @@ void QTransform::setScale3D(const QVector3D &scale) d->m_scale = scale; d->m_matrixDirty = true; emit scale3DChanged(scale); + + const bool wasBlocked = blockNotifications(true); + emit matrixChanged(); + blockNotifications(wasBlocked); } } @@ -356,6 +364,7 @@ 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(scale); blockNotifications(wasBlocked); @@ -379,9 +388,20 @@ void QTransform::setRotation(const QQuaternion &rotation) Q_D(QTransform); if (rotation != d->m_rotation) { d->m_rotation = rotation; + const QVector3D oldRotation = d->m_eulerRotationAngles; d->m_eulerRotationAngles = d->m_rotation.toEulerAngles(); d->m_matrixDirty = true; emit rotationChanged(rotation); + + const bool wasBlocked = blockNotifications(true); + emit matrixChanged(); + if (d->m_eulerRotationAngles.x() != oldRotation.x()) + emit rotationXChanged(d->m_eulerRotationAngles.x()); + if (d->m_eulerRotationAngles.y() != oldRotation.y()) + emit rotationYChanged(d->m_eulerRotationAngles.y()); + if (d->m_eulerRotationAngles.z() != oldRotation.z()) + emit rotationZChanged(d->m_eulerRotationAngles.z()); + blockNotifications(wasBlocked); } } @@ -403,6 +423,10 @@ void QTransform::setTranslation(const QVector3D &translation) d->m_translation = translation; d->m_matrixDirty = true; emit translationChanged(translation); + + const bool wasBlocked = blockNotifications(true); + emit matrixChanged(); + blockNotifications(wasBlocked); } } diff --git a/src/core/transforms/qtransform.h b/src/core/transforms/qtransform.h index 9dcab1108..25b1da8cd 100644 --- a/src/core/transforms/qtransform.h +++ b/src/core/transforms/qtransform.h @@ -108,7 +108,7 @@ Q_SIGNALS: void scale3DChanged(const QVector3D &scale); void rotationChanged(const QQuaternion &rotation); void translationChanged(const QVector3D &translation); - void matrixChanged(const QMatrix4x4 &matrix); + void matrixChanged(); void rotationXChanged(float rotationX); void rotationYChanged(float rotationY); void rotationZChanged(float rotationZ); |