Make gui/math3d classes use float rather than qreal
authorSean Harmer <sean.harmer@kdab.com>
Mon, 20 Aug 2012 19:55:40 +0000 (20:55 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 7 Sep 2012 11:27:38 +0000 (13:27 +0200)
commit51d40d7e9bdfc63c5109aef5b732aa2ba10f985a
treeffa750956ab2e96e0cd8f02bafa820042aa9f78a
parent56414e2498ae19d305b391678afe3a67a9069832
Make gui/math3d classes use float rather than qreal

This corrects the mismatch between using floats for internal storage
and qreal in the API of QVector*D which leads to lots of implicit
casts between double and float.

This change also stops users from being surprised by the loss of
precision when using these classes on desktop platforms and removes
the need for the private constructors taking a dummy int as the final
argument.

The QMatrix4x4 and QQuaternion classes have been changed to use float
for their internal storage since these are meant to be used in
conjunction with the QVector*D classes. This is to prevent unexpected
loss of precision and to improve performance.

The on-disk format has also been changed from double to float thereby
reducing the storage required when streaming vectors and matrices. This
is potentially a large saving when working with complex 3D meshes etc.

This also has a significant performance improvement when passing
matrices to QOpenGLShaderProgram (and QGLShaderProgram) as we no
longer have to iterate and convert the data to floats. This is
an operation that could easily be needed many times per frame.

This change also opens the door for further optimisations of these
classes to be implemented by using SIMD intrinsics.

This needs to be applied in conjunction with

https://codereview.qt-project.org/#change,33548

Task-number: QTBUG-21035
Task-number: QTBUG-20661
Change-Id: I9321b06040ffb93ae1cbd72fd2013267ac901b2e
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
24 files changed:
examples/opengl/pbuffers/cube.cpp
examples/opengl/shared/qtlogo.cpp
examples/widgets/graphicsview/boxes/scene.cpp
src/gui/math3d/qgenericmatrix.cpp
src/gui/math3d/qgenericmatrix.h
src/gui/math3d/qmatrix4x4.cpp
src/gui/math3d/qmatrix4x4.h
src/gui/math3d/qquaternion.cpp
src/gui/math3d/qquaternion.h
src/gui/math3d/qvector2d.cpp
src/gui/math3d/qvector2d.h
src/gui/math3d/qvector3d.cpp
src/gui/math3d/qvector3d.h
src/gui/math3d/qvector4d.cpp
src/gui/math3d/qvector4d.h
src/gui/opengl/qopenglshaderprogram.cpp
src/opengl/qglshaderprogram.cpp
tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp
tests/auto/widgets/graphicsview/qgraphicstransform/qgraphicstransform.pro
tests/auto/widgets/graphicsview/qgraphicstransform/tst_qgraphicstransform.cpp
tests/benchmarks/gui/math3d/qmatrix4x4/tst_qmatrix4x4.cpp
tests/benchmarks/gui/math3d/qquaternion/tst_qquaternion.cpp