Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-8211

QVector2D, QVector3D and QVector4D have a qreal interface, but store as float internally

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 4.6.0
    • Qt3D
    • None
    • Only on platforms where qreal != float

    Description

      QVector2D, QVector3D and QVector4D classes all have qreal accessors, constructors and mutators but store the data as floats. This has has important repercussion as it means that this code will fail:

      qreal val = double(std::rand())/double(RAND_MAX);
      QVector3D vec(val,val,val);
      QCOMPARE(vec.getX(), val); // MIGHT FAIL!
      QCOMPARE(vec.getY(), val); // MIGHT FAIL!
      QCOMPARE(vec.getZ(), val); // MIGHT FAIL!

      This also causes problems for us as we need values to be stored as doubles. And they are not. I suspect that the argument for storing floats internally is because OpenGL uses floats, but QVectorXD are NOT part of QtOpenGL but are part of qtGui and therefore should not be OpenGL specific. In addition, QQuaternions do use qreal as storage.

      Should floats be needed for OpenGL, conversion should be done as late as possible.

      Thanks and keep up the good work!
      J-O

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              rweather Rhys Weatherley (closed Nokia identity) (Inactive)
              sirmont Jean-Olivier Racine
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes