summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-08-18 13:25:53 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-08-18 13:25:53 +1000
commit8b4539770da00ec98820352fcce89bd6d843f51d (patch)
tree2d821ad08e15522ba6f18417c13f1eb9f6593665
parent5bc376247a07a79be4a04bf33b44d4fd85a6ae97 (diff)
downloadqt4-tools-8b4539770da00ec98820352fcce89bd6d843f51d.tar.gz
Optimize QMatrix4x4::rotate() for 0, 90, 180, 270 degrees.
Reviewed-by: Sarah Smith
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index dc17eda50a..8fc439be6c 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) {