summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-04-07 06:16:22 (GMT)
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-04-08 00:19:12 (GMT)
commita83faaf1bedfd321c4fc759156369d2f86fbbbed (patch)
tree9fefa2840ae8a784fcd323551de6a74835e5b267 /src/gui
parent939623b2bc8e441618ee1a1886cc656880bee62b (diff)
downloadQt-a83faaf1bedfd321c4fc759156369d2f86fbbbed.zip
Qt-a83faaf1bedfd321c4fc759156369d2f86fbbbed.tar.gz
Qt-a83faaf1bedfd321c4fc759156369d2f86fbbbed.tar.bz2
Remove fixed-point support from math3d
The main use case for fixed-point support is to build large arrays of vertices. This can be handled using qvertextype or something similar at higher levels. So it isn't worth risking numerical instability in the core classes. Reviewed-by: trustme
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/math3d/math3d.pri5
-rw-r--r--src/gui/math3d/qfixedpt.cpp711
-rw-r--r--src/gui/math3d/qfixedpt.h551
-rw-r--r--src/gui/math3d/qgenericmatrix.h22
-rw-r--r--src/gui/math3d/qmath3dglobal.h102
-rw-r--r--src/gui/math3d/qmath3dutil.cpp194
-rw-r--r--src/gui/math3d/qmath3dutil_p.h96
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp374
-rw-r--r--src/gui/math3d/qmatrix4x4.h177
-rw-r--r--src/gui/math3d/qquaternion.cpp33
-rw-r--r--src/gui/math3d/qquaternion.h49
-rw-r--r--src/gui/math3d/qvector2d.cpp9
-rw-r--r--src/gui/math3d/qvector2d.h34
-rw-r--r--src/gui/math3d/qvector3d.cpp8
-rw-r--r--src/gui/math3d/qvector3d.h41
-rw-r--r--src/gui/math3d/qvector4d.cpp12
-rw-r--r--src/gui/math3d/qvector4d.h46
17 files changed, 380 insertions, 2084 deletions
diff --git a/src/gui/math3d/math3d.pri b/src/gui/math3d/math3d.pri
index 581adbd..e4dd53a 100644
--- a/src/gui/math3d/math3d.pri
+++ b/src/gui/math3d/math3d.pri
@@ -1,8 +1,5 @@
HEADERS += \
- math3d/qfixedpt.h \
math3d/qgenericmatrix.h \
- math3d/qmath3dglobal.h \
- math3d/qmath3dutil_p.h \
math3d/qmatrix4x4.h \
math3d/qquaternion.h \
math3d/qvector2d.h \
@@ -10,9 +7,7 @@ HEADERS += \
math3d/qvector4d.h
SOURCES += \
- math3d/qfixedpt.cpp \
math3d/qgenericmatrix.cpp \
- math3d/qmath3dutil.cpp \
math3d/qmatrix4x4.cpp \
math3d/qquaternion.cpp \
math3d/qvector2d.cpp \
diff --git a/src/gui/math3d/qfixedpt.cpp b/src/gui/math3d/qfixedpt.cpp
deleted file mode 100644
index 93f2150..0000000
--- a/src/gui/math3d/qfixedpt.cpp
+++ /dev/null
@@ -1,711 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfixedpt.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- Returns the fixed-point square root of \a value.
-*/
-qint64 qt_math3d_fixed_sqrt(qint64 value)
-{
- qint64 result = 0;
- qint64 bit = ((qint64)1) << 62;
- while (bit > value)
- bit >>= 2;
- while (bit != 0) {
- if (value >= (result + bit)) {
- value -= result + bit;
- result += (bit << 1);
- }
- result >>= 1;
- bit >>= 2;
- }
- return result;
-}
-
-/*!
- \class QFixedPt
- \brief The QFixedPt class represents fixed-point numbers within a 32-bit integer with a configurable precision.
-
- The template parameter is the number of bits of precision after
- the decimal point. For example, QFixedPt<5> indicates that there
- are 27 bits before the decimal point, and 5 bits of precision after
- the decimal point.
-*/
-
-/*!
- \fn QFixedPt::QFixedPt()
-
- Constructs a default fixed-point number. The initial value
- is undefined.
-*/
-
-/*!
- \fn QFixedPt::QFixedPt(int value)
-
- Constructs a fixed-point number from the integer \a value.
-*/
-
-/*!
- \fn QFixedPt::QFixedPt(qreal value)
-
- Constructs a fixed-point number from the floating-point \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator=(int value)
-
- Assigns the integer \a value to this fixed-point variable.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator=(qreal value)
-
- Assigns the floating-point \a value to this fixed-point variable.
-*/
-
-/*!
- \fn int QFixedPt::bits() const
-
- Returns the raw bits that represent the fixed-point value of this object.
-
- \sa setBits()
-*/
-
-/*!
- \fn void QFixedPt::setBits(int value)
-
- Sets the raw bits that represent the fixed-point value of
- this object to \a value.
-
- \sa bits()
-*/
-
-#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
-
-/*!
- \fn QFixedPt<Prec> QFixedPt::toPrecision() const
-
- Returns this fixed-point number, converted to the new fixed-point
- precision Prec.
-
- \sa qFixedPtToPrecision()
-*/
-
-#endif
-
-/*!
- \fn QFixedPt<Prec> qFixedPtToPrecision(const QFixedPt<PrecBits>& value)
-
- Returns the fixed-point number \a value, converted to the new fixed-point
- precision Prec.
-
- \sa QFixedPt::toPrecision()
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator+=(const QFixedPt<PrecBits>& value)
-
- Adds \a value to this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator+=(int value)
-
- Adds an integer \a value to this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator+=(qreal value)
-
- Adds a floating-point \a value to this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator-=(const QFixedPt<PrecBits>& value)
-
- Subtracts \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator-=(int value)
-
- Subtracts an integer \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator-=(qreal value)
-
- Subtracts a floating-point \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator*=(const QFixedPt<PrecBits>& value)
-
- Multiplies this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator*=(int value)
-
- Multiplies this fixed-point number by an integer \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator*=(qreal value)
-
- Multiplies this fixed-point number by a floating-point \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator/=(const QFixedPt<PrecBits>& value)
-
- Divides this fixed-point number by \a value. Division by zero
- will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator/=(int value)
-
- Divides this fixed-point number by an integer \a value. Division
- by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator/=(qreal value)
-
- Divides this fixed-point number by a floating-point \a value. Division
- by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator<<=(int value)
-
- Shifts this fixed-point number left by \a value bits.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator>>=(int value)
-
- Shifts this fixed-point number right by \a value bits.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator<<(int value) const
-
- Returns the result of shifting this fixed-point number
- left by \a value bits.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator>>(int value) const
-
- Returns the result of shifting this fixed-point number
- right by \a value bits.
-*/
-
-/*!
- \fn bool QFixedPt::operator==(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is equal to \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator==(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator==(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator==(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator==(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator!=(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is not equal to \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator!=(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator!=(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator!=(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator!=(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator<=(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is less than or equal to
- \a value; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator<(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is less than \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator<(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator>=(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is greater than or equal to
- \a value; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator>(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is greater than \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator>(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator+(const QFixedPt<PrecBits>& value) const
-
- Returns the result of adding this fixed-point number and \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator+(int value) const
-
- Returns the result of adding this fixed-point number and \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator+(qreal value) const
-
- Returns the result of adding this fixed-point number and \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator+(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of adding \a v1 and \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator+(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of adding \a v1 and \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-(const QFixedPt<PrecBits>& value) const
-
- Returns the result of subtracting \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-(int value) const
-
- Returns the result of subtracting \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-(qreal value) const
-
- Returns the result of subtracting \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator-(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of subtracting \a v2 from \a v1.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator-(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of subtracting \a v2 from \a v1.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator*(const QFixedPt<PrecBits>& value) const
-
- Returns the result of multiplying this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator*(int value) const
-
- Returns the result of multiplying this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator*(qreal value) const
-
- Returns the result of multiplying this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator*(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of multiplying \a v1 by \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator*(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of multiplying \a v1 by \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator/(const QFixedPt<PrecBits>& value) const
-
- Returns the result of dividing this fixed-point number by \a value.
- Division by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator/(int value) const
-
- Returns the result of dividing this fixed-point number by \a value.
- Division by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator/(qreal value) const
-
- Returns the result of dividing this fixed-point number by \a value.
- Division by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator/(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of dividing \a v1 by \a v2. Division by zero will
- result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator/(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of dividing \a v1 by \a v2. Division by zero will
- result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-() const
-
- Returns the negation of this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::sqrt() const
-
- Returns the square root of this fixed-point number.
-
- \sa sqrtF()
-*/
-
-/*!
- \fn qreal QFixedPt::sqrtF() const
-
- Return the square root of this fixed-point number as a
- floating-point value.
-
- \sa sqrt()
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::round() const
-
- Returns this fixed-point number, rounded to the nearest integer.
-
- \sa floor(), ceil(), truncate()
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::floor() const;
-
- Returns the largest integer that is less than or equal to
- this fixed-point number.
-
- \sa round(), ceil(), truncate()
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::ceil() const
-
- Returns the smallest integer that is greater than or equal to
- this fixed-point number.
-
- \sa round(), floor(), truncate()
-*/
-
-/*!
- \fn int QFixedPt::truncate() const
-
- Returns this fixed-point number with the bits after the
- decimal point truncated.
-
- \sa round(), floor(), ceil()
-*/
-
-/*!
- \fn int QFixedPt::toInt() const
-
- Returns this fixed-point number, rounded to the nearest integer.
-
- \sa toReal()
-*/
-
-/*!
- \fn qreal QFixedPt::toReal() const
-
- Returns this fixed-point number as a floating-point value.
-
- \sa toInt()
-*/
-
-/*!
- \fn int qCeil(const QFixedPt<PrecBits>& value)
- \relates QFixedPt
-
- Returns the smallest integer that is greater than or equal to
- \a value.
-
- \sa qFloor(), qRound(), QFixedPt::ceil()
-*/
-
-/*!
- \fn int qFloor(const QFixedPt<PrecBits>& value)
- \relates QFixedPt
-
- Returns the largest integer that is less than or equal to
- \a value.
-
- \sa qCeil(), qRound(), QFixedPt::floor()
-*/
-
-/*!
- \fn int qRound(const QFixedPt<PrecBits>& value)
- \relates QFixedPt
-
- Returns \a value, rounded to the nearest integer.
-
- \sa qCeil(), qFloor(), QFixedPt::round()
-*/
-
-/*!
- \fn bool qFuzzyCompare(const QFixedPt<PrecBits>& v1, const QFixedPt<PrecBits>& v2, int compareBits)
- \relates QFixedPt
-
- Returns true if \a v1 is almost equal to \a v2; false otherwise.
- The \a compareBits parameter specifies the number of bits of precision
- that should be considered relevant when performing the comparison.
- By default, \a compareBits is PrecBits / 4.
-*/
-
-/*!
- \fn bool qIsNull(const QFixedPt<PrecBits>& v)
- \relates QFixedPt
-
- Returns true if \a v is zero; false otherwise.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/gui/math3d/qfixedpt.h b/src/gui/math3d/qfixedpt.h
deleted file mode 100644
index 142f62f..0000000
--- a/src/gui/math3d/qfixedpt.h
+++ /dev/null
@@ -1,551 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFIXEDPT_H
-#define QFIXEDPT_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-Q_GUI_EXPORT qint64 qt_math3d_fixed_sqrt(qint64 value);
-
-// Should be called QFixed or QFixedPoint, but both of those
-// are already in use in src/gui/painting/qfixed_p.h.
-template <int PrecBits>
-class QFixedPt
-{
-public:
- inline QFixedPt() {} // Deliberately not initialized - don't change this.
- inline QFixedPt(int value) : val(value << PrecBits) {}
- inline QFixedPt(qreal value) : val(int(value * (1 << PrecBits))) {}
-
- inline QFixedPt<PrecBits>& operator=(int value)
- { val = value << PrecBits; return *this; }
- inline QFixedPt<PrecBits>& operator=(qreal value)
- { val = int(value * (1 << PrecBits)); return *this; }
-
- inline int bits() const { return val; }
- inline void setBits(int value) { val = value; }
-
-#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
- template <int Prec>
- inline QFixedPt<Prec> toPrecision() const
- {
- QFixedPt<Prec> result;
- if (Prec < PrecBits)
- result.setBits(shiftRight(val, (PrecBits - Prec)));
- else
- result.setBits(shiftLeft(val, (Prec - PrecBits)));
- return result;
- }
-#endif
-
- inline QFixedPt<PrecBits>& operator+=(const QFixedPt<PrecBits>& value)
- { val += value.val; return *this; }
- inline QFixedPt<PrecBits>& operator+=(int value)
- { val += (value << PrecBits); return *this; }
- inline QFixedPt<PrecBits>& operator+=(qreal value)
- { val += int(value * (1 << PrecBits)); return *this; }
-
- inline QFixedPt<PrecBits>& operator-=(const QFixedPt<PrecBits>& value)
- { val -= value.val; return *this; }
- inline QFixedPt<PrecBits>& operator-=(int value)
- { val -= (value << PrecBits); return *this; }
- inline QFixedPt<PrecBits>& operator-=(qreal value)
- { val -= int(value * (1 << PrecBits)); return *this; }
-
- inline QFixedPt<PrecBits>& operator*=(const QFixedPt<PrecBits>& value)
- { val = mul(val, value.val); return *this; }
- inline QFixedPt<PrecBits>& operator*=(int value)
- { val = mul(val, (value << PrecBits)); return *this; }
- inline QFixedPt<PrecBits>& operator*=(qreal value)
- { val = mul(val, int(value * (1 << PrecBits))); return *this; }
-
- inline QFixedPt<PrecBits>& operator/=(const QFixedPt<PrecBits>& value)
- { val = div(val, value.val); return *this; }
- inline QFixedPt<PrecBits>& operator/=(int value)
- { val = div(val, (value << PrecBits)); return *this; }
- inline QFixedPt<PrecBits>& operator/=(qreal value)
- { val = div(val, int(value * (1 << PrecBits))); return *this; }
-
- inline QFixedPt<PrecBits>& operator<<=(int value)
- { val <<= value; return *this; }
- inline QFixedPt<PrecBits>& operator>>=(int value)
- { val >>= value; return *this; }
-
- inline QFixedPt<PrecBits> operator<<(int value) const
- { QFixedPt<PrecBits> result; result.val = val << value; return result; }
- inline QFixedPt<PrecBits> operator>>(int value) const
- { QFixedPt<PrecBits> result; result.val = val >> value; return result; }
-
- inline bool operator==(const QFixedPt<PrecBits>& value) const
- { return val == value.val; }
- inline bool operator!=(const QFixedPt<PrecBits>& value) const
- { return val != value.val; }
- inline bool operator<=(const QFixedPt<PrecBits>& value) const
- { return val <= value.val; }
- inline bool operator<(const QFixedPt<PrecBits>& value) const
- { return val < value.val; }
- inline bool operator>=(const QFixedPt<PrecBits>& value) const
- { return val >= value.val; }
- inline bool operator>(const QFixedPt<PrecBits>& value) const
- { return val > value.val; }
-
- inline QFixedPt<PrecBits> operator+(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = val + value.val; return result; }
- inline QFixedPt<PrecBits> operator+(int value) const
- { QFixedPt<PrecBits> result;
- result.val = val + (value << PrecBits); return result; }
- inline QFixedPt<PrecBits> operator+(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = val + int(value * (1 << PrecBits)); return result; }
-
- inline QFixedPt<PrecBits> operator-(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = val - value.val; return result; }
- inline QFixedPt<PrecBits> operator-(int value) const
- { QFixedPt<PrecBits> result;
- result.val = val - (value << PrecBits); return result; }
- inline QFixedPt<PrecBits> operator-(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = val - int(value * (1 << PrecBits)); return result; }
-
- inline QFixedPt<PrecBits> operator*(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = mul(val, value.val); return result; }
- inline QFixedPt<PrecBits> operator*(int value) const
- { QFixedPt<PrecBits> result;
- result.val = mul(val, (value << PrecBits)); return result; }
- inline QFixedPt<PrecBits> operator*(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = mul(val, int(value * (1 << PrecBits))); return result; }
-
- inline QFixedPt<PrecBits> operator/(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = div(val, value.val); return result; }
- inline QFixedPt<PrecBits> operator/(int value) const
- { QFixedPt<PrecBits> result;
- result.val = div(val, (value << PrecBits)); return result; }
- inline QFixedPt<PrecBits> operator/(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = div(val, int(value * (1 << PrecBits))); return result; }
-
- inline QFixedPt<PrecBits> operator-() const
- { QFixedPt<PrecBits> result; result.val = -val; return result; }
-
- inline QFixedPt<PrecBits> sqrt() const;
- inline qreal sqrtF() const;
- inline QFixedPt<PrecBits> round() const;
- inline QFixedPt<PrecBits> floor() const;
- inline QFixedPt<PrecBits> ceil() const;
- inline int truncate() const { return val >> PrecBits; }
-
- inline int toInt() const { return (val + (1 << (PrecBits - 1))) >> PrecBits; }
- inline qreal toReal() const { return qreal(val) / qreal(1 << PrecBits); }
-
-#if !defined(Q_NO_TEMPLATE_FRIENDS)
- template <int Prec>
- friend QFixedPt<Prec> operator/(int v1, const QFixedPt<Prec>& v2);
- template <int Prec>
- friend QFixedPt<Prec> operator/(qreal v1, const QFixedPt<Prec>& v2);
-
-private:
-#endif
- int val;
-
- inline static int mul(int v1, int v2)
- {
- return int((qint64(v1) * qint64(v2)) >> PrecBits);
- }
-
- inline static int div(int v1, int v2)
- {
- if (v2)
- return int((qint64(v1) << PrecBits) / qint64(v2));
- else
- return 0;
- }
-
- // These are used by toPrecision() to avoid a silly gcc compiler warning
- // related to negative shift values that will never actually be used.
- inline static int shiftRight(int val, int shift)
- {
- return val >> shift;
- }
- inline static int shiftLeft(int val, int shift)
- {
- return val << shift;
- }
-
-#if !defined(Q_NO_TEMPLATE_FRIENDS)
- template <int Prec, int Prec2>
- friend QFixedPt<Prec> qFixedPtToPrecision(const QFixedPt<Prec2>& value);
-#endif
-};
-
-template <int PrecBits>
-inline bool operator==(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() == (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator==(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) == v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator==(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() == int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator==(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) == v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator!=(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() != (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator!=(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) != v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator!=(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() != int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator!=(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) != v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<=(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() <= (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator<=(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) <= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<=(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() <= int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator<=(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) <= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() < (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator<(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) < v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() < int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator<(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) < v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>=(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() >= (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator>=(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) >= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>=(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() >= int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator>=(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) >= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() > (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator>(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) > v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() > int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator>(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) > v2.bits();
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator+(int v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 + v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator+(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 + v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator-(int v1, const QFixedPt<PrecBits>& v2)
-{
- return -(v2 - v1);
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator-(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return -(v2 - v1);
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator*(int v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 * v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator*(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 * v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator/(int v1, const QFixedPt<PrecBits>& v2)
-{
- QFixedPt<PrecBits> result;
- result.val = QFixedPt<PrecBits>::div(v1 << PrecBits, v2.val);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator/(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- QFixedPt<PrecBits> result;
- result.val = QFixedPt<PrecBits>::div(int(v1 * (1 << PrecBits)), v2.val);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::sqrt() const
-{
- QFixedPt<PrecBits> result;
- result.val = int(qt_math3d_fixed_sqrt
- (qint64(val) << (PrecBits * 2)) >> (PrecBits / 2));
- return result;
-}
-
-template <int PrecBits>
-inline qreal QFixedPt<PrecBits>::sqrtF() const
-{
- return qt_math3d_fixed_sqrt
- (qint64(val) << (PrecBits * 2)) / (qreal)(1 << (PrecBits + (PrecBits / 2)));
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::round() const
-{
- QFixedPt<PrecBits> result;
- result.val = (val + (1 << (PrecBits - 1))) & ~((1 << PrecBits) - 1);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::floor() const
-{
- QFixedPt<PrecBits> result;
- result.val = val & ~((1 << PrecBits) - 1);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::ceil() const
-{
- QFixedPt<PrecBits> result;
- result.val = (val + (1 << PrecBits) - 1) & ~((1 << PrecBits) - 1);
- return result;
-}
-
-template <int PrecBits>
-inline int qCeil(const QFixedPt<PrecBits>& value)
-{
- return value.ceil().bits() >> PrecBits;
-}
-
-template <int PrecBits>
-inline int qFloor(const QFixedPt<PrecBits>& value)
-{
- return value.floor().bits() >> PrecBits;
-}
-
-template <int PrecBits>
-inline int qRound(const QFixedPt<PrecBits>& value)
-{
- return value.round().bits() >> PrecBits;
-}
-
-template <int PrecBits>
-inline bool qFuzzyCompare(const QFixedPt<PrecBits>& v1, const QFixedPt<PrecBits>& v2, int compareBits = (PrecBits / 4))
-{
- return ((v1.bits() ^ v2.bits()) & ~((1 << compareBits) - 1)) == 0;
-}
-
-template <int PrecBits>
-inline bool qIsNull(const QFixedPt<PrecBits>& v)
-{
- return v.bits() == 0;
-}
-
-template <int Prec, int PrecBits>
-QFixedPt<Prec> qFixedPtToPrecision(const QFixedPt<PrecBits>& value)
-{
- QFixedPt<Prec> result;
- if (Prec < PrecBits)
- result.setBits(QFixedPt<PrecBits>::shiftRight(value.bits(), (PrecBits - Prec)));
- else
- result.setBits(QFixedPt<PrecBits>::shiftLeft(value.bits(), (Prec - PrecBits)));
- return result;
-}
-
-template <int PrecBits>
-inline QDebug &operator<<(QDebug &dbg, const QFixedPt<PrecBits> &f)
-{
- return dbg << f.toReal();
-}
-
-Q_DECLARE_TYPEINFO(QFixedPt<0>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<1>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<2>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<3>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<4>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<5>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<6>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<7>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<8>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<9>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<10>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<11>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<12>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<13>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<14>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<15>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<16>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<17>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<18>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<19>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<20>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<21>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<22>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<23>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<24>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<25>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<26>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<27>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<28>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<29>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<30>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<31>, Q_PRIMITIVE_TYPE);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h
index dbeaaf3..d0b22de 100644
--- a/src/gui/math3d/qgenericmatrix.h
+++ b/src/gui/math3d/qgenericmatrix.h
@@ -42,8 +42,8 @@
#ifndef QGENERICMATRIX_H
#define QGENERICMATRIX_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qmetatype.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_HEADER
@@ -134,7 +134,7 @@ template <int N, int M, typename T, typename InnerT>
Q_INLINE_TEMPLATE T QGenericMatrix<N, M, T, InnerT>::operator()(int row, int column) const
{
Q_ASSERT(row >= 0 && row < M && column >= 0 && column < N);
- return qt_math3d_convert<T, InnerT>(m[column][row]);
+ return T(m[column][row]);
}
template <int N, int M, typename T, typename InnerT>
@@ -323,18 +323,18 @@ Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T, InnerT>::toValueArray(T *value
{
for (int col = 0; col < N; ++col)
for (int row = 0; row < M; ++row)
- values[row * N + col] = qt_math3d_convert<T, InnerT>(m[col][row]);
+ values[row * N + col] = T(m[col][row]);
}
// Define aliases for the useful variants of QGenericMatrix.
-typedef QGenericMatrix<2, 2, qreal, qrealinner> QMatrix2x2;
-typedef QGenericMatrix<2, 3, qreal, qrealinner> QMatrix2x3;
-typedef QGenericMatrix<2, 4, qreal, qrealinner> QMatrix2x4;
-typedef QGenericMatrix<3, 2, qreal, qrealinner> QMatrix3x2;
-typedef QGenericMatrix<3, 3, qreal, qrealinner> QMatrix3x3;
-typedef QGenericMatrix<3, 4, qreal, qrealinner> QMatrix3x4;
-typedef QGenericMatrix<4, 2, qreal, qrealinner> QMatrix4x2;
-typedef QGenericMatrix<4, 3, qreal, qrealinner> QMatrix4x3;
+typedef QGenericMatrix<2, 2, qreal, float> QMatrix2x2;
+typedef QGenericMatrix<2, 3, qreal, float> QMatrix2x3;
+typedef QGenericMatrix<2, 4, qreal, float> QMatrix2x4;
+typedef QGenericMatrix<3, 2, qreal, float> QMatrix3x2;
+typedef QGenericMatrix<3, 3, qreal, float> QMatrix3x3;
+typedef QGenericMatrix<3, 4, qreal, float> QMatrix3x4;
+typedef QGenericMatrix<4, 2, qreal, float> QMatrix4x2;
+typedef QGenericMatrix<4, 3, qreal, float> QMatrix4x3;
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qmath3dglobal.h b/src/gui/math3d/qmath3dglobal.h
deleted file mode 100644
index c2f7184..0000000
--- a/src/gui/math3d/qmath3dglobal.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMATH3DGLOBAL_H
-#define QMATH3DGLOBAL_H
-
-#include <QtCore/qglobal.h>
-#include <QtGui/qfixedpt.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-// Detect the presence of a fixed-point OpenGL implementation.
-#if defined(QT_OPENGL_ES_1_CL) || defined(QT_NO_GL_FLOAT)
-#ifndef QT_GL_FIXED_PREFERRED
-#define QT_GL_FIXED_PREFERRED 1
-#endif
-#endif
-
-// QT_GL_FIXED_PREFERRED indicates that fixed-point should be
-// preferred over floating-point for operations requiring high performance.
-//
-// qreal is the floating-point type that should be used in
-// user-visible functions. qrealinner is used internally where
-// values may be stored as either floating-point or fixed-point.
-// qrealinner will typically be the same size as GLfloat or GLfixed.
-#if defined(QT_GL_FIXED_PREFERRED)
-typedef QFixedPt<16> qrealinner;
-#else
-typedef float qrealinner;
-#endif
-
-// Explicit conversion operator, primarily for converting from
-// fixed point back to floating-point. This is safer than
-// declaring conversion operators in the QFixedPt class.
-template <typename T1, typename T2>
-T1 qt_math3d_convert(T2 v)
-{
- return T1(v);
-}
-template <>
-inline float qt_math3d_convert< float, QFixedPt<16> >(QFixedPt<16> v)
-{
- return float(v.toReal());
-}
-template <>
-inline double qt_math3d_convert< double, QFixedPt<16> >(QFixedPt<16> v)
-{
- return double(v.toReal());
-}
-template <>
-inline int qt_math3d_convert< int, QFixedPt<16> >(QFixedPt<16> v)
-{
- return v.toInt();
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/math3d/qmath3dutil.cpp b/src/gui/math3d/qmath3dutil.cpp
deleted file mode 100644
index ad84162..0000000
--- a/src/gui/math3d/qmath3dutil.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmath3dutil_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_GL_FIXED_PREFERRED
-
-// The table that follows was automatically generated by the following code:
-//
-//#include <math.h>
-//#include <stdio.h>
-//
-//int main()
-//{
-// double angle;
-// int count = 0;
-// for (angle = 0.0; angle < 360.0; angle += 1.0) {
-// if ((count % 4) == 0)
-// printf(" ");
-// printf(" qf2vt(%f)", sin(angle * M_PI / 180.0));
-// ++count;
-// if (count != 360)
-// printf(",");
-// if ((count % 4) == 0)
-// printf("\n");
-// }
-// return 0;
-//}
-
-#define qf2vt(x) (int((x) * 65536.0))
-
-static int const sinTable[360] = {
- qf2vt(0.000000), qf2vt(0.017452), qf2vt(0.034899), qf2vt(0.052336),
- qf2vt(0.069756), qf2vt(0.087156), qf2vt(0.104528), qf2vt(0.121869),
- qf2vt(0.139173), qf2vt(0.156434), qf2vt(0.173648), qf2vt(0.190809),
- qf2vt(0.207912), qf2vt(0.224951), qf2vt(0.241922), qf2vt(0.258819),
- qf2vt(0.275637), qf2vt(0.292372), qf2vt(0.309017), qf2vt(0.325568),
- qf2vt(0.342020), qf2vt(0.358368), qf2vt(0.374607), qf2vt(0.390731),
- qf2vt(0.406737), qf2vt(0.422618), qf2vt(0.438371), qf2vt(0.453990),
- qf2vt(0.469472), qf2vt(0.484810), qf2vt(0.500000), qf2vt(0.515038),
- qf2vt(0.529919), qf2vt(0.544639), qf2vt(0.559193), qf2vt(0.573576),
- qf2vt(0.587785), qf2vt(0.601815), qf2vt(0.615661), qf2vt(0.629320),
- qf2vt(0.642788), qf2vt(0.656059), qf2vt(0.669131), qf2vt(0.681998),
- qf2vt(0.694658), qf2vt(0.707107), qf2vt(0.719340), qf2vt(0.731354),
- qf2vt(0.743145), qf2vt(0.754710), qf2vt(0.766044), qf2vt(0.777146),
- qf2vt(0.788011), qf2vt(0.798636), qf2vt(0.809017), qf2vt(0.819152),
- qf2vt(0.829038), qf2vt(0.838671), qf2vt(0.848048), qf2vt(0.857167),
- qf2vt(0.866025), qf2vt(0.874620), qf2vt(0.882948), qf2vt(0.891007),
- qf2vt(0.898794), qf2vt(0.906308), qf2vt(0.913545), qf2vt(0.920505),
- qf2vt(0.927184), qf2vt(0.933580), qf2vt(0.939693), qf2vt(0.945519),
- qf2vt(0.951057), qf2vt(0.956305), qf2vt(0.961262), qf2vt(0.965926),
- qf2vt(0.970296), qf2vt(0.974370), qf2vt(0.978148), qf2vt(0.981627),
- qf2vt(0.984808), qf2vt(0.987688), qf2vt(0.990268), qf2vt(0.992546),
- qf2vt(0.994522), qf2vt(0.996195), qf2vt(0.997564), qf2vt(0.998630),
- qf2vt(0.999391), qf2vt(0.999848), qf2vt(1.000000), qf2vt(0.999848),
- qf2vt(0.999391), qf2vt(0.998630), qf2vt(0.997564), qf2vt(0.996195),
- qf2vt(0.994522), qf2vt(0.992546), qf2vt(0.990268), qf2vt(0.987688),
- qf2vt(0.984808), qf2vt(0.981627), qf2vt(0.978148), qf2vt(0.974370),
- qf2vt(0.970296), qf2vt(0.965926), qf2vt(0.961262), qf2vt(0.956305),
- qf2vt(0.951057), qf2vt(0.945519), qf2vt(0.939693), qf2vt(0.933580),
- qf2vt(0.927184), qf2vt(0.920505), qf2vt(0.913545), qf2vt(0.906308),
- qf2vt(0.898794), qf2vt(0.891007), qf2vt(0.882948), qf2vt(0.874620),
- qf2vt(0.866025), qf2vt(0.857167), qf2vt(0.848048), qf2vt(0.838671),
- qf2vt(0.829038), qf2vt(0.819152), qf2vt(0.809017), qf2vt(0.798636),
- qf2vt(0.788011), qf2vt(0.777146), qf2vt(0.766044), qf2vt(0.754710),
- qf2vt(0.743145), qf2vt(0.731354), qf2vt(0.719340), qf2vt(0.707107),
- qf2vt(0.694658), qf2vt(0.681998), qf2vt(0.669131), qf2vt(0.656059),
- qf2vt(0.642788), qf2vt(0.629320), qf2vt(0.615661), qf2vt(0.601815),
- qf2vt(0.587785), qf2vt(0.573576), qf2vt(0.559193), qf2vt(0.544639),
- qf2vt(0.529919), qf2vt(0.515038), qf2vt(0.500000), qf2vt(0.484810),
- qf2vt(0.469472), qf2vt(0.453990), qf2vt(0.438371), qf2vt(0.422618),
- qf2vt(0.406737), qf2vt(0.390731), qf2vt(0.374607), qf2vt(0.358368),
- qf2vt(0.342020), qf2vt(0.325568), qf2vt(0.309017), qf2vt(0.292372),
- qf2vt(0.275637), qf2vt(0.258819), qf2vt(0.241922), qf2vt(0.224951),
- qf2vt(0.207912), qf2vt(0.190809), qf2vt(0.173648), qf2vt(0.156434),
- qf2vt(0.139173), qf2vt(0.121869), qf2vt(0.104528), qf2vt(0.087156),
- qf2vt(0.069756), qf2vt(0.052336), qf2vt(0.034899), qf2vt(0.017452),
- qf2vt(0.000000), qf2vt(-0.017452), qf2vt(-0.034899), qf2vt(-0.052336),
- qf2vt(-0.069756), qf2vt(-0.087156), qf2vt(-0.104528), qf2vt(-0.121869),
- qf2vt(-0.139173), qf2vt(-0.156434), qf2vt(-0.173648), qf2vt(-0.190809),
- qf2vt(-0.207912), qf2vt(-0.224951), qf2vt(-0.241922), qf2vt(-0.258819),
- qf2vt(-0.275637), qf2vt(-0.292372), qf2vt(-0.309017), qf2vt(-0.325568),
- qf2vt(-0.342020), qf2vt(-0.358368), qf2vt(-0.374607), qf2vt(-0.390731),
- qf2vt(-0.406737), qf2vt(-0.422618), qf2vt(-0.438371), qf2vt(-0.453990),
- qf2vt(-0.469472), qf2vt(-0.484810), qf2vt(-0.500000), qf2vt(-0.515038),
- qf2vt(-0.529919), qf2vt(-0.544639), qf2vt(-0.559193), qf2vt(-0.573576),
- qf2vt(-0.587785), qf2vt(-0.601815), qf2vt(-0.615661), qf2vt(-0.629320),
- qf2vt(-0.642788), qf2vt(-0.656059), qf2vt(-0.669131), qf2vt(-0.681998),
- qf2vt(-0.694658), qf2vt(-0.707107), qf2vt(-0.719340), qf2vt(-0.731354),
- qf2vt(-0.743145), qf2vt(-0.754710), qf2vt(-0.766044), qf2vt(-0.777146),
- qf2vt(-0.788011), qf2vt(-0.798636), qf2vt(-0.809017), qf2vt(-0.819152),
- qf2vt(-0.829038), qf2vt(-0.838671), qf2vt(-0.848048), qf2vt(-0.857167),
- qf2vt(-0.866025), qf2vt(-0.874620), qf2vt(-0.882948), qf2vt(-0.891007),
- qf2vt(-0.898794), qf2vt(-0.906308), qf2vt(-0.913545), qf2vt(-0.920505),
- qf2vt(-0.927184), qf2vt(-0.933580), qf2vt(-0.939693), qf2vt(-0.945519),
- qf2vt(-0.951057), qf2vt(-0.956305), qf2vt(-0.961262), qf2vt(-0.965926),
- qf2vt(-0.970296), qf2vt(-0.974370), qf2vt(-0.978148), qf2vt(-0.981627),
- qf2vt(-0.984808), qf2vt(-0.987688), qf2vt(-0.990268), qf2vt(-0.992546),
- qf2vt(-0.994522), qf2vt(-0.996195), qf2vt(-0.997564), qf2vt(-0.998630),
- qf2vt(-0.999391), qf2vt(-0.999848), qf2vt(-1.000000), qf2vt(-0.999848),
- qf2vt(-0.999391), qf2vt(-0.998630), qf2vt(-0.997564), qf2vt(-0.996195),
- qf2vt(-0.994522), qf2vt(-0.992546), qf2vt(-0.990268), qf2vt(-0.987688),
- qf2vt(-0.984808), qf2vt(-0.981627), qf2vt(-0.978148), qf2vt(-0.974370),
- qf2vt(-0.970296), qf2vt(-0.965926), qf2vt(-0.961262), qf2vt(-0.956305),
- qf2vt(-0.951057), qf2vt(-0.945519), qf2vt(-0.939693), qf2vt(-0.933580),
- qf2vt(-0.927184), qf2vt(-0.920505), qf2vt(-0.913545), qf2vt(-0.906308),
- qf2vt(-0.898794), qf2vt(-0.891007), qf2vt(-0.882948), qf2vt(-0.874620),
- qf2vt(-0.866025), qf2vt(-0.857167), qf2vt(-0.848048), qf2vt(-0.838671),
- qf2vt(-0.829038), qf2vt(-0.819152), qf2vt(-0.809017), qf2vt(-0.798636),
- qf2vt(-0.788011), qf2vt(-0.777146), qf2vt(-0.766044), qf2vt(-0.754710),
- qf2vt(-0.743145), qf2vt(-0.731354), qf2vt(-0.719340), qf2vt(-0.707107),
- qf2vt(-0.694658), qf2vt(-0.681998), qf2vt(-0.669131), qf2vt(-0.656059),
- qf2vt(-0.642788), qf2vt(-0.629320), qf2vt(-0.615661), qf2vt(-0.601815),
- qf2vt(-0.587785), qf2vt(-0.573576), qf2vt(-0.559193), qf2vt(-0.544639),
- qf2vt(-0.529919), qf2vt(-0.515038), qf2vt(-0.500000), qf2vt(-0.484810),
- qf2vt(-0.469472), qf2vt(-0.453990), qf2vt(-0.438371), qf2vt(-0.422618),
- qf2vt(-0.406737), qf2vt(-0.390731), qf2vt(-0.374607), qf2vt(-0.358368),
- qf2vt(-0.342020), qf2vt(-0.325568), qf2vt(-0.309017), qf2vt(-0.292372),
- qf2vt(-0.275637), qf2vt(-0.258819), qf2vt(-0.241922), qf2vt(-0.224951),
- qf2vt(-0.207912), qf2vt(-0.190809), qf2vt(-0.173648), qf2vt(-0.156434),
- qf2vt(-0.139173), qf2vt(-0.121869), qf2vt(-0.104528), qf2vt(-0.087156),
- qf2vt(-0.069756), qf2vt(-0.052336), qf2vt(-0.034899), qf2vt(-0.017452)
-};
-
-void qt_math3d_sincos(qreal angle, qrealinner *s, qrealinner *c)
-{
- if (angle == qFloor(angle)) {
- // The angle is an integer number of degrees, so look up the results.
- int a = (int)angle;
- if (a >= 0)
- a = (a % 360);
- else
- a = 360 - (-a % 360);
- s->setBits(sinTable[a]);
- c->setBits(sinTable[(a + 90) % 360]);
- } else {
- qreal a = angle * M_PI / 180.0f;
- *s = qSin(a);
- *c = qCos(a);
- }
-}
-
-#else
-
-void qt_math3d_sincos(qreal angle, qrealinner *s, qrealinner *c)
-{
- qreal a = angle * M_PI / 180.0f;
- *s = qSin(a);
- *c = qCos(a);
-}
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/gui/math3d/qmath3dutil_p.h b/src/gui/math3d/qmath3dutil_p.h
deleted file mode 100644
index fa4c156..0000000
--- a/src/gui/math3d/qmath3dutil_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMATH3DUTIL_P_H
-#define QMATH3DUTIL_P_H
-
-#include <QtGui/qmath3dglobal.h>
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_GL_FIXED_PREFERRED
-#define qvtsqrt(x) ((x).sqrtF())
-#else
-#define qvtsqrt(x) qSqrt((x))
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-void qt_math3d_sincos(qreal degrees, qrealinner *s, qrealinner *c);
-
-#ifdef QT_GL_FIXED_PREFERRED
-
-inline qrealinner qf2vt_round(qreal x)
-{
- QFixedPt<16> result;
- if (x >= 0.0f)
- result.setBits(int(x * 65536.0f + 0.5f));
- else
- result.setBits(int(x * 65536.0f - 0.5f));
- return result;
-}
-
-// Helper macros for computing dot products without losing precision.
-// In fixed-point mode, a 64-bit intermediate result is used.
-#define qvtmul64(x,y) ((qint64((x).bits())) * (qint64((y).bits())))
-#define qvtsqrt64(x) \
- (qt_math3d_fixed_sqrt((x) << 16) / (qreal)(1 << 24))
-#define qvtdot64(x) ((x) / (qreal)(((qint64)1) << 32))
-
-#else
-
-inline qrealinner qf2vt_round(qreal x)
-{
- return x;
-}
-
-#define qvtmul64(x,y) ((x) * (y))
-#define qvtsqrt64(x) (qvtsqrt((x)))
-#define qvtdot64(x) ((x))
-
-#endif
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index bcb3066..c2873e0 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include "qmatrix4x4.h"
-#include "qmath3dutil_p.h"
#include <QtCore/qmath.h>
#include <QtGui/qmatrix.h>
#include <QtGui/qtransform.h>
@@ -106,7 +105,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
/*!
- \fn QMatrix4x4::QMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+ \fn QMatrix4x4::QMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
Constructs a 4x4 matrix from the left-most 4 columns and top-most
4 rows of \a matrix. If \a matrix has less than 4 columns or rows,
@@ -117,7 +116,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
*/
/*!
- \fn QGenericMatrix<N, M, qreal, qrealinner> QMatrix4x4::toGenericMatrix() const
+ \fn QGenericMatrix<N, M, qreal, float> QMatrix4x4::toGenericMatrix() const
Constructs a NxM generic matrix from the left-most N columns and
top-most M rows of this 4x4 matrix. If N or M is greater than 4,
@@ -130,7 +129,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
#endif
/*!
- \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+ \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
\relates QMatrix4x4
Returns a 4x4 matrix constructed from the left-most 4 columns and
@@ -142,7 +141,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
*/
/*!
- \fn QGenericMatrix<N, M, qreal, qrealinner> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
+ \fn QGenericMatrix<N, M, qreal, float> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
\relates QMatrix4x4
Returns a NxM generic matrix constructed from the left-most N columns
@@ -156,7 +155,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
/*!
\internal
*/
-QMatrix4x4::QMatrix4x4(const qrealinner *values, int cols, int rows)
+QMatrix4x4::QMatrix4x4(const float *values, int cols, int rows)
{
for (int col = 0; col < 4; ++col) {
for (int row = 0; row < 4; ++row) {
@@ -244,7 +243,7 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
*/
/*!
- \fn qrealinner& QMatrix4x4::operator()(int row, int column)
+ \fn float& QMatrix4x4::operator()(int row, int column)
Returns a reference to the element at position (\a row, \a column)
in this matrix so that the element can be assigned to.
@@ -316,8 +315,8 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
// | A B C |
// M = | D E F | det(M) = A * (EI - HF) - B * (DI - GF) + C * (DH - GE)
// | G H I |
-static inline qrealinner matrixDet3
- (const qrealinner m[4][4], int col0, int col1, int col2,
+static inline float matrixDet3
+ (const float m[4][4], int col0, int col1, int col2,
int row0, int row1, int row2)
{
return m[col0][row0] *
@@ -332,9 +331,9 @@ static inline qrealinner matrixDet3
}
// Calculate the determinant of a 4x4 matrix.
-static inline qrealinner matrixDet4(const qrealinner m[4][4])
+static inline float matrixDet4(const float m[4][4])
{
- qrealinner det;
+ float det;
det = m[0][0] * matrixDet3(m, 1, 2, 3, 1, 2, 3);
det -= m[1][0] * matrixDet3(m, 0, 2, 3, 1, 2, 3);
det += m[2][0] * matrixDet3(m, 0, 1, 3, 1, 2, 3);
@@ -347,7 +346,7 @@ static inline qrealinner matrixDet4(const qrealinner m[4][4])
*/
qreal QMatrix4x4::determinant() const
{
- return qt_math3d_convert<qreal, qrealinner>(matrixDet4(m));
+ return qreal(matrixDet4(m));
}
/*!
@@ -386,13 +385,13 @@ QMatrix4x4 QMatrix4x4::inverted(bool *invertible) const
QMatrix4x4 inv(1); // The "1" says to not load the identity.
- qrealinner det = matrixDet4(m);
+ float det = matrixDet4(m);
if (det == 0.0f) {
if (invertible)
*invertible = false;
return QMatrix4x4();
}
- det = qrealinner(1.0f) / det;
+ det = 1.0f / det;
inv.m[0][0] = matrixDet3(m, 1, 2, 3, 1, 2, 3) * det;
inv.m[0][1] = -matrixDet3(m, 0, 2, 3, 1, 2, 3) * det;
@@ -434,18 +433,18 @@ QMatrix3x3 QMatrix4x4::normalMatrix() const
} else if (flagBits == Scale || flagBits == (Translation | Scale)) {
if (m[0][0] == 0.0f || m[1][1] == 0.0f || m[2][2] == 0.0f)
return inv;
- inv.data()[0] = qrealinner(1.0f) / m[0][0];
- inv.data()[4] = qrealinner(1.0f) / m[1][1];
- inv.data()[8] = qrealinner(1.0f) / m[2][2];
+ inv.data()[0] = 1.0f / m[0][0];
+ inv.data()[4] = 1.0f / m[1][1];
+ inv.data()[8] = 1.0f / m[2][2];
return inv;
}
- qrealinner det = matrixDet3(m, 0, 1, 2, 0, 1, 2);
+ float det = matrixDet3(m, 0, 1, 2, 0, 1, 2);
if (det == 0.0f)
return inv;
- det = qrealinner(1.0f) / det;
+ det = 1.0f / det;
- qrealinner *invm = inv.data();
+ float *invm = inv.data();
// Invert and transpose in a single step.
invm[0 + 0 * 3] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]) * det;
@@ -507,23 +506,22 @@ QMatrix4x4 QMatrix4x4::transposed() const
*/
QMatrix4x4& QMatrix4x4::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- m[0][0] /= d;
- m[0][1] /= d;
- m[0][2] /= d;
- m[0][3] /= d;
- m[1][0] /= d;
- m[1][1] /= d;
- m[1][2] /= d;
- m[1][3] /= d;
- m[2][0] /= d;
- m[2][1] /= d;
- m[2][2] /= d;
- m[2][3] /= d;
- m[3][0] /= d;
- m[3][1] /= d;
- m[3][2] /= d;
- m[3][3] /= d;
+ m[0][0] /= divisor;
+ m[0][1] /= divisor;
+ m[0][2] /= divisor;
+ m[0][3] /= divisor;
+ m[1][0] /= divisor;
+ m[1][1] /= divisor;
+ m[1][2] /= divisor;
+ m[1][3] /= divisor;
+ m[2][0] /= divisor;
+ m[2][1] /= divisor;
+ m[2][2] /= divisor;
+ m[2][3] /= divisor;
+ m[3][0] /= divisor;
+ m[3][1] /= divisor;
+ m[3][2] /= divisor;
+ m[3][3] /= divisor;
flagBits = General;
return *this;
}
@@ -665,23 +663,22 @@ QMatrix4x4& QMatrix4x4::operator/=(qreal divisor)
QMatrix4x4 operator/(const QMatrix4x4& matrix, qreal divisor)
{
QMatrix4x4 m(1); // The "1" says to not load the identity.
- qrealinner d(divisor);
- m.m[0][0] = matrix.m[0][0] / d;
- m.m[0][1] = matrix.m[0][1] / d;
- m.m[0][2] = matrix.m[0][2] / d;
- m.m[0][3] = matrix.m[0][3] / d;
- m.m[1][0] = matrix.m[1][0] / d;
- m.m[1][1] = matrix.m[1][1] / d;
- m.m[1][2] = matrix.m[1][2] / d;
- m.m[1][3] = matrix.m[1][3] / d;
- m.m[2][0] = matrix.m[2][0] / d;
- m.m[2][1] = matrix.m[2][1] / d;
- m.m[2][2] = matrix.m[2][2] / d;
- m.m[2][3] = matrix.m[2][3] / d;
- m.m[3][0] = matrix.m[3][0] / d;
- m.m[3][1] = matrix.m[3][1] / d;
- m.m[3][2] = matrix.m[3][2] / d;
- m.m[3][3] = matrix.m[3][3] / d;
+ m.m[0][0] = matrix.m[0][0] / divisor;
+ m.m[0][1] = matrix.m[0][1] / divisor;
+ m.m[0][2] = matrix.m[0][2] / divisor;
+ m.m[0][3] = matrix.m[0][3] / divisor;
+ m.m[1][0] = matrix.m[1][0] / divisor;
+ m.m[1][1] = matrix.m[1][1] / divisor;
+ m.m[1][2] = matrix.m[1][2] / divisor;
+ m.m[1][3] = matrix.m[1][3] / divisor;
+ m.m[2][0] = matrix.m[2][0] / divisor;
+ m.m[2][1] = matrix.m[2][1] / divisor;
+ m.m[2][2] = matrix.m[2][2] / divisor;
+ m.m[2][3] = matrix.m[2][3] / divisor;
+ m.m[3][0] = matrix.m[3][0] / divisor;
+ m.m[3][1] = matrix.m[3][1] / divisor;
+ m.m[3][2] = matrix.m[3][2] / divisor;
+ m.m[3][3] = matrix.m[3][3] / divisor;
return m;
}
@@ -703,9 +700,9 @@ QMatrix4x4 operator/(const QMatrix4x4& matrix, qreal divisor)
*/
QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
{
- qrealinner vx = vector.xp;
- qrealinner vy = vector.yp;
- qrealinner vz = vector.zp;
+ float vx = vector.xp;
+ float vy = vector.yp;
+ float vz = vector.zp;
if (flagBits == Identity) {
m[0][0] = vx;
m[1][1] = vy;
@@ -749,9 +746,9 @@ QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
*/
QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y, qreal z)
{
- qrealinner vx(x);
- qrealinner vy(y);
- qrealinner vz(z);
+ float vx(x);
+ float vy(y);
+ float vz(z);
if (flagBits == Identity) {
m[0][0] = vx;
m[1][1] = vy;
@@ -794,34 +791,33 @@ QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y, qreal z)
*/
QMatrix4x4& QMatrix4x4::scale(qreal factor)
{
- qrealinner f(factor);
if (flagBits == Identity) {
- m[0][0] = f;
- m[1][1] = f;
- m[2][2] = f;
+ m[0][0] = factor;
+ m[1][1] = factor;
+ m[2][2] = factor;
flagBits = Scale;
} else if (flagBits == Scale || flagBits == (Scale | Translation)) {
- m[0][0] *= f;
- m[1][1] *= f;
- m[2][2] *= f;
+ m[0][0] *= factor;
+ m[1][1] *= factor;
+ m[2][2] *= factor;
} else if (flagBits == Translation) {
- m[0][0] = f;
- m[1][1] = f;
- m[2][2] = f;
+ m[0][0] = factor;
+ m[1][1] = factor;
+ m[2][2] = factor;
flagBits |= Scale;
} else {
- m[0][0] *= f;
- m[0][1] *= f;
- m[0][2] *= f;
- m[0][3] *= f;
- m[1][0] *= f;
- m[1][1] *= f;
- m[1][2] *= f;
- m[1][3] *= f;
- m[2][0] *= f;
- m[2][1] *= f;
- m[2][2] *= f;
- m[2][3] *= f;
+ m[0][0] *= factor;
+ m[0][1] *= factor;
+ m[0][2] *= factor;
+ m[0][3] *= factor;
+ m[1][0] *= factor;
+ m[1][1] *= factor;
+ m[1][2] *= factor;
+ m[1][3] *= factor;
+ m[2][0] *= factor;
+ m[2][1] *= factor;
+ m[2][2] *= factor;
+ m[2][3] *= factor;
flagBits = General;
}
return *this;
@@ -836,9 +832,9 @@ QMatrix4x4& QMatrix4x4::scale(qreal factor)
*/
QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
{
- qrealinner vx = vector.xp;
- qrealinner vy = vector.yp;
- qrealinner vz = vector.zp;
+ float vx = vector.xp;
+ float vy = vector.yp;
+ float vz = vector.zp;
if (flagBits == Identity) {
m[3][0] = vx;
m[3][1] = vy;
@@ -882,9 +878,9 @@ QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
*/
QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y, qreal z)
{
- qrealinner vx(x);
- qrealinner vy(y);
- qrealinner vz(z);
+ float vx(x);
+ float vy(y);
+ float vz(z);
if (flagBits == Identity) {
m[3][0] = vx;
m[3][1] = vy;
@@ -931,6 +927,10 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
#endif
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
/*!
\overload
@@ -942,8 +942,10 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
{
QMatrix4x4 m(1); // The "1" says to not load the identity.
- qrealinner c, s, ic;
- qt_math3d_sincos(angle, &s, &c);
+ qreal a = angle * M_PI / 180.0f;
+ qreal c = qCos(a);
+ qreal s = qSin(a);
+ qreal ic;
bool quick = false;
if (x == 0.0f) {
if (y == 0.0f) {
@@ -993,27 +995,24 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
quick = true;
}
if (!quick) {
- qrealinner vx(x);
- qrealinner vy(y);
- qrealinner vz(z);
- qrealinner len(qvtsqrt(vx * vx + vy * vy + vz * vz));
+ qreal len = qSqrt(x * x + y * y + z * z);
if (len != 0) {
- vx /= len;
- vy /= len;
- vz /= len;
+ x /= len;
+ y /= len;
+ z /= len;
}
ic = 1.0f - c;
- m.m[0][0] = vx * vx * ic + c;
- m.m[1][0] = vx * vy * ic - vz * s;
- m.m[2][0] = vx * vz * ic + vy * s;
+ m.m[0][0] = x * x * ic + c;
+ m.m[1][0] = x * y * ic - z * s;
+ m.m[2][0] = x * z * ic + y * s;
m.m[3][0] = 0.0f;
- m.m[0][1] = vy * vx * ic + vz * s;
- m.m[1][1] = vy * vy * ic + c;
- m.m[2][1] = vy * vz * ic - vx * s;
+ m.m[0][1] = y * x * ic + z * s;
+ m.m[1][1] = y * y * ic + c;
+ m.m[2][1] = y * z * ic - x * s;
m.m[3][1] = 0.0f;
- m.m[0][2] = vx * vz * ic - vy * s;
- m.m[1][2] = vy * vz * ic + vx * s;
- m.m[2][2] = vz * vz * ic + c;
+ m.m[0][2] = x * z * ic - y * s;
+ m.m[1][2] = y * z * ic + x * s;
+ m.m[2][2] = z * z * ic + c;
m.m[3][2] = 0.0f;
m.m[0][3] = 0.0f;
m.m[1][3] = 0.0f;
@@ -1043,15 +1042,15 @@ QMatrix4x4& QMatrix4x4::rotate(const QQuaternion& quaternion)
// Algorithm from:
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54
QMatrix4x4 m(1);
- qrealinner xx = quaternion.xp * quaternion.xp;
- qrealinner xy = quaternion.xp * quaternion.yp;
- qrealinner xz = quaternion.xp * quaternion.zp;
- qrealinner xw = quaternion.xp * quaternion.wp;
- qrealinner yy = quaternion.yp * quaternion.yp;
- qrealinner yz = quaternion.yp * quaternion.zp;
- qrealinner yw = quaternion.yp * quaternion.wp;
- qrealinner zz = quaternion.zp * quaternion.zp;
- qrealinner zw = quaternion.zp * quaternion.wp;
+ float xx = quaternion.xp * quaternion.xp;
+ float xy = quaternion.xp * quaternion.yp;
+ float xz = quaternion.xp * quaternion.zp;
+ float xw = quaternion.xp * quaternion.wp;
+ float yy = quaternion.yp * quaternion.yp;
+ float yz = quaternion.yp * quaternion.zp;
+ float yw = quaternion.yp * quaternion.wp;
+ float zz = quaternion.zp * quaternion.zp;
+ float zw = quaternion.zp * quaternion.wp;
m.m[0][0] = 1.0f - 2 * (yy + zz);
m.m[1][0] = 2 * (xy - zw);
m.m[2][0] = 2 * (xz + yw);
@@ -1137,33 +1136,33 @@ QMatrix4x4& QMatrix4x4::ortho(qreal left, qreal right, qreal bottom, qreal top,
// which will be more efficient to modify with further
// transformations than producing a "General" matrix.
translate(QVector3D
- (qf2vt_round(-(left + right) / width),
- qf2vt_round(-(top + bottom) / invheight),
+ (-(left + right) / width,
+ -(top + bottom) / invheight,
0.0f, 1));
scale(QVector3D
- (qf2vt_round(2.0f / width),
- qf2vt_round(2.0f / invheight),
+ (2.0f / width,
+ 2.0f / invheight,
-1.0f, 1));
return *this;
}
#endif
QMatrix4x4 m(1);
- m.m[0][0] = qf2vt_round(2.0f / width);
- m.m[1][0] = qf2vt_round(0.0f);
- m.m[2][0] = qf2vt_round(0.0f);
- m.m[3][0] = qf2vt_round(-(left + right) / width);
- m.m[0][1] = qf2vt_round(0.0f);
- m.m[1][1] = qf2vt_round(2.0f / invheight);
- m.m[2][1] = qf2vt_round(0.0f);
- m.m[3][1] = qf2vt_round(-(top + bottom) / invheight);
- m.m[0][2] = qf2vt_round(0.0f);
- m.m[1][2] = qf2vt_round(0.0f);
- m.m[2][2] = qf2vt_round(-2.0f / clip);
- m.m[3][2] = qf2vt_round(-(nearPlane + farPlane) / clip);
- m.m[0][3] = qf2vt_round(0.0f);
- m.m[1][3] = qf2vt_round(0.0f);
- m.m[2][3] = qf2vt_round(0.0f);
- m.m[3][3] = qf2vt_round(1.0f);
+ m.m[0][0] = 2.0f / width;
+ m.m[1][0] = 0.0f;
+ m.m[2][0] = 0.0f;
+ m.m[3][0] = -(left + right) / width;
+ m.m[0][1] = 0.0f;
+ m.m[1][1] = 2.0f / invheight;
+ m.m[2][1] = 0.0f;
+ m.m[3][1] = -(top + bottom) / invheight;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = -2.0f / clip;
+ m.m[3][2] = -(nearPlane + farPlane) / clip;
+ m.m[0][3] = 0.0f;
+ m.m[1][3] = 0.0f;
+ m.m[2][3] = 0.0f;
+ m.m[3][3] = 1.0f;
// Apply the projection.
*this *= m;
@@ -1189,22 +1188,22 @@ QMatrix4x4& QMatrix4x4::frustum(qreal left, qreal right, qreal bottom, qreal top
qreal width = right - left;
qreal invheight = top - bottom;
qreal clip = farPlane - nearPlane;
- m.m[0][0] = qf2vt_round(2.0f * nearPlane / width);
- m.m[1][0] = qf2vt_round(0.0f);
- m.m[2][0] = qf2vt_round((left + right) / width);
- m.m[3][0] = qf2vt_round(0.0f);
- m.m[0][1] = qf2vt_round(0.0f);
- m.m[1][1] = qf2vt_round(2.0f * nearPlane / invheight);
- m.m[2][1] = qf2vt_round((top + bottom) / invheight);
- m.m[3][1] = qf2vt_round(0.0f);
- m.m[0][2] = qf2vt_round(0.0f);
- m.m[1][2] = qf2vt_round(0.0f);
- m.m[2][2] = qf2vt_round(-(nearPlane + farPlane) / clip);
- m.m[3][2] = qf2vt_round(-(2.0f * nearPlane * farPlane) / clip);
- m.m[0][3] = qf2vt_round(0.0f);
- m.m[1][3] = qf2vt_round(0.0f);
- m.m[2][3] = qf2vt_round(-1.0f);
- m.m[3][3] = qf2vt_round(0.0f);
+ m.m[0][0] = 2.0f * nearPlane / width;
+ m.m[1][0] = 0.0f;
+ m.m[2][0] = (left + right) / width;
+ m.m[3][0] = 0.0f;
+ m.m[0][1] = 0.0f;
+ m.m[1][1] = 2.0f * nearPlane / invheight;
+ m.m[2][1] = (top + bottom) / invheight;
+ m.m[3][1] = 0.0f;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = -(nearPlane + farPlane) / clip;
+ m.m[3][2] = -2.0f * nearPlane * farPlane / clip;
+ m.m[0][3] = 0.0f;
+ m.m[1][3] = 0.0f;
+ m.m[2][3] = -1.0f;
+ m.m[3][3] = 0.0f;
// Apply the projection.
*this *= m;
@@ -1234,22 +1233,22 @@ QMatrix4x4& QMatrix4x4::perspective(qreal angle, qreal aspect, qreal nearPlane,
return *this;
qreal cotan = qCos(radians) / sine;
qreal clip = farPlane - nearPlane;
- m.m[0][0] = qf2vt_round(cotan / aspect);
- m.m[1][0] = qf2vt_round(0.0f);
- m.m[2][0] = qf2vt_round(0.0f);
- m.m[3][0] = qf2vt_round(0.0f);
- m.m[0][1] = qf2vt_round(0.0f);
- m.m[1][1] = qf2vt_round(cotan);
- m.m[2][1] = qf2vt_round(0.0f);
- m.m[3][1] = qf2vt_round(0.0f);
- m.m[0][2] = qf2vt_round(0.0f);
- m.m[1][2] = qf2vt_round(0.0f);
- m.m[2][2] = qf2vt_round(-(nearPlane + farPlane) / clip);
- m.m[3][2] = qf2vt_round(-(2.0f * nearPlane * farPlane) / clip);
- m.m[0][3] = qf2vt_round(0.0f);
- m.m[1][3] = qf2vt_round(0.0f);
- m.m[2][3] = qf2vt_round(-1.0f);
- m.m[3][3] = qf2vt_round(0.0f);
+ m.m[0][0] = cotan / aspect;
+ m.m[1][0] = 0.0f;
+ m.m[2][0] = 0.0f;
+ m.m[3][0] = 0.0f;
+ m.m[0][1] = 0.0f;
+ m.m[1][1] = cotan;
+ m.m[2][1] = 0.0f;
+ m.m[3][1] = 0.0f;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = -(nearPlane + farPlane) / clip;
+ m.m[3][2] = -(2.0f * nearPlane * farPlane) / clip;
+ m.m[0][3] = 0.0f;
+ m.m[1][3] = 0.0f;
+ m.m[2][3] = -1.0f;
+ m.m[3][3] = 0.0f;
// Apply the projection.
*this *= m;
@@ -1339,7 +1338,7 @@ void QMatrix4x4::toValueArray(qreal *values) const
{
for (int row = 0; row < 4; ++row)
for (int col = 0; col < 4; ++col)
- values[row * 4 + col] = qt_math3d_convert<qreal, qrealinner>(m[col][row]);
+ values[row * 4 + col] = qreal(m[col][row]);
}
/*!
@@ -1351,12 +1350,9 @@ void QMatrix4x4::toValueArray(qreal *values) const
*/
QMatrix QMatrix4x4::toAffine() const
{
- return QMatrix(qt_math3d_convert<qreal, qrealinner>(m[0][0]),
- qt_math3d_convert<qreal, qrealinner>(m[0][1]),
- qt_math3d_convert<qreal, qrealinner>(m[1][0]),
- qt_math3d_convert<qreal, qrealinner>(m[1][1]),
- qt_math3d_convert<qreal, qrealinner>(m[3][0]),
- qt_math3d_convert<qreal, qrealinner>(m[3][1]));
+ return QMatrix(qreal(m[0][0]), qreal(m[0][1]),
+ qreal(m[1][0]), qreal(m[1][1]),
+ qreal(m[3][0]), qreal(m[3][1]));
}
/*!
@@ -1368,15 +1364,9 @@ QMatrix QMatrix4x4::toAffine() const
*/
QTransform QMatrix4x4::toTransform() const
{
- return QTransform(qt_math3d_convert<qreal, qrealinner>(m[0][0]),
- qt_math3d_convert<qreal, qrealinner>(m[0][1]),
- qt_math3d_convert<qreal, qrealinner>(m[0][3]),
- qt_math3d_convert<qreal, qrealinner>(m[1][0]),
- qt_math3d_convert<qreal, qrealinner>(m[1][1]),
- qt_math3d_convert<qreal, qrealinner>(m[1][3]),
- qt_math3d_convert<qreal, qrealinner>(m[3][0]),
- qt_math3d_convert<qreal, qrealinner>(m[3][1]),
- qt_math3d_convert<qreal, qrealinner>(m[3][3]));
+ return QTransform(qreal(m[0][0]), qreal(m[0][1]), qreal(m[0][3]),
+ qreal(m[1][0]), qreal(m[1][1]), qreal(m[1][3]),
+ qreal(m[3][0]), qreal(m[3][1]), qreal(m[3][3]));
}
/*!
@@ -1442,7 +1432,7 @@ QTransform QMatrix4x4::toTransform() const
*/
/*!
- \fn qrealinner *QMatrix4x4::data()
+ \fn float *QMatrix4x4::data()
Returns a pointer to the raw data of this matrix. This is indended
for use with raw GL functions.
@@ -1451,7 +1441,7 @@ QTransform QMatrix4x4::toTransform() const
*/
/*!
- \fn const qrealinner *QMatrix4x4::data() const
+ \fn const float *QMatrix4x4::data() const
Returns a constant pointer to the raw data of this matrix.
This is indended for use with raw GL functions.
@@ -1460,7 +1450,7 @@ QTransform QMatrix4x4::toTransform() const
*/
/*!
- \fn const qrealinner *QMatrix4x4::constData() const
+ \fn const float *QMatrix4x4::constData() const
Returns a constant pointer to the raw data of this matrix.
This is indended for use with raw GL functions.
@@ -1519,8 +1509,8 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
{
// Orientation is dependent on the upper 3x3 matrix; subtract the
// homogeneous scaling element from the trace of the 4x4 matrix
- qrealinner tr = m[0][0] + m[1][1] + m[2][2];
- qreal cosa = qt_math3d_convert<qreal, qrealinner>(0.5f * (tr - 1.0f));
+ float tr = m[0][0] + m[1][1] + m[2][2];
+ qreal cosa = qreal(0.5f * (tr - 1.0f));
angle = acos(cosa) * 180.0f / M_PI;
// Any axis will work if r is zero (means no rotation)
@@ -1540,11 +1530,11 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
}
// rads == PI
- qrealinner tmp;
+ float tmp;
// r00 is maximum
if ((m[0][0] >= m[2][2]) && (m[0][0] >= m[1][1])) {
- axis.xp = 0.5f * qvtsqrt(m[0][0] - m[1][1] - m[2][2] + 1.0f);
+ axis.xp = 0.5f * qSqrt(m[0][0] - m[1][1] - m[2][2] + 1.0f);
tmp = 0.5f / axis.x();
axis.yp = m[1][0] * tmp;
axis.zp = m[2][0] * tmp;
@@ -1552,7 +1542,7 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
// r11 is maximum
if ((m[1][1] >= m[2][2]) && (m[1][1] >= m[0][0])) {
- axis.yp = 0.5f * qvtsqrt(m[1][1] - m[0][0] - m[2][2] + 1.0f);
+ axis.yp = 0.5f * qSqrt(m[1][1] - m[0][0] - m[2][2] + 1.0f);
tmp = 0.5f / axis.y();
axis.xp = tmp * m[1][0];
axis.zp = tmp * m[2][1];
@@ -1560,7 +1550,7 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
// r22 is maximum
if ((m[2][2] >= m[1][1]) && (m[2][2] >= m[0][0])) {
- axis.zp = 0.5f * qvtsqrt(m[2][2] - m[0][0] - m[1][1] + 1.0f);
+ axis.zp = 0.5f * qSqrt(m[2][2] - m[0][0] - m[1][1] + 1.0f);
tmp = 0.5f / axis.z();
axis.xp = m[2][0]*tmp;
axis.yp = m[2][1]*tmp;
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index 6428b20..2b485c1 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -70,14 +70,14 @@ public:
qreal m41, qreal m42, qreal m43, qreal m44);
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
template <int N, int M>
- explicit QMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix);
+ explicit QMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix);
#endif
- QMatrix4x4(const qrealinner *values, int cols, int rows);
+ QMatrix4x4(const float *values, int cols, int rows);
QMatrix4x4(const QTransform& transform);
QMatrix4x4(const QMatrix& matrix);
inline qreal operator()(int row, int column) const;
- inline qrealinner& operator()(int row, int column);
+ inline float& operator()(int row, int column);
inline QVector4D column(int index) const;
inline void setColumn(int index, const QVector4D& value);
@@ -171,12 +171,12 @@ public:
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
template <int N, int M>
- QGenericMatrix<N, M, qreal, qrealinner> toGenericMatrix() const;
+ QGenericMatrix<N, M, qreal, float> toGenericMatrix() const;
#endif
- inline qrealinner *data();
- inline const qrealinner *data() const { return m[0]; }
- inline const qrealinner *constData() const { return m[0]; }
+ inline float *data();
+ inline const float *data() const { return m[0]; }
+ inline const float *constData() const { return m[0]; }
void inferSpecialType();
@@ -185,7 +185,7 @@ public:
#endif
private:
- qrealinner m[4][4]; // Column-major order to match OpenGL.
+ float m[4][4]; // Column-major order to match OpenGL.
int flagBits; // Flag bits from the enum below.
enum {
@@ -219,9 +219,9 @@ inline QMatrix4x4::QMatrix4x4
template <int N, int M>
Q_INLINE_TEMPLATE QMatrix4x4::QMatrix4x4
- (const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+ (const QGenericMatrix<N, M, qreal, float>& matrix)
{
- const qrealinner *values = matrix.constData();
+ const float *values = matrix.constData();
for (int col = 0; col < 4; ++col) {
for (int row = 0; row < 4; ++row) {
if (col < N && row < M)
@@ -236,10 +236,10 @@ Q_INLINE_TEMPLATE QMatrix4x4::QMatrix4x4
}
template <int N, int M>
-QGenericMatrix<N, M, qreal, qrealinner> QMatrix4x4::toGenericMatrix() const
+QGenericMatrix<N, M, qreal, float> QMatrix4x4::toGenericMatrix() const
{
- QGenericMatrix<N, M, qreal, qrealinner> result;
- qrealinner *values = result.data();
+ QGenericMatrix<N, M, qreal, float> result;
+ float *values = result.data();
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
if (col < 4 && row < 4)
@@ -258,10 +258,10 @@ QGenericMatrix<N, M, qreal, qrealinner> QMatrix4x4::toGenericMatrix() const
inline qreal QMatrix4x4::operator()(int row, int column) const
{
Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4);
- return qt_math3d_convert<qreal, qrealinner>(m[column][row]);
+ return qreal(m[column][row]);
}
-inline qrealinner& QMatrix4x4::operator()(int row, int column)
+inline float& QMatrix4x4::operator()(int row, int column)
{
Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4);
flagBits = General;
@@ -420,23 +420,22 @@ inline QMatrix4x4& QMatrix4x4::operator*=(const QMatrix4x4& other)
inline QMatrix4x4& QMatrix4x4::operator*=(qreal factor)
{
- qrealinner f(factor);
- m[0][0] *= f;
- m[0][1] *= f;
- m[0][2] *= f;
- m[0][3] *= f;
- m[1][0] *= f;
- m[1][1] *= f;
- m[1][2] *= f;
- m[1][3] *= f;
- m[2][0] *= f;
- m[2][1] *= f;
- m[2][2] *= f;
- m[2][3] *= f;
- m[3][0] *= f;
- m[3][1] *= f;
- m[3][2] *= f;
- m[3][3] *= f;
+ m[0][0] *= factor;
+ m[0][1] *= factor;
+ m[0][2] *= factor;
+ m[0][3] *= factor;
+ m[1][0] *= factor;
+ m[1][1] *= factor;
+ m[1][2] *= factor;
+ m[1][3] *= factor;
+ m[2][0] *= factor;
+ m[2][1] *= factor;
+ m[2][2] *= factor;
+ m[2][3] *= factor;
+ m[3][0] *= factor;
+ m[3][1] *= factor;
+ m[3][2] *= factor;
+ m[3][3] *= factor;
flagBits = General;
return *this;
}
@@ -604,7 +603,7 @@ inline QMatrix4x4 operator*(const QMatrix4x4& m1, const QMatrix4x4& m2)
inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[0][1] +
vector.zp * matrix.m[0][2] +
@@ -629,7 +628,7 @@ inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix)
inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[1][0] +
vector.zp * matrix.m[2][0] +
@@ -658,7 +657,7 @@ inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector)
inline QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[0][1] +
vector.zp * matrix.m[0][2] +
@@ -680,7 +679,7 @@ inline QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix)
inline QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[1][0] +
vector.zp * matrix.m[2][0] +
@@ -704,8 +703,8 @@ inline QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector)
inline QPoint operator*(const QPoint& point, const QMatrix4x4& matrix)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -725,8 +724,8 @@ inline QPoint operator*(const QPoint& point, const QMatrix4x4& matrix)
inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -739,18 +738,16 @@ inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix)
yin * matrix.m[3][1] +
matrix.m[3][3];
if (w == 1.0f) {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x),
- qt_math3d_convert<qreal, qrealinner>(y));
+ return QPointF(qreal(x), qreal(y));
} else {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x / w),
- qt_math3d_convert<qreal, qrealinner>(y / w));
+ return QPointF(qreal(x / w), qreal(y / w));
}
}
inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -770,8 +767,8 @@ inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point)
inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -784,11 +781,9 @@ inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point)
yin * matrix.m[1][3] +
matrix.m[3][3];
if (w == 1.0f) {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x),
- qt_math3d_convert<qreal, qrealinner>(y));
+ return QPointF(qreal(x), qreal(y));
} else {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x / w),
- qt_math3d_convert<qreal, qrealinner>(y / w));
+ return QPointF(qreal(x / w), qreal(y / w));
}
}
@@ -817,46 +812,44 @@ inline QMatrix4x4 operator-(const QMatrix4x4& matrix)
inline QMatrix4x4 operator*(qreal factor, const QMatrix4x4& matrix)
{
QMatrix4x4 m(1);
- qrealinner f(factor);
- m.m[0][0] = matrix.m[0][0] * f;
- m.m[0][1] = matrix.m[0][1] * f;
- m.m[0][2] = matrix.m[0][2] * f;
- m.m[0][3] = matrix.m[0][3] * f;
- m.m[1][0] = matrix.m[1][0] * f;
- m.m[1][1] = matrix.m[1][1] * f;
- m.m[1][2] = matrix.m[1][2] * f;
- m.m[1][3] = matrix.m[1][3] * f;
- m.m[2][0] = matrix.m[2][0] * f;
- m.m[2][1] = matrix.m[2][1] * f;
- m.m[2][2] = matrix.m[2][2] * f;
- m.m[2][3] = matrix.m[2][3] * f;
- m.m[3][0] = matrix.m[3][0] * f;
- m.m[3][1] = matrix.m[3][1] * f;
- m.m[3][2] = matrix.m[3][2] * f;
- m.m[3][3] = matrix.m[3][3] * f;
+ m.m[0][0] = matrix.m[0][0] * factor;
+ m.m[0][1] = matrix.m[0][1] * factor;
+ m.m[0][2] = matrix.m[0][2] * factor;
+ m.m[0][3] = matrix.m[0][3] * factor;
+ m.m[1][0] = matrix.m[1][0] * factor;
+ m.m[1][1] = matrix.m[1][1] * factor;
+ m.m[1][2] = matrix.m[1][2] * factor;
+ m.m[1][3] = matrix.m[1][3] * factor;
+ m.m[2][0] = matrix.m[2][0] * factor;
+ m.m[2][1] = matrix.m[2][1] * factor;
+ m.m[2][2] = matrix.m[2][2] * factor;
+ m.m[2][3] = matrix.m[2][3] * factor;
+ m.m[3][0] = matrix.m[3][0] * factor;
+ m.m[3][1] = matrix.m[3][1] * factor;
+ m.m[3][2] = matrix.m[3][2] * factor;
+ m.m[3][3] = matrix.m[3][3] * factor;
return m;
}
inline QMatrix4x4 operator*(const QMatrix4x4& matrix, qreal factor)
{
QMatrix4x4 m(1);
- qrealinner f(factor);
- m.m[0][0] = matrix.m[0][0] * f;
- m.m[0][1] = matrix.m[0][1] * f;
- m.m[0][2] = matrix.m[0][2] * f;
- m.m[0][3] = matrix.m[0][3] * f;
- m.m[1][0] = matrix.m[1][0] * f;
- m.m[1][1] = matrix.m[1][1] * f;
- m.m[1][2] = matrix.m[1][2] * f;
- m.m[1][3] = matrix.m[1][3] * f;
- m.m[2][0] = matrix.m[2][0] * f;
- m.m[2][1] = matrix.m[2][1] * f;
- m.m[2][2] = matrix.m[2][2] * f;
- m.m[2][3] = matrix.m[2][3] * f;
- m.m[3][0] = matrix.m[3][0] * f;
- m.m[3][1] = matrix.m[3][1] * f;
- m.m[3][2] = matrix.m[3][2] * f;
- m.m[3][3] = matrix.m[3][3] * f;
+ m.m[0][0] = matrix.m[0][0] * factor;
+ m.m[0][1] = matrix.m[0][1] * factor;
+ m.m[0][2] = matrix.m[0][2] * factor;
+ m.m[0][3] = matrix.m[0][3] * factor;
+ m.m[1][0] = matrix.m[1][0] * factor;
+ m.m[1][1] = matrix.m[1][1] * factor;
+ m.m[1][2] = matrix.m[1][2] * factor;
+ m.m[1][3] = matrix.m[1][3] * factor;
+ m.m[2][0] = matrix.m[2][0] * factor;
+ m.m[2][1] = matrix.m[2][1] * factor;
+ m.m[2][2] = matrix.m[2][2] * factor;
+ m.m[2][3] = matrix.m[2][3] * factor;
+ m.m[3][0] = matrix.m[3][0] * factor;
+ m.m[3][1] = matrix.m[3][1] * factor;
+ m.m[3][2] = matrix.m[3][2] * factor;
+ m.m[3][3] = matrix.m[3][3] * factor;
return m;
}
@@ -934,7 +927,7 @@ inline QRectF QMatrix4x4::mapRect(const QRectF& rect) const
return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax));
}
-inline qrealinner *QMatrix4x4::data()
+inline float *QMatrix4x4::data()
{
// We have to assume that the caller will modify the matrix elements,
// so we flip it over to "General" mode.
@@ -947,17 +940,17 @@ Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QMatrix4x4 &m);
#endif
template <int N, int M>
-QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
{
return QMatrix4x4(matrix.constData(), N, M);
}
template <int N, int M>
-QGenericMatrix<N, M, qreal, qrealinner> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
+QGenericMatrix<N, M, qreal, float> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
{
- QGenericMatrix<N, M, qreal, qrealinner> result;
- const qrealinner *m = matrix.constData();
- qrealinner *values = result.data();
+ QGenericMatrix<N, M, qreal, float> result;
+ const float *m = matrix.constData();
+ float *values = result.data();
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
if (col < 4 && row < 4)
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index 121ff51..efde362 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -40,8 +40,8 @@
****************************************************************************/
#include "qquaternion.h"
-#include "qmath3dutil_p.h"
#include <QtCore/qmath.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -223,8 +223,7 @@ QT_BEGIN_NAMESPACE
*/
qreal QQuaternion::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return qSqrt(xp * xp + yp * yp + zp * zp + wp * wp);
}
/*!
@@ -234,8 +233,7 @@ qreal QQuaternion::length() const
*/
qreal QQuaternion::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return xp * xp + yp * yp + zp * zp + wp * wp;
}
/*!
@@ -342,6 +340,10 @@ QVector3D QQuaternion::rotateVector(const QVector3D& vector) const
\sa operator*=()
*/
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
#ifndef QT_NO_VECTOR3D
/*!
@@ -354,9 +356,10 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56
// We normalize the result just in case the values are close
// to zero, as suggested in the above FAQ.
- qrealinner s, c;
+ qreal a = (angle / 2.0f) * M_PI / 180.0f;
+ qreal s = qSin(a);
+ qreal c = qCos(a);
QVector3D ax = axis.normalized();
- qt_math3d_sincos(angle / 2.0f, &s, &c);
return QQuaternion(c, ax.xp * s, ax.yp * s, ax.zp * s, 1).normalized();
}
@@ -369,17 +372,18 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
QQuaternion QQuaternion::fromAxisAndAngle
(qreal x, qreal y, qreal z, qreal angle)
{
- qrealinner xp = x;
- qrealinner yp = y;
- qrealinner zp = z;
- qrealinner s, c;
- qreal length = qvtsqrt(xp * xp + yp * yp + zp * zp);
+ float xp = x;
+ float yp = y;
+ float zp = z;
+ qreal length = qSqrt(xp * xp + yp * yp + zp * zp);
if (!qIsNull(length)) {
xp /= length;
yp /= length;
zp /= length;
}
- qt_math3d_sincos(angle / 2.0f, &s, &c);
+ qreal a = (angle / 2.0f) * M_PI / 180.0f;
+ qreal s = qSin(a);
+ qreal c = qCos(a);
return QQuaternion(c, xp * s, yp * s, zp * s, 1).normalized();
}
@@ -500,8 +504,7 @@ QQuaternion QQuaternion::interpolate
// Determine the angle between the two quaternions.
QQuaternion q2b;
qreal dot;
- dot = qvtdot64(qvtmul64(q1.xp, q2.xp) + qvtmul64(q1.yp, q2.yp) +
- qvtmul64(q1.zp, q2.zp) + qvtmul64(q1.wp, q2.wp));
+ dot = q1.xp * q2.xp + q1.yp * q2.yp + q1.zp * q2.zp + q1.wp * q2.wp;
if (dot >= 0.0f) {
q2b = q2;
} else {
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index 6ba63ec..f0cb308 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -129,11 +129,11 @@ public:
(const QQuaternion& q1, const QQuaternion& q2, qreal t);
private:
- qrealinner wp, xp, yp, zp;
+ float wp, xp, yp, zp;
friend class QMatrix4x4;
- QQuaternion(qrealinner scalar, qrealinner xpos, qrealinner ypos, qrealinner zpos, int dummy);
+ QQuaternion(float scalar, float xpos, float ypos, float zpos, int dummy);
};
inline QQuaternion::QQuaternion() : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {}
@@ -141,7 +141,7 @@ inline QQuaternion::QQuaternion() : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {}
inline QQuaternion::QQuaternion(qreal scalar, qreal xpos, qreal ypos, qreal zpos) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
-inline QQuaternion::QQuaternion(qrealinner scalar, qrealinner xpos, qrealinner ypos, qrealinner zpos, int) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
+inline QQuaternion::QQuaternion(float scalar, float xpos, float ypos, float zpos, int) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
inline QQuaternion::QQuaternion(int scalar, int xpos, int ypos, int zpos) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
@@ -155,10 +155,10 @@ inline bool QQuaternion::isIdentity() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && wp == 1.0f;
}
-inline qreal QQuaternion::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QQuaternion::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QQuaternion::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
-inline qreal QQuaternion::scalar() const { return qt_math3d_convert<qreal, qrealinner>(wp); }
+inline qreal QQuaternion::x() const { return qreal(xp); }
+inline qreal QQuaternion::y() const { return qreal(yp); }
+inline qreal QQuaternion::z() const { return qreal(zp); }
+inline qreal QQuaternion::scalar() const { return qreal(wp); }
inline void QQuaternion::setX(qreal x) { xp = x; }
inline void QQuaternion::setY(qreal y) { yp = y; }
@@ -190,11 +190,10 @@ inline QQuaternion &QQuaternion::operator-=(const QQuaternion &quaternion)
inline QQuaternion &QQuaternion::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
- wp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
+ wp *= factor;
return *this;
}
@@ -202,19 +201,19 @@ inline const QQuaternion operator*(const QQuaternion &q1, const QQuaternion& q2)
{
// Algorithm from:
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q53
- qrealinner x = q1.wp * q2.xp +
+ float x = q1.wp * q2.xp +
q1.xp * q2.wp +
q1.yp * q2.zp -
q1.zp * q2.yp;
- qrealinner y = q1.wp * q2.yp +
+ float y = q1.wp * q2.yp +
q1.yp * q2.wp +
q1.zp * q2.xp -
q1.xp * q2.zp;
- qrealinner z = q1.wp * q2.zp +
+ float z = q1.wp * q2.zp +
q1.zp * q2.wp +
q1.xp * q2.yp -
q1.yp * q2.xp;
- qrealinner w = q1.wp * q2.wp -
+ float w = q1.wp * q2.wp -
q1.xp * q2.xp -
q1.yp * q2.yp -
q1.zp * q2.zp;
@@ -229,11 +228,10 @@ inline QQuaternion &QQuaternion::operator*=(const QQuaternion &quaternion)
inline QQuaternion &QQuaternion::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
- wp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
+ wp /= divisor;
return *this;
}
@@ -259,14 +257,12 @@ inline const QQuaternion operator-(const QQuaternion &q1, const QQuaternion &q2)
inline const QQuaternion operator*(qreal factor, const QQuaternion &quaternion)
{
- qrealinner f(factor);
- return QQuaternion(quaternion.wp * f, quaternion.xp * f, quaternion.yp * f, quaternion.zp * f, 1);
+ return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor, 1);
}
inline const QQuaternion operator*(const QQuaternion &quaternion, qreal factor)
{
- qrealinner f(factor);
- return QQuaternion(quaternion.wp * f, quaternion.xp * f, quaternion.yp * f, quaternion.zp * f, 1);
+ return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor, 1);
}
inline const QQuaternion operator-(const QQuaternion &quaternion)
@@ -276,8 +272,7 @@ inline const QQuaternion operator-(const QQuaternion &quaternion)
inline const QQuaternion operator/(const QQuaternion &quaternion, qreal divisor)
{
- qrealinner d(divisor);
- return QQuaternion(quaternion.wp / d, quaternion.xp / d, quaternion.yp / d, quaternion.zp / d, 1);
+ return QQuaternion(quaternion.wp / divisor, quaternion.xp / divisor, quaternion.yp / divisor, quaternion.zp / divisor, 1);
}
inline bool qFuzzyCompare(const QQuaternion& q1, const QQuaternion& q2)
diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp
index 0426fc5..31e5be6 100644
--- a/src/gui/math3d/qvector2d.cpp
+++ b/src/gui/math3d/qvector2d.cpp
@@ -42,7 +42,8 @@
#include "qvector2d.h"
#include "qvector3d.h"
#include "qvector4d.h"
-#include "qmath3dutil_p.h"
+#include <QtCore/qdebug.h>
+#include <QtCore/qmath.h>
QT_BEGIN_NAMESPACE
@@ -169,7 +170,7 @@ QVector2D::QVector2D(const QVector4D& vector)
*/
qreal QVector2D::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp));
+ return qSqrt(xp * xp + yp * yp);
}
/*!
@@ -180,7 +181,7 @@ qreal QVector2D::length() const
*/
qreal QVector2D::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp));
+ return xp * xp + yp * yp;
}
/*!
@@ -263,7 +264,7 @@ void QVector2D::normalize()
*/
qreal QVector2D::dotProduct(const QVector2D& v1, const QVector2D& v2)
{
- return qvtdot64(qvtmul64(v1.xp, v2.xp) + qvtmul64(v1.yp, v2.yp));
+ return v1.xp * v2.xp + v1.yp * v2.yp;
}
/*!
diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h
index a72ecc5..5e15de6 100644
--- a/src/gui/math3d/qvector2d.h
+++ b/src/gui/math3d/qvector2d.h
@@ -42,7 +42,6 @@
#ifndef QVECTOR2D_H
#define QVECTOR2D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -117,18 +116,17 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp;
+ float xp, yp;
- QVector2D(qrealinner xpos, qrealinner ypos, int dummy);
+ QVector2D(float xpos, float ypos, int dummy);
friend class QVector3D;
friend class QVector4D;
- friend class QVertexArray;
};
inline QVector2D::QVector2D() : xp(0.0f), yp(0.0f) {}
-inline QVector2D::QVector2D(qrealinner xpos, qrealinner ypos, int) : xp(xpos), yp(ypos) {}
+inline QVector2D::QVector2D(float xpos, float ypos, int) : xp(xpos), yp(ypos) {}
inline QVector2D::QVector2D(qreal xpos, qreal ypos) : xp(xpos), yp(ypos) {}
@@ -143,8 +141,8 @@ inline bool QVector2D::isNull() const
return qIsNull(xp) && qIsNull(yp);
}
-inline qreal QVector2D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector2D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
+inline qreal QVector2D::x() const { return qreal(xp); }
+inline qreal QVector2D::y() const { return qreal(yp); }
inline void QVector2D::setX(qreal x) { xp = x; }
inline void QVector2D::setY(qreal y) { yp = y; }
@@ -165,9 +163,8 @@ inline QVector2D &QVector2D::operator-=(const QVector2D &vector)
inline QVector2D &QVector2D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
+ xp *= factor;
+ yp *= factor;
return *this;
}
@@ -180,9 +177,8 @@ inline QVector2D &QVector2D::operator*=(const QVector2D &vector)
inline QVector2D &QVector2D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
+ xp /= divisor;
+ yp /= divisor;
return *this;
}
@@ -208,14 +204,12 @@ inline const QVector2D operator-(const QVector2D &v1, const QVector2D &v2)
inline const QVector2D operator*(qreal factor, const QVector2D &vector)
{
- qrealinner f(factor);
- return QVector2D(vector.xp * f, vector.yp * f, 1);
+ return QVector2D(vector.xp * factor, vector.yp * factor, 1);
}
inline const QVector2D operator*(const QVector2D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector2D(vector.xp * f, vector.yp * f, 1);
+ return QVector2D(vector.xp * factor, vector.yp * factor, 1);
}
inline const QVector2D operator*(const QVector2D &v1, const QVector2D &v2)
@@ -230,8 +224,7 @@ inline const QVector2D operator-(const QVector2D &vector)
inline const QVector2D operator/(const QVector2D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector2D(vector.xp / d, vector.yp / d, 1);
+ return QVector2D(vector.xp / divisor, vector.yp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector2D& v1, const QVector2D& v2)
@@ -246,8 +239,7 @@ inline QPoint QVector2D::toPoint() const
inline QPointF QVector2D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp
index 32068ee..814753d 100644
--- a/src/gui/math3d/qvector3d.cpp
+++ b/src/gui/math3d/qvector3d.cpp
@@ -42,8 +42,8 @@
#include "qvector3d.h"
#include "qvector2d.h"
#include "qvector4d.h"
-#include "qmath3dutil_p.h"
#include <QtCore/qmath.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -287,7 +287,7 @@ void QVector3D::normalize()
*/
qreal QVector3D::dotProduct(const QVector3D& v1, const QVector3D& v2)
{
- return qvtdot64(qvtmul64(v1.xp, v2.xp) + qvtmul64(v1.yp, v2.yp) + qvtmul64(v1.zp, v2.zp));
+ return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp;
}
/*!
@@ -535,7 +535,7 @@ QVector4D QVector3D::toVector4D() const
*/
qreal QVector3D::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp) + qvtmul64(zp, zp));
+ return qSqrt(xp * xp + yp * yp + zp * zp);
}
/*!
@@ -546,7 +546,7 @@ qreal QVector3D::length() const
*/
qreal QVector3D::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp) + qvtmul64(zp, zp));
+ return xp * xp + yp * yp + zp * zp;
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h
index 8f8f3b4..4771d5a 100644
--- a/src/gui/math3d/qvector3d.h
+++ b/src/gui/math3d/qvector3d.h
@@ -42,7 +42,6 @@
#ifndef QVECTOR3D_H
#define QVECTOR3D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -130,16 +129,14 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp, zp;
+ float xp, yp, zp;
- QVector3D(qrealinner xpos, qrealinner ypos, qrealinner zpos, int dummy);
+ QVector3D(float xpos, float ypos, float zpos, int dummy);
friend class QVector2D;
friend class QVector4D;
friend class QQuaternion;
friend class QMatrix4x4;
- friend class QVertexArray;
- friend class QGLPainter;
#ifndef QT_NO_MATRIX4X4
friend QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix);
friend QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector);
@@ -150,7 +147,7 @@ inline QVector3D::QVector3D() : xp(0.0f), yp(0.0f), zp(0.0f) {}
inline QVector3D::QVector3D(qreal xpos, qreal ypos, qreal zpos) : xp(xpos), yp(ypos), zp(zpos) {}
-inline QVector3D::QVector3D(qrealinner xpos, qrealinner ypos, qrealinner zpos, int) : xp(xpos), yp(ypos), zp(zpos) {}
+inline QVector3D::QVector3D(float xpos, float ypos, float zpos, int) : xp(xpos), yp(ypos), zp(zpos) {}
inline QVector3D::QVector3D(int xpos, int ypos, int zpos) : xp(xpos), yp(ypos), zp(zpos) {}
@@ -163,9 +160,9 @@ inline bool QVector3D::isNull() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp);
}
-inline qreal QVector3D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector3D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QVector3D::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
+inline qreal QVector3D::x() const { return qreal(xp); }
+inline qreal QVector3D::y() const { return qreal(yp); }
+inline qreal QVector3D::z() const { return qreal(zp); }
inline void QVector3D::setX(qreal x) { xp = x; }
inline void QVector3D::setY(qreal y) { yp = y; }
@@ -189,10 +186,9 @@ inline QVector3D &QVector3D::operator-=(const QVector3D &vector)
inline QVector3D &QVector3D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
return *this;
}
@@ -206,10 +202,9 @@ inline QVector3D &QVector3D::operator*=(const QVector3D& vector)
inline QVector3D &QVector3D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
return *this;
}
@@ -235,14 +230,12 @@ inline const QVector3D operator-(const QVector3D &v1, const QVector3D &v2)
inline const QVector3D operator*(qreal factor, const QVector3D &vector)
{
- qrealinner f(factor);
- return QVector3D(vector.xp * f, vector.yp * f, vector.zp * f, 1);
+ return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor, 1);
}
inline const QVector3D operator*(const QVector3D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector3D(vector.xp * f, vector.yp * f, vector.zp * f, 1);
+ return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor, 1);
}
inline const QVector3D operator*(const QVector3D &v1, const QVector3D& v2)
@@ -257,8 +250,7 @@ inline const QVector3D operator-(const QVector3D &vector)
inline const QVector3D operator/(const QVector3D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector3D(vector.xp / d, vector.yp / d, vector.zp / d, 1);
+ return QVector3D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector3D& v1, const QVector3D& v2)
@@ -275,8 +267,7 @@ inline QPoint QVector3D::toPoint() const
inline QPointF QVector3D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp
index 4287806..d19665a 100644
--- a/src/gui/math3d/qvector4d.cpp
+++ b/src/gui/math3d/qvector4d.cpp
@@ -42,7 +42,8 @@
#include "qvector4d.h"
#include "qvector3d.h"
#include "qvector2d.h"
-#include "qmath3dutil_p.h"
+#include <QtCore/qdebug.h>
+#include <QtCore/qmath.h>
QT_BEGIN_NAMESPACE
@@ -237,8 +238,7 @@ QVector4D::QVector4D(const QVector3D& vector, qreal wpos)
*/
qreal QVector4D::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return qSqrt(xp * xp + yp * yp + zp * zp + wp * wp);
}
/*!
@@ -249,8 +249,7 @@ qreal QVector4D::length() const
*/
qreal QVector4D::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return xp * xp + yp * yp + zp * zp + wp * wp;
}
/*!
@@ -336,8 +335,7 @@ void QVector4D::normalize()
*/
qreal QVector4D::dotProduct(const QVector4D& v1, const QVector4D& v2)
{
- return qvtdot64(qvtmul64(v1.xp, v2.xp) + qvtmul64(v1.yp, v2.yp) +
- qvtmul64(v1.zp, v2.zp) + qvtmul64(v1.wp, v2.wp));
+ return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp + v1.wp * v2.wp;
}
/*!
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h
index 4ac6ae8..12efc95 100644
--- a/src/gui/math3d/qvector4d.h
+++ b/src/gui/math3d/qvector4d.h
@@ -42,7 +42,6 @@
#ifndef QVECTOR4D_H
#define QVECTOR4D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -127,15 +126,14 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp, zp, wp;
+ float xp, yp, zp, wp;
- QVector4D(qrealinner xpos, qrealinner ypos, qrealinner zpos, qrealinner wpos, int dummy);
+ QVector4D(float xpos, float ypos, float zpos, float wpos, int dummy);
friend class QVector2D;
friend class QVector3D;
friend class QQuaternion;
friend class QMatrix4x4;
- friend class QVertexArray;
#ifndef QT_NO_MATRIX4X4
friend QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix);
friend QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector);
@@ -146,7 +144,7 @@ inline QVector4D::QVector4D() : xp(0.0f), yp(0.0f), zp(0.0f), wp(0.0f) {}
inline QVector4D::QVector4D(qreal xpos, qreal ypos, qreal zpos, qreal wpos) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
-inline QVector4D::QVector4D(qrealinner xpos, qrealinner ypos, qrealinner zpos, qrealinner wpos, int) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
+inline QVector4D::QVector4D(float xpos, float ypos, float zpos, float wpos, int) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
inline QVector4D::QVector4D(int xpos, int ypos, int zpos, int wpos) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
@@ -159,10 +157,10 @@ inline bool QVector4D::isNull() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && qIsNull(wp);
}
-inline qreal QVector4D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector4D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QVector4D::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
-inline qreal QVector4D::w() const { return qt_math3d_convert<qreal, qrealinner>(wp); }
+inline qreal QVector4D::x() const { return qreal(xp); }
+inline qreal QVector4D::y() const { return qreal(yp); }
+inline qreal QVector4D::z() const { return qreal(zp); }
+inline qreal QVector4D::w() const { return qreal(wp); }
inline void QVector4D::setX(qreal x) { xp = x; }
inline void QVector4D::setY(qreal y) { yp = y; }
@@ -189,11 +187,10 @@ inline QVector4D &QVector4D::operator-=(const QVector4D &vector)
inline QVector4D &QVector4D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
- wp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
+ wp *= factor;
return *this;
}
@@ -208,11 +205,10 @@ inline QVector4D &QVector4D::operator*=(const QVector4D &vector)
inline QVector4D &QVector4D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
- wp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
+ wp /= divisor;
return *this;
}
@@ -238,14 +234,12 @@ inline const QVector4D operator-(const QVector4D &v1, const QVector4D &v2)
inline const QVector4D operator*(qreal factor, const QVector4D &vector)
{
- qrealinner f(factor);
- return QVector4D(vector.xp * f, vector.yp * f, vector.zp * f, vector.wp * f, 1);
+ return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor, 1);
}
inline const QVector4D operator*(const QVector4D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector4D(vector.xp * f, vector.yp * f, vector.zp * f, vector.wp * f, 1);
+ return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor, 1);
}
inline const QVector4D operator*(const QVector4D &v1, const QVector4D& v2)
@@ -260,8 +254,7 @@ inline const QVector4D operator-(const QVector4D &vector)
inline const QVector4D operator/(const QVector4D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector4D(vector.xp / d, vector.yp / d, vector.zp / d, vector.wp / d, 1);
+ return QVector4D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor, vector.wp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector4D& v1, const QVector4D& v2)
@@ -279,8 +272,7 @@ inline QPoint QVector4D::toPoint() const
inline QPointF QVector4D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM