tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   149     void perspective();
   149     void perspective();
   150     void flipCoordinates();
   150     void flipCoordinates();
   151 
   151 
   152     void convertGeneric();
   152     void convertGeneric();
   153 
   153 
   154     void extractAxisRotation_data();
   154     void optimize_data();
   155     void extractAxisRotation();
   155     void optimize();
   156 
       
   157     void extractTranslation_data();
       
   158     void extractTranslation();
       
   159 
       
   160     void inferSpecialType_data();
       
   161     void inferSpecialType();
       
   162 
   156 
   163     void columnsAndRows();
   157     void columnsAndRows();
   164 
   158 
   165     void convertQMatrix();
   159     void convertQMatrix();
   166     void convertQTransform();
   160     void convertQTransform();
   513 
   507 
   514     QMatrix2x2 m5;
   508     QMatrix2x2 m5;
   515     m5 = m3;
   509     m5 = m3;
   516     QVERIFY(isSame(m5, uniqueValues2));
   510     QVERIFY(isSame(m5, uniqueValues2));
   517 
   511 
   518     m5.setIdentity();
   512     m5.setToIdentity();
   519     QVERIFY(isIdentity(m5));
   513     QVERIFY(isIdentity(m5));
   520 
   514 
   521     QMatrix2x2 m6(uniqueValues2);
   515     QMatrix2x2 m6(uniqueValues2);
   522     QVERIFY(isSame(m6, uniqueValues2));
   516     QVERIFY(isSame(m6, uniqueValues2));
   523     qreal vals[4];
   517     qreal vals[4];
   524     m6.toValueArray(vals);
   518     m6.copyDataTo(vals);
   525     for (int index = 0; index < 4; ++index)
   519     for (int index = 0; index < 4; ++index)
   526         QCOMPARE(vals[index], uniqueValues2[index]);
   520         QCOMPARE(vals[index], uniqueValues2[index]);
   527 }
   521 }
   528 
   522 
   529 // Test the creation of QMatrix3x3 objects in various ways:
   523 // Test the creation of QMatrix3x3 objects in various ways:
   548 
   542 
   549     QMatrix3x3 m5;
   543     QMatrix3x3 m5;
   550     m5 = m3;
   544     m5 = m3;
   551     QVERIFY(isSame(m5, uniqueValues3));
   545     QVERIFY(isSame(m5, uniqueValues3));
   552 
   546 
   553     m5.setIdentity();
   547     m5.setToIdentity();
   554     QVERIFY(isIdentity(m5));
   548     QVERIFY(isIdentity(m5));
   555 
   549 
   556     QMatrix3x3 m6(uniqueValues3);
   550     QMatrix3x3 m6(uniqueValues3);
   557     QVERIFY(isSame(m6, uniqueValues3));
   551     QVERIFY(isSame(m6, uniqueValues3));
   558     qreal vals[9];
   552     qreal vals[9];
   559     m6.toValueArray(vals);
   553     m6.copyDataTo(vals);
   560     for (int index = 0; index < 9; ++index)
   554     for (int index = 0; index < 9; ++index)
   561         QCOMPARE(vals[index], uniqueValues3[index]);
   555         QCOMPARE(vals[index], uniqueValues3[index]);
   562 }
   556 }
   563 
   557 
   564 // Test the creation of QMatrix4x4 objects in various ways:
   558 // Test the creation of QMatrix4x4 objects in various ways:
   583 
   577 
   584     QMatrix4x4 m5;
   578     QMatrix4x4 m5;
   585     m5 = m3;
   579     m5 = m3;
   586     QVERIFY(isSame(m5, uniqueValues4));
   580     QVERIFY(isSame(m5, uniqueValues4));
   587 
   581 
   588     m5.setIdentity();
   582     m5.setToIdentity();
   589     QVERIFY(isIdentity(m5));
   583     QVERIFY(isIdentity(m5));
   590 
   584 
   591     QMatrix4x4 m6(uniqueValues4);
   585     QMatrix4x4 m6(uniqueValues4);
   592     QVERIFY(isSame(m6, uniqueValues4));
   586     QVERIFY(isSame(m6, uniqueValues4));
   593     qreal vals[16];
   587     qreal vals[16];
   594     m6.toValueArray(vals);
   588     m6.copyDataTo(vals);
   595     for (int index = 0; index < 16; ++index)
   589     for (int index = 0; index < 16; ++index)
   596         QCOMPARE(vals[index], uniqueValues4[index]);
   590         QCOMPARE(vals[index], uniqueValues4[index]);
   597 
   591 
   598     QMatrix4x4 m8
   592     QMatrix4x4 m8
   599         (uniqueValues4[0], uniqueValues4[1], uniqueValues4[2], uniqueValues4[3],
   593         (uniqueValues4[0], uniqueValues4[1], uniqueValues4[2], uniqueValues4[3],
   625 
   619 
   626     QMatrix4x3 m5;
   620     QMatrix4x3 m5;
   627     m5 = m3;
   621     m5 = m3;
   628     QVERIFY(isSame(m5, uniqueValues4x3));
   622     QVERIFY(isSame(m5, uniqueValues4x3));
   629 
   623 
   630     m5.setIdentity();
   624     m5.setToIdentity();
   631     QVERIFY(isIdentity(m5));
   625     QVERIFY(isIdentity(m5));
   632 
   626 
   633     QMatrix4x3 m6(uniqueValues4x3);
   627     QMatrix4x3 m6(uniqueValues4x3);
   634     QVERIFY(isSame(m6, uniqueValues4x3));
   628     QVERIFY(isSame(m6, uniqueValues4x3));
   635     qreal vals[12];
   629     qreal vals[12];
   636     m6.toValueArray(vals);
   630     m6.copyDataTo(vals);
   637     for (int index = 0; index < 12; ++index)
   631     for (int index = 0; index < 12; ++index)
   638         QCOMPARE(vals[index], uniqueValues4x3[index]);
   632         QCOMPARE(vals[index], uniqueValues4x3[index]);
   639 }
   633 }
   640 
   634 
   641 // Test isIdentity() for 2x2 matrices.
   635 // Test isIdentity() for 2x2 matrices.
   800 void tst_QMatrixNxN::transposed4x3()
   794 void tst_QMatrixNxN::transposed4x3()
   801 {
   795 {
   802     QMatrix4x3 m3(uniqueValues4x3);
   796     QMatrix4x3 m3(uniqueValues4x3);
   803     QMatrix3x4 m4 = m3.transposed();
   797     QMatrix3x4 m4 = m3.transposed();
   804     qreal values[12];
   798     qreal values[12];
   805     m4.toValueArray(values);
   799     m4.copyDataTo(values);
   806     for (int index = 0; index < 12; ++index)
   800     for (int index = 0; index < 12; ++index)
   807         QCOMPARE(values[index], transposedValues3x4[index]);
   801         QCOMPARE(values[index], transposedValues3x4[index]);
   808 }
   802 }
   809 
   803 
   810 // Test matrix addition for 2x2 matrices.
   804 // Test matrix addition for 2x2 matrices.
  1294     QMatrix3x4 m2((const qreal *)m2Values);
  1288     QMatrix3x4 m2((const qreal *)m2Values);
  1295 
  1289 
  1296     QGenericMatrix<3, 3, qreal> m4;
  1290     QGenericMatrix<3, 3, qreal> m4;
  1297     m4 = m1 * m2;
  1291     m4 = m1 * m2;
  1298     qreal values[9];
  1292     qreal values[9];
  1299     m4.toValueArray(values);
  1293     m4.copyDataTo(values);
  1300     for (int index = 0; index < 9; ++index)
  1294     for (int index = 0; index < 9; ++index)
  1301         QCOMPARE(values[index], ((const qreal *)m3Values)[index]);
  1295         QCOMPARE(values[index], ((const qreal *)m3Values)[index]);
  1302 }
  1296 }
  1303 
  1297 
  1304 // Test matrix multiplication by a factor for 2x2 matrices.
  1298 // Test matrix multiplication by a factor for 2x2 matrices.
  1896     } else {
  1890     } else {
  1897         QVERIFY(!inv);
  1891         QVERIFY(!inv);
  1898     }
  1892     }
  1899 
  1893 
  1900     // Test again, after inferring the special matrix type.
  1894     // Test again, after inferring the special matrix type.
  1901     m1.inferSpecialType();
  1895     m1.optimize();
  1902     m2 = m1.inverted(&inv);
  1896     m2 = m1.inverted(&inv);
  1903     QVERIFY(isSame(m2, (const qreal *)m2Values));
  1897     QVERIFY(isSame(m2, (const qreal *)m2Values));
  1904     QCOMPARE(inv, invertible);
  1898     QCOMPARE(inv, invertible);
  1905 }
  1899 }
  1906 
  1900 
  1911 
  1905 
  1912     QMatrix4x4 m2;
  1906     QMatrix4x4 m2;
  1913     m2.rotate(45.0, 1.0, 0.0, 0.0);
  1907     m2.rotate(45.0, 1.0, 0.0, 0.0);
  1914     m2.translate(10.0, 0.0, 0.0);
  1908     m2.translate(10.0, 0.0, 0.0);
  1915 
  1909 
  1916     // Use inferSpecialType() to drop the internal flags that
  1910     // Use optimize() to drop the internal flags that
  1917     // mark the matrix as orthonormal.  This will force inverted()
  1911     // mark the matrix as orthonormal.  This will force inverted()
  1918     // to compute m3.inverted() the long way.  We can then compare
  1912     // to compute m3.inverted() the long way.  We can then compare
  1919     // the result to what the faster algorithm produces on m2.
  1913     // the result to what the faster algorithm produces on m2.
  1920     QMatrix4x4 m3 = m2;
  1914     QMatrix4x4 m3 = m2;
  1921     m3.inferSpecialType();
  1915     m3.optimize();
  1922     bool invertible;
  1916     bool invertible;
  1923     QVERIFY(qFuzzyCompare(m2.inverted(&invertible), m3.inverted()));
  1917     QVERIFY(qFuzzyCompare(m2.inverted(&invertible), m3.inverted()));
  1924     QVERIFY(invertible);
  1918     QVERIFY(invertible);
  1925 
  1919 
  1926     QMatrix4x4 m4;
  1920     QMatrix4x4 m4;
  1927     m4.rotate(45.0, 0.0, 1.0, 0.0);
  1921     m4.rotate(45.0, 0.0, 1.0, 0.0);
  1928     QMatrix4x4 m5 = m4;
  1922     QMatrix4x4 m5 = m4;
  1929     m5.inferSpecialType();
  1923     m5.optimize();
  1930     QVERIFY(qFuzzyCompare(m4.inverted(), m5.inverted()));
  1924     QVERIFY(qFuzzyCompare(m4.inverted(), m5.inverted()));
  1931 
  1925 
  1932     QMatrix4x4 m6;
  1926     QMatrix4x4 m6;
  1933     m1.rotate(88, 0.0, 0.0, 1.0);
  1927     m1.rotate(88, 0.0, 0.0, 1.0);
  1934     m1.translate(-20.0, 20.0, 15.0);
  1928     m1.translate(-20.0, 20.0, 15.0);
  1935     m1.rotate(25, 1.0, 0.0, 0.0);
  1929     m1.rotate(25, 1.0, 0.0, 0.0);
  1936     QMatrix4x4 m7 = m6;
  1930     QMatrix4x4 m7 = m6;
  1937     m7.inferSpecialType();
  1931     m7.optimize();
  1938     QVERIFY(qFuzzyCompare(m6.inverted(), m7.inverted()));
  1932     QVERIFY(qFuzzyCompare(m6.inverted(), m7.inverted()));
  1939 }
  1933 }
  1940 
  1934 
  1941 // Test the generation and use of 4x4 scale matrices.
  1935 // Test the generation and use of 4x4 scale matrices.
  1942 void tst_QMatrixNxN::scale4x4_data()
  1936 void tst_QMatrixNxN::scale4x4_data()
  2079         QMatrix4x4 m8;
  2073         QMatrix4x4 m8;
  2080         m8(0, 0) = 1.0f;
  2074         m8(0, 0) = 1.0f;
  2081         m8.scale(x);
  2075         m8.scale(x);
  2082         QVERIFY(isSame(m8, (const qreal *)resultValues));
  2076         QVERIFY(isSame(m8, (const qreal *)resultValues));
  2083 
  2077 
  2084         m8.inferSpecialType();
  2078         m8.optimize();
  2085         m8.scale(1.0f);
  2079         m8.scale(1.0f);
  2086         QVERIFY(isSame(m8, (const qreal *)resultValues));
  2080         QVERIFY(isSame(m8, (const qreal *)resultValues));
  2087 
  2081 
  2088         QMatrix4x4 m9;
  2082         QMatrix4x4 m9;
  2089         m9.translate(0.0f, 0.0f, 0.0f);
  2083         m9.translate(0.0f, 0.0f, 0.0f);
  2410     QVERIFY(fuzzyCompare(p4.x(), p1x));
  2404     QVERIFY(fuzzyCompare(p4.x(), p1x));
  2411     QVERIFY(fuzzyCompare(p4.y(), p1y));
  2405     QVERIFY(fuzzyCompare(p4.y(), p1y));
  2412 
  2406 
  2413     if (x != 0 || y != 0 || z != 0) {
  2407     if (x != 0 || y != 0 || z != 0) {
  2414         QQuaternion q = QQuaternion::fromAxisAndAngle(QVector3D(x, y, z), angle);
  2408         QQuaternion q = QQuaternion::fromAxisAndAngle(QVector3D(x, y, z), angle);
  2415         QVector3D vq = q.rotateVector(v1);
  2409         QVector3D vq = q.rotatedVector(v1);
  2416         QVERIFY(fuzzyCompare(vq.x(), v1x));
  2410         QVERIFY(fuzzyCompare(vq.x(), v1x));
  2417         QVERIFY(fuzzyCompare(vq.y(), v1y));
  2411         QVERIFY(fuzzyCompare(vq.y(), v1y));
  2418         QVERIFY(fuzzyCompare(vq.z(), v1z));
  2412         QVERIFY(fuzzyCompare(vq.z(), v1z));
  2419     }
  2413     }
  2420 }
  2414 }
  2507     else
  2501     else
  2508         QVERIFY(isIdentity(n1));
  2502         QVERIFY(isIdentity(n1));
  2509 
  2503 
  2510     // Perform the test again, after inferring special matrix types.
  2504     // Perform the test again, after inferring special matrix types.
  2511     // This tests the optimized paths in the normalMatrix() function.
  2505     // This tests the optimized paths in the normalMatrix() function.
  2512     m1.inferSpecialType();
  2506     m1.optimize();
  2513     n1 = m1.normalMatrix();
  2507     n1 = m1.normalMatrix();
  2514 
  2508 
  2515     if (invertible)
  2509     if (invertible)
  2516         QVERIFY(::isSame(n1, answer));
  2510         QVERIFY(::isSame(n1, answer));
  2517     else
  2511     else
  2848 
  2842 
  2849     QMatrix4x3 m11 = qGenericMatrixFromMatrix4x4<4, 3>(m9);
  2843     QMatrix4x3 m11 = qGenericMatrixFromMatrix4x4<4, 3>(m9);
  2850     QVERIFY(isSame(m11, conv4x4));
  2844     QVERIFY(isSame(m11, conv4x4));
  2851 }
  2845 }
  2852 
  2846 
  2853 void tst_QMatrixNxN::extractAxisRotation_data()
       
  2854 {
       
  2855     QTest::addColumn<float>("x");
       
  2856     QTest::addColumn<float>("y");
       
  2857     QTest::addColumn<float>("z");
       
  2858     QTest::addColumn<float>("angle");
       
  2859     
       
  2860     QTest::newRow("1, 0, 0, 0 deg") << 1.0f << 0.0f << 0.0f << 0.0f;
       
  2861     QTest::newRow("1, 0, 0, 90 deg") << 1.0f << 0.0f << 0.0f << 90.0f;
       
  2862     QTest::newRow("1, 0, 0, 270 deg") << 1.0f << 0.0f << 0.0f << 270.0f;
       
  2863     QTest::newRow("1, 0, 0, 45 deg") << 1.0f << 0.0f << 0.0f << 45.0f;
       
  2864     QTest::newRow("1, 0, 0, 120 deg") << 1.0f << 0.0f << 0.0f << 120.0f;
       
  2865     QTest::newRow("1, 0, 0, 300 deg") << 1.0f << 0.0f << 0.0f << 300.0f;
       
  2866 
       
  2867     QTest::newRow("0, 1, 0, 90 deg") << 0.0f << 1.0f << 0.0f << 90.0f;
       
  2868     QTest::newRow("0, 1, 0, 270 deg") << 0.0f << 1.0f << 0.0f << 270.0f;
       
  2869     QTest::newRow("0, 1, 0, 45 deg") << 0.0f << 1.0f << 0.0f << 45.0f;
       
  2870     QTest::newRow("0, 1, 0, 120 deg") << 0.0f << 1.0f << 0.0f << 120.0f;
       
  2871     QTest::newRow("0, 1, 0, 300 deg") << 0.0f << 1.0f << 0.0f << 300.0f;
       
  2872     
       
  2873     QTest::newRow("0, 0, 1, 90 deg") << 0.0f << 0.0f << 1.0f << 90.0f;
       
  2874     QTest::newRow("0, 0, 1, 270 deg") << 0.0f << 0.0f << 1.0f << 270.0f;
       
  2875     QTest::newRow("0, 0, 1, 45 deg") << 0.0f << 0.0f << 1.0f << 45.0f;
       
  2876     QTest::newRow("0, 0, 1, 120 deg") << 0.0f << 0.0f << 1.0f << 120.0f;
       
  2877     QTest::newRow("0, 0, 1, 300 deg") << 0.0f << 0.0f << 1.0f << 300.0f;
       
  2878 
       
  2879     QTest::newRow("1, 1, 1, 90 deg") << 1.0f << 1.0f << 1.0f << 90.0f;
       
  2880     QTest::newRow("1, 1, 1, 270 deg") << 1.0f << 1.0f << 1.0f << 270.0f;
       
  2881     QTest::newRow("1, 1, 1, 45 deg") << 1.0f << 1.0f << 1.0f << 45.0f;
       
  2882     QTest::newRow("1, 1, 1, 120 deg") << 1.0f << 1.0f << 1.0f << 120.0f;
       
  2883     QTest::newRow("1, 1, 1, 300 deg") << 1.0f << 1.0f << 1.0f << 300.0f;
       
  2884 }
       
  2885 
       
  2886 void tst_QMatrixNxN::extractAxisRotation()
       
  2887 {
       
  2888     QFETCH(float, x);
       
  2889     QFETCH(float, y);
       
  2890     QFETCH(float, z);
       
  2891     QFETCH(float, angle);
       
  2892 
       
  2893     QMatrix4x4 m;
       
  2894     QVector3D origAxis(x, y, z);
       
  2895 
       
  2896     m.rotate(angle, x, y, z);
       
  2897 
       
  2898     origAxis.normalize();
       
  2899     QVector3D extractedAxis;
       
  2900     qreal extractedAngle;
       
  2901 
       
  2902     m.extractAxisRotation(extractedAngle, extractedAxis);
       
  2903  
       
  2904     if (angle > 180) {
       
  2905         QVERIFY(fuzzyCompare(360.0f - angle, extractedAngle));
       
  2906         QVERIFY(fuzzyCompare(extractedAxis, -origAxis));
       
  2907     } else {
       
  2908         QVERIFY(fuzzyCompare(angle, extractedAngle));
       
  2909         QVERIFY(fuzzyCompare(extractedAxis, origAxis));
       
  2910     }
       
  2911 }
       
  2912 
       
  2913 void tst_QMatrixNxN::extractTranslation_data()
       
  2914 {
       
  2915     QTest::addColumn<QMatrix4x4>("rotation");
       
  2916     QTest::addColumn<float>("x");
       
  2917     QTest::addColumn<float>("y");
       
  2918     QTest::addColumn<float>("z");
       
  2919 
       
  2920     static QMatrix4x4 m1;
       
  2921 
       
  2922     QTest::newRow("identity, 100, 50, 25")
       
  2923         << m1 << 100.0f << 50.0f << 250.0f;
       
  2924 
       
  2925     m1.rotate(45.0, 1.0, 0.0, 0.0);
       
  2926     QTest::newRow("rotX 45 + 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f;
       
  2927 
       
  2928     m1.setIdentity();
       
  2929     m1.rotate(45.0, 0.0, 1.0, 0.0);
       
  2930     QTest::newRow("rotY 45 + 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f;
       
  2931 
       
  2932     m1.setIdentity();
       
  2933     m1.rotate(75, 0.0, 0.0, 1.0);
       
  2934     m1.rotate(25, 1.0, 0.0, 0.0);
       
  2935     m1.rotate(45, 0.0, 1.0, 0.0);
       
  2936     QTest::newRow("rotZ 75, rotX 25, rotY 45, 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f;
       
  2937 }
       
  2938 
       
  2939 void tst_QMatrixNxN::extractTranslation()
       
  2940 {
       
  2941     QFETCH(QMatrix4x4, rotation);
       
  2942     QFETCH(float, x);
       
  2943     QFETCH(float, y);
       
  2944     QFETCH(float, z);
       
  2945 
       
  2946     rotation.translate(x, y, z);
       
  2947 
       
  2948     QVector3D vec = rotation.extractTranslation();
       
  2949 
       
  2950     QVERIFY(fuzzyCompare(vec.x(), x));
       
  2951     QVERIFY(fuzzyCompare(vec.y(), y));
       
  2952     QVERIFY(fuzzyCompare(vec.z(), z));
       
  2953 
       
  2954     QMatrix4x4 lookAt;
       
  2955     QVector3D eye(1.5f, -2.5f, 2.5f);
       
  2956     lookAt.lookAt(eye,
       
  2957                   QVector3D(10.0f, 10.0f, 10.0f), 
       
  2958                   QVector3D(0.0f, 1.0f, 0.0f));
       
  2959 
       
  2960    QVector3D extEye = lookAt.extractTranslation();
       
  2961 
       
  2962    QVERIFY(fuzzyCompare(eye.x(), -extEye.x()));
       
  2963    QVERIFY(fuzzyCompare(eye.y(), -extEye.y()));
       
  2964    QVERIFY(fuzzyCompare(eye.z(), -extEye.z()));
       
  2965 }
       
  2966 
       
  2967 // Copy of "flagBits" in qmatrix4x4.h.
  2847 // Copy of "flagBits" in qmatrix4x4.h.
  2968 enum {
  2848 enum {
  2969     Identity        = 0x0001,   // Identity matrix
  2849     Identity        = 0x0001,   // Identity matrix
  2970     General         = 0x0002,   // General matrix, unknown contents
  2850     General         = 0x0002,   // General matrix, unknown contents
  2971     Translation     = 0x0004,   // Contains a simple translation
  2851     Translation     = 0x0004,   // Contains a simple translation
  2979     qreal m[4][4];
  2859     qreal m[4][4];
  2980     int flagBits;
  2860     int flagBits;
  2981 };
  2861 };
  2982 
  2862 
  2983 // Test the inferring of special matrix types.
  2863 // Test the inferring of special matrix types.
  2984 void tst_QMatrixNxN::inferSpecialType_data()
  2864 void tst_QMatrixNxN::optimize_data()
  2985 {
  2865 {
  2986     QTest::addColumn<void *>("mValues");
  2866     QTest::addColumn<void *>("mValues");
  2987     QTest::addColumn<int>("flagBits");
  2867     QTest::addColumn<int>("flagBits");
  2988 
  2868 
  2989     QTest::newRow("null")
  2869     QTest::newRow("null")
  3027         4.0f, 0.0f, 0.0f, 1.0f
  2907         4.0f, 0.0f, 0.0f, 1.0f
  3028     };
  2908     };
  3029     QTest::newRow("below")
  2909     QTest::newRow("below")
  3030         << (void *)belowValues << (int)General;
  2910         << (void *)belowValues << (int)General;
  3031 }
  2911 }
  3032 void tst_QMatrixNxN::inferSpecialType()
  2912 void tst_QMatrixNxN::optimize()
  3033 {
  2913 {
  3034     QFETCH(void *, mValues);
  2914     QFETCH(void *, mValues);
  3035     QFETCH(int, flagBits);
  2915     QFETCH(int, flagBits);
  3036 
  2916 
  3037     QMatrix4x4 m((const qreal *)mValues);
  2917     QMatrix4x4 m((const qreal *)mValues);
  3038     m.inferSpecialType();
  2918     m.optimize();
  3039 
  2919 
  3040     QCOMPARE(reinterpret_cast<Matrix4x4 *>(&m)->flagBits, flagBits);
  2920     QCOMPARE(reinterpret_cast<Matrix4x4 *>(&m)->flagBits, flagBits);
  3041 }
  2921 }
  3042 
  2922 
  3043 void tst_QMatrixNxN::columnsAndRows()
  2923 void tst_QMatrixNxN::columnsAndRows()
  3360 void tst_QMatrixNxN::mapVector()
  3240 void tst_QMatrixNxN::mapVector()
  3361 {
  3241 {
  3362     QFETCH(void *, mValues);
  3242     QFETCH(void *, mValues);
  3363 
  3243 
  3364     QMatrix4x4 m1((const qreal *)mValues);
  3244     QMatrix4x4 m1((const qreal *)mValues);
  3365     m1.inferSpecialType();
  3245     m1.optimize();
  3366 
  3246 
  3367     QVector3D v(3.5f, -1.0f, 2.5f);
  3247     QVector3D v(3.5f, -1.0f, 2.5f);
  3368 
  3248 
  3369     QVector3D expected
  3249     QVector3D expected
  3370         (v.x() * m1(0, 0) + v.y() * m1(0, 1) + v.z() * m1(0, 2),
  3250         (v.x() * m1(0, 0) + v.y() * m1(0, 1) + v.z() * m1(0, 2),