Re: Question about QVector2D, QVector3D, QVector4D, etc...
Keith Gardner <kgardner <at> zebraimaging.com>
2011-08-19 19:31:45 GMT
Thanks for the quick response. It is now QTBUG-21035.
From: gunnar.sletta <at> nokia.com [mailto:gunnar.sletta <at> nokia.com]
Sent: Friday, August 19, 2011 1:47 PM
To: Keith Gardner
Cc: qt5-feedback <at> qt.nokia.com
Subject: Re: [Qt5-feedback] Question about QVector2D, QVector3D, QVector4D, etc...
On Aug 19, 2011, at 8:35 PM, ext Keith Gardner wrote:
> I noticed that QVector2D, QVector3D, QVector4D, etc... use floats as the storage type and I recognize
that it was a performance decision to do it this way. I am just wondering why the getters and setters for the
structures use qreal as the parameter type instead of floats.
> I know that on a mobile system qreal is a float, but on desktop systems qreal is a double. I would like to use
these data structures but the conversion from double to float only to be accessed as a double again seems to
be overly expensive.
> In Qt5, would it be possible to have the function parameters take a floats instead of a qreals?
I think that is a very good idea. Could you make a suggestion about that on the Qt bugtracker?
In general, we have discussed dropping the concept of qreal and sticking to the native C++ types. It is a pain
to develop something on desktop and have the sizeof(qreal) change behind the scenes or to have an
algorithm you developed suddenly become numerically unstable when ported to device. We've been
thinking it is better to be explicit.
For most of graphics floats is the "right" choice as it maps directly to OpenGL, is storage-wise efficient
and quality-wise precise enough. Then for the cases where precision is very important, we should
explicitly use double.