From 8b4539770da00ec98820352fcce89bd6d843f51d Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 18 Aug 2009 13:25:53 +1000 Subject: Optimize QMatrix4x4::rotate() for 0, 90, 180, 270 degrees. Reviewed-by: Sarah Smith --- src/gui/math3d/qmatrix4x4.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index dc17eda..8fc439b 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -1010,11 +1010,24 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector) */ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z) { + if (angle == 0.0f) + return *this; QMatrix4x4 m(1); // The "1" says to not load the identity. - qreal a = angle * M_PI / 180.0f; - qreal c = qCos(a); - qreal s = qSin(a); - qreal ic; + qreal c, s, ic; + if (angle == 90.0f || angle == -270.0f) { + s = 1.0f; + c = 0.0f; + } else if (angle == -90.0f || angle == 270.0f) { + s = -1.0f; + c = 0.0f; + } else if (angle == 180.0f || angle == -180.0f) { + s = 0.0f; + c = -1.0f; + } else { + qreal a = angle * M_PI / 180.0f; + c = qCos(a); + s = qSin(a); + } bool quick = false; if (x == 0.0f) { if (y == 0.0f) { -- cgit v0.12 From 1ddf4ae979e3b573f45a99ac92838e098dfc8e45 Mon Sep 17 00:00:00 2001 From: Stian Sandvik Thomassen Date: Tue, 18 Aug 2009 14:59:57 +1000 Subject: Doc: sorted list correctly for qLess() documentation --- doc/src/snippets/code/doc_src_qalgorithms.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/snippets/code/doc_src_qalgorithms.qdoc b/doc/src/snippets/code/doc_src_qalgorithms.qdoc index 69d943c..e2126dd 100644 --- a/doc/src/snippets/code/doc_src_qalgorithms.qdoc +++ b/doc/src/snippets/code/doc_src_qalgorithms.qdoc @@ -302,7 +302,7 @@ list.clear(); QList list; list << 33 << 12 << 68 << 6 << 12; qSort(list.begin(), list.end(), qLess()); -// list: [ 68, 33, 12, 12, 6 ] +// list: [ 6, 12, 12, 33, 68 ] //! [24] -- cgit v0.12