qmatrix4x4.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/math3d/qmatrix4x4.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4static const float inv_dist_to_plane = 1.0f / 1024.0f;-
5QMatrix4x4::QMatrix4x4(const float *values)-
6{-
7 for (int row = 0; row < 4
row < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++row)
0
8 for (int col = 0; col < 4
col < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++col)
0
9 m[col][row] = values[row * 4 + col];
never executed: m[col][row] = values[row * 4 + col];
0
10 flagBits = General;-
11}
never executed: end of block
0
12QMatrix4x4::QMatrix4x4(const float *values, int cols, int rows)-
13{-
14 for (int col = 0; col < 4
col < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++col) {
0
15 for (int row = 0; row < 4
row < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++row) {
0
16 if (col < cols
col < colsDescription
TRUEnever evaluated
FALSEnever evaluated
&& row < rows
row < rowsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
17 m[col][row] = values[col * rows + row];
never executed: m[col][row] = values[col * rows + row];
0
18 else if (col == row
col == rowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
19 m[col][row] = 1.0f;
never executed: m[col][row] = 1.0f;
0
20 else-
21 m[col][row] = 0.0f;
never executed: m[col][row] = 0.0f;
0
22 }-
23 }
never executed: end of block
0
24 flagBits = General;-
25}
never executed: end of block
0
26QMatrix4x4::QMatrix4x4(const QMatrix& matrix)-
27{-
28 m[0][0] = matrix.m11();-
29 m[0][1] = matrix.m12();-
30 m[0][2] = 0.0f;-
31 m[0][3] = 0.0f;-
32 m[1][0] = matrix.m21();-
33 m[1][1] = matrix.m22();-
34 m[1][2] = 0.0f;-
35 m[1][3] = 0.0f;-
36 m[2][0] = 0.0f;-
37 m[2][1] = 0.0f;-
38 m[2][2] = 1.0f;-
39 m[2][3] = 0.0f;-
40 m[3][0] = matrix.dx();-
41 m[3][1] = matrix.dy();-
42 m[3][2] = 0.0f;-
43 m[3][3] = 1.0f;-
44 flagBits = Translation | Scale | Rotation2D;-
45}
never executed: end of block
0
46QMatrix4x4::QMatrix4x4(const QTransform& transform)-
47{-
48 m[0][0] = transform.m11();-
49 m[0][1] = transform.m12();-
50 m[0][2] = 0.0f;-
51 m[0][3] = transform.m13();-
52 m[1][0] = transform.m21();-
53 m[1][1] = transform.m22();-
54 m[1][2] = 0.0f;-
55 m[1][3] = transform.m23();-
56 m[2][0] = 0.0f;-
57 m[2][1] = 0.0f;-
58 m[2][2] = 1.0f;-
59 m[2][3] = 0.0f;-
60 m[3][0] = transform.dx();-
61 m[3][1] = transform.dy();-
62 m[3][2] = 0.0f;-
63 m[3][3] = transform.m33();-
64 flagBits = General;-
65}
never executed: end of block
0
66static inline double matrixDet2(const double m[4][4], int col0, int col1, int row0, int row1)-
67{-
68 return
never executed: return m[col0][row0] * m[col1][row1] - m[col0][row1] * m[col1][row0];
m[col0][row0] * m[col1][row1] - m[col0][row1] * m[col1][row0];
never executed: return m[col0][row0] * m[col1][row1] - m[col0][row1] * m[col1][row0];
0
69}-
70static inline double matrixDet3-
71 (const double m[4][4], int col0, int col1, int col2,-
72 int row0, int row1, int row2)-
73{-
74 return
never executed: return m[col0][row0] * matrixDet2(m, col1, col2, row1, row2) - m[col1][row0] * matrixDet2(m, col0, col2, row1, row2) + m[col2][row0] * matrixDet2(m, col0, col1, row1, row2);
m[col0][row0] * matrixDet2(m, col1, col2, row1, row2)
never executed: return m[col0][row0] * matrixDet2(m, col1, col2, row1, row2) - m[col1][row0] * matrixDet2(m, col0, col2, row1, row2) + m[col2][row0] * matrixDet2(m, col0, col1, row1, row2);
0
75 - m[col1][row0] * matrixDet2(m, col0, col2, row1, row2)
never executed: return m[col0][row0] * matrixDet2(m, col1, col2, row1, row2) - m[col1][row0] * matrixDet2(m, col0, col2, row1, row2) + m[col2][row0] * matrixDet2(m, col0, col1, row1, row2);
0
76 + m[col2][row0] * matrixDet2(m, col0, col1, row1, row2);
never executed: return m[col0][row0] * matrixDet2(m, col1, col2, row1, row2) - m[col1][row0] * matrixDet2(m, col0, col2, row1, row2) + m[col2][row0] * matrixDet2(m, col0, col1, row1, row2);
0
77}-
78-
79-
80static inline double matrixDet4(const double m[4][4])-
81{-
82 double det;-
83 det = m[0][0] * matrixDet3(m, 1, 2, 3, 1, 2, 3);-
84 det -= m[1][0] * matrixDet3(m, 0, 2, 3, 1, 2, 3);-
85 det += m[2][0] * matrixDet3(m, 0, 1, 3, 1, 2, 3);-
86 det -= m[3][0] * matrixDet3(m, 0, 1, 2, 1, 2, 3);-
87 return
never executed: return det;
det;
never executed: return det;
0
88}-
89-
90static inline void copyToDoubles(const float m[4][4], double mm[4][4])-
91{-
92 for (int i = 0; i < 4
i < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
93 for (int j = 0; j < 4
j < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++j)
0
94 mm[i][j] = double(m[i][j]);
never executed: mm[i][j] = double(m[i][j]);
0
95}
never executed: end of block
0
96-
97-
98-
99-
100double QMatrix4x4::determinant() const-
101{-
102 if ((
(flagBits & ~(...)) == IdentityDescription
TRUEnever evaluated
FALSEnever evaluated
flagBits & ~(Translation | Rotation2D | Rotation)) == Identity
(flagBits & ~(...)) == IdentityDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
103 return
never executed: return 1.0;
1.0;
never executed: return 1.0;
0
104-
105 double mm[4][4];-
106 copyToDoubles(m, mm);-
107 if (flagBits < Rotation2D
flagBits < Rotation2DDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
108 return
never executed: return mm[0][0] * mm[1][1] * mm[2][2];
mm[0][0] * mm[1][1] * mm[2][2];
never executed: return mm[0][0] * mm[1][1] * mm[2][2];
0
109 if (flagBits < Perspective
flagBits < PerspectiveDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
110 return
never executed: return matrixDet3(mm, 0, 1, 2, 0, 1, 2);
matrixDet3(mm, 0, 1, 2, 0, 1, 2);
never executed: return matrixDet3(mm, 0, 1, 2, 0, 1, 2);
0
111 return
never executed: return matrixDet4(mm);
matrixDet4(mm);
never executed: return matrixDet4(mm);
0
112}-
113QMatrix4x4 QMatrix4x4::inverted(bool *invertible) const-
114{-
115-
116 if (flagBits == Identity
flagBits == IdentityDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
117 if (invertible
invertibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
118 *
never executed: *invertible = true;
invertible = true;
never executed: *invertible = true;
0
119 return
never executed: return QMatrix4x4();
QMatrix4x4();
never executed: return QMatrix4x4();
0
120 } else if (flagBits == Translation
flagBits == TranslationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
121 QMatrix4x4 inv;-
122 inv.m[3][0] = -m[3][0];-
123 inv.m[3][1] = -m[3][1];-
124 inv.m[3][2] = -m[3][2];-
125 inv.flagBits = Translation;-
126 if (invertible
invertibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
127 *
never executed: *invertible = true;
invertible = true;
never executed: *invertible = true;
0
128 return
never executed: return inv;
inv;
never executed: return inv;
0
129 } else if (flagBits < Rotation2D
flagBits < Rotation2DDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
130-
131 if (m[0][0] == 0
m[0][0] == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| m[1][1] == 0
m[1][1] == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| m[2][2] == 0
m[2][2] == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
132 if (invertible
invertibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
133 *
never executed: *invertible = false;
invertible = false;
never executed: *invertible = false;
0
134 return
never executed: return QMatrix4x4();
QMatrix4x4();
never executed: return QMatrix4x4();
0
135 }-
136 QMatrix4x4 inv;-
137 inv.m[0][0] = 1.0f / m[0][0];-
138 inv.m[1][1] = 1.0f / m[1][1];-
139 inv.m[2][2] = 1.0f / m[2][2];-
140 inv.m[3][0] = -m[3][0] * inv.m[0][0];-
141 inv.m[3][1] = -m[3][1] * inv.m[1][1];-
142 inv.m[3][2] = -m[3][2] * inv.m[2][2];-
143 inv.flagBits = flagBits;-
144-
145 if (invertible
invertibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
146 *
never executed: *invertible = true;
invertible = true;
never executed: *invertible = true;
0
147 return
never executed: return inv;
inv;
never executed: return inv;
0
148 } else if ((
(flagBits & ~(...)) == IdentityDescription
TRUEnever evaluated
FALSEnever evaluated
flagBits & ~(Translation | Rotation2D | Rotation)) == Identity
(flagBits & ~(...)) == IdentityDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
149 if (invertible
invertibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
150 *
never executed: *invertible = true;
invertible = true;
never executed: *invertible = true;
0
151 return
never executed: return orthonormalInverse();
orthonormalInverse();
never executed: return orthonormalInverse();
0
152 } else if (flagBits < Perspective
flagBits < PerspectiveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
153 QMatrix4x4 inv(1);-
154-
155 double mm[4][4];-
156 copyToDoubles(m, mm);-
157-
158 double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2);-
159 if (det == 0.0f
det == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
160 if (invertible
invertibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
161 *
never executed: *invertible = false;
invertible = false;
never executed: *invertible = false;
0
162 return
never executed: return QMatrix4x4();
QMatrix4x4();
never executed: return QMatrix4x4();
0
163 }-
164 det = 1.0f / det;-
165-
166 inv.m[0][0] = matrixDet2(mm, 1, 2, 1, 2) * det;-
167 inv.m[0][1] = -matrixDet2(mm, 0, 2, 1, 2) * det;-
168 inv.m[0][2] = matrixDet2(mm, 0, 1, 1, 2) * det;-
169 inv.m[0][3] = 0;-
170 inv.m[1][0] = -matrixDet2(mm, 1, 2, 0, 2) * det;-
171 inv.m[1][1] = matrixDet2(mm, 0, 2, 0, 2) * det;-
172 inv.m[1][2] = -matrixDet2(mm, 0, 1, 0, 2) * det;-
173 inv.m[1][3] = 0;-
174 inv.m[2][0] = matrixDet2(mm, 1, 2, 0, 1) * det;-
175 inv.m[2][1] = -matrixDet2(mm, 0, 2, 0, 1) * det;-
176 inv.m[2][2] = matrixDet2(mm, 0, 1, 0, 1) * det;-
177 inv.m[2][3] = 0;-
178 inv.m[3][0] = -inv.m[0][0] * m[3][0] - inv.m[1][0] * m[3][1] - inv.m[2][0] * m[3][2];-
179 inv.m[3][1] = -inv.m[0][1] * m[3][0] - inv.m[1][1] * m[3][1] - inv.m[2][1] * m[3][2];-
180 inv.m[3][2] = -inv.m[0][2] * m[3][0] - inv.m[1][2] * m[3][1] - inv.m[2][2] * m[3][2];-
181 inv.m[3][3] = 1;-
182 inv.flagBits = flagBits;-
183-
184 if (invertible
invertibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
185 *
never executed: *invertible = true;
invertible = true;
never executed: *invertible = true;
0
186 return
never executed: return inv;
inv;
never executed: return inv;
0
187 }-
188-
189 QMatrix4x4 inv(1);-
190-
191 double mm[4][4];-
192 copyToDoubles(m, mm);-
193-
194 double det = matrixDet4(mm);-
195 if (det == 0.0f
det == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
196 if (invertible
invertibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
197 *
never executed: *invertible = false;
invertible = false;
never executed: *invertible = false;
0
198 return
never executed: return QMatrix4x4();
QMatrix4x4();
never executed: return QMatrix4x4();
0
199 }-
200 det = 1.0f / det;-
201-
202 inv.m[0][0] = matrixDet3(mm, 1, 2, 3, 1, 2, 3) * det;-
203 inv.m[0][1] = -matrixDet3(mm, 0, 2, 3, 1, 2, 3) * det;-
204 inv.m[0][2] = matrixDet3(mm, 0, 1, 3, 1, 2, 3) * det;-
205 inv.m[0][3] = -matrixDet3(mm, 0, 1, 2, 1, 2, 3) * det;-
206 inv.m[1][0] = -matrixDet3(mm, 1, 2, 3, 0, 2, 3) * det;-
207 inv.m[1][1] = matrixDet3(mm, 0, 2, 3, 0, 2, 3) * det;-
208 inv.m[1][2] = -matrixDet3(mm, 0, 1, 3, 0, 2, 3) * det;-
209 inv.m[1][3] = matrixDet3(mm, 0, 1, 2, 0, 2, 3) * det;-
210 inv.m[2][0] = matrixDet3(mm, 1, 2, 3, 0, 1, 3) * det;-
211 inv.m[2][1] = -matrixDet3(mm, 0, 2, 3, 0, 1, 3) * det;-
212 inv.m[2][2] = matrixDet3(mm, 0, 1, 3, 0, 1, 3) * det;-
213 inv.m[2][3] = -matrixDet3(mm, 0, 1, 2, 0, 1, 3) * det;-
214 inv.m[3][0] = -matrixDet3(mm, 1, 2, 3, 0, 1, 2) * det;-
215 inv.m[3][1] = matrixDet3(mm, 0, 2, 3, 0, 1, 2) * det;-
216 inv.m[3][2] = -matrixDet3(mm, 0, 1, 3, 0, 1, 2) * det;-
217 inv.m[3][3] = matrixDet3(mm, 0, 1, 2, 0, 1, 2) * det;-
218 inv.flagBits = flagBits;-
219-
220 if (invertible
invertibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
221 *
never executed: *invertible = true;
invertible = true;
never executed: *invertible = true;
0
222 return
never executed: return inv;
inv;
never executed: return inv;
0
223}-
224QMatrix3x3 QMatrix4x4::normalMatrix() const-
225{-
226 QMatrix3x3 inv;-
227-
228-
229 if (flagBits < Scale
flagBits < ScaleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
230-
231 return
never executed: return inv;
inv;
never executed: return inv;
0
232 } else if (flagBits < Rotation2D
flagBits < Rotation2DDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
233-
234 if (m[0][0] == 0.0f
m[0][0] == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
|| m[1][1] == 0.0f
m[1][1] == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
|| m[2][2] == 0.0f
m[2][2] == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
235 return
never executed: return inv;
inv;
never executed: return inv;
0
236 inv.data()[0] = 1.0f / m[0][0];-
237 inv.data()[4] = 1.0f / m[1][1];-
238 inv.data()[8] = 1.0f / m[2][2];-
239 return
never executed: return inv;
inv;
never executed: return inv;
0
240 } else if ((
(flagBits & ~(...)) == IdentityDescription
TRUEnever evaluated
FALSEnever evaluated
flagBits & ~(Translation | Rotation2D | Rotation)) == Identity
(flagBits & ~(...)) == IdentityDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
241 float *invm = inv.data();-
242 invm[0 + 0 * 3] = m[0][0];-
243 invm[1 + 0 * 3] = m[0][1];-
244 invm[2 + 0 * 3] = m[0][2];-
245 invm[0 + 1 * 3] = m[1][0];-
246 invm[1 + 1 * 3] = m[1][1];-
247 invm[2 + 1 * 3] = m[1][2];-
248 invm[0 + 2 * 3] = m[2][0];-
249 invm[1 + 2 * 3] = m[2][1];-
250 invm[2 + 2 * 3] = m[2][2];-
251 return
never executed: return inv;
inv;
never executed: return inv;
0
252 }-
253-
254 double mm[4][4];-
255 copyToDoubles(m, mm);-
256 double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2);-
257 if (det == 0.0f
det == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
258 return
never executed: return inv;
inv;
never executed: return inv;
0
259 det = 1.0f / det;-
260-
261 float *invm = inv.data();-
262-
263-
264 invm[0 + 0 * 3] = (mm[1][1] * mm[2][2] - mm[2][1] * mm[1][2]) * det;-
265 invm[1 + 0 * 3] = -(mm[1][0] * mm[2][2] - mm[1][2] * mm[2][0]) * det;-
266 invm[2 + 0 * 3] = (mm[1][0] * mm[2][1] - mm[1][1] * mm[2][0]) * det;-
267 invm[0 + 1 * 3] = -(mm[0][1] * mm[2][2] - mm[2][1] * mm[0][2]) * det;-
268 invm[1 + 1 * 3] = (mm[0][0] * mm[2][2] - mm[0][2] * mm[2][0]) * det;-
269 invm[2 + 1 * 3] = -(mm[0][0] * mm[2][1] - mm[0][1] * mm[2][0]) * det;-
270 invm[0 + 2 * 3] = (mm[0][1] * mm[1][2] - mm[0][2] * mm[1][1]) * det;-
271 invm[1 + 2 * 3] = -(mm[0][0] * mm[1][2] - mm[0][2] * mm[1][0]) * det;-
272 invm[2 + 2 * 3] = (mm[0][0] * mm[1][1] - mm[1][0] * mm[0][1]) * det;-
273-
274 return
never executed: return inv;
inv;
never executed: return inv;
0
275}-
276-
277-
278-
279-
280QMatrix4x4 QMatrix4x4::transposed() const-
281{-
282 QMatrix4x4 result(1);-
283 for (int row = 0; row < 4
row < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++row) {
0
284 for (int col = 0; col < 4
col < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++col) {
0
285 result.m[col][row] = m[row][col];-
286 }
never executed: end of block
0
287 }
never executed: end of block
0
288-
289 result.flagBits = (flagBits & Translation
flagBits & TranslationDescription
TRUEnever evaluated
FALSEnever evaluated
? General : flagBits);
0
290 return
never executed: return result;
result;
never executed: return result;
0
291}-
292QMatrix4x4& QMatrix4x4::operator/=(float divisor)-
293{-
294 m[0][0] /= divisor;-
295 m[0][1] /= divisor;-
296 m[0][2] /= divisor;-
297 m[0][3] /= divisor;-
298 m[1][0] /= divisor;-
299 m[1][1] /= divisor;-
300 m[1][2] /= divisor;-
301 m[1][3] /= divisor;-
302 m[2][0] /= divisor;-
303 m[2][1] /= divisor;-
304 m[2][2] /= divisor;-
305 m[2][3] /= divisor;-
306 m[3][0] /= divisor;-
307 m[3][1] /= divisor;-
308 m[3][2] /= divisor;-
309 m[3][3] /= divisor;-
310 flagBits = General;-
311 return
never executed: return *this;
*this;
never executed: return *this;
0
312}-
313QMatrix4x4 operator/(const QMatrix4x4& matrix, float divisor)-
314{-
315 QMatrix4x4 m(1);-
316 m.m[0][0] = matrix.m[0][0] / divisor;-
317 m.m[0][1] = matrix.m[0][1] / divisor;-
318 m.m[0][2] = matrix.m[0][2] / divisor;-
319 m.m[0][3] = matrix.m[0][3] / divisor;-
320 m.m[1][0] = matrix.m[1][0] / divisor;-
321 m.m[1][1] = matrix.m[1][1] / divisor;-
322 m.m[1][2] = matrix.m[1][2] / divisor;-
323 m.m[1][3] = matrix.m[1][3] / divisor;-
324 m.m[2][0] = matrix.m[2][0] / divisor;-
325 m.m[2][1] = matrix.m[2][1] / divisor;-
326 m.m[2][2] = matrix.m[2][2] / divisor;-
327 m.m[2][3] = matrix.m[2][3] / divisor;-
328 m.m[3][0] = matrix.m[3][0] / divisor;-
329 m.m[3][1] = matrix.m[3][1] / divisor;-
330 m.m[3][2] = matrix.m[3][2] / divisor;-
331 m.m[3][3] = matrix.m[3][3] / divisor;-
332 m.flagBits = QMatrix4x4::General;-
333 return
never executed: return m;
m;
never executed: return m;
0
334}-
335void QMatrix4x4::scale(const QVector3D& vector)-
336{-
337 float vx = vector.x();-
338 float vy = vector.y();-
339 float vz = vector.z();-
340 if (flagBits < Scale
flagBits < ScaleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
341 m[0][0] = vx;-
342 m[1][1] = vy;-
343 m[2][2] = vz;-
344 }
never executed: end of block
else if (flagBits < Rotation2D
flagBits < Rotation2DDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
345 m[0][0] *= vx;-
346 m[1][1] *= vy;-
347 m[2][2] *= vz;-
348 }
never executed: end of block
else if (flagBits < Rotation
flagBits < RotationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
349 m[0][0] *= vx;-
350 m[0][1] *= vx;-
351 m[1][0] *= vy;-
352 m[1][1] *= vy;-
353 m[2][2] *= vz;-
354 }
never executed: end of block
else {
0
355 m[0][0] *= vx;-
356 m[0][1] *= vx;-
357 m[0][2] *= vx;-
358 m[0][3] *= vx;-
359 m[1][0] *= vy;-
360 m[1][1] *= vy;-
361 m[1][2] *= vy;-
362 m[1][3] *= vy;-
363 m[2][0] *= vz;-
364 m[2][1] *= vz;-
365 m[2][2] *= vz;-
366 m[2][3] *= vz;-
367 }
never executed: end of block
0
368 flagBits |= Scale;-
369}
never executed: end of block
0
370void QMatrix4x4::scale(float x, float y)-
371{-
372 if (flagBits < Scale
flagBits < ScaleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
373 m[0][0] = x;-
374 m[1][1] = y;-
375 }
never executed: end of block
else if (flagBits < Rotation2D
flagBits < Rotation2DDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
376 m[0][0] *= x;-
377 m[1][1] *= y;-
378 }
never executed: end of block
else if (flagBits < Rotation
flagBits < RotationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
379 m[0][0] *= x;-
380 m[0][1] *= x;-
381 m[1][0] *= y;-
382 m[1][1] *= y;-
383 }
never executed: end of block
else {
0
384 m[0][0] *= x;-
385 m[0][1] *= x;-
386 m[0][2] *= x;-
387 m[0][3] *= x;-
388 m[1][0] *= y;-
389 m[1][1] *= y;-
390 m[1][2] *= y;-
391 m[1][3] *= y;-
392 }
never executed: end of block
0
393 flagBits |= Scale;-
394}
never executed: end of block
0
395void QMatrix4x4::scale(float x, float y, float z)-
396{-
397 if (flagBits < Scale
flagBits < ScaleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
398 m[0][0] = x;-
399 m[1][1] = y;-
400 m[2][2] = z;-
401 }
never executed: end of block
else if (flagBits < Rotation2D
flagBits < Rotation2DDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
402 m[0][0] *= x;-
403 m[1][1] *= y;-
404 m[2][2] *= z;-
405 }
never executed: end of block
else if (flagBits < Rotation
flagBits < RotationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
406 m[0][0] *= x;-
407 m[0][1] *= x;-
408 m[1][0] *= y;-
409 m[1][1] *= y;-
410 m[2][2] *= z;-
411 }
never executed: end of block
else {
0
412 m[0][0] *= x;-
413 m[0][1] *= x;-
414 m[0][2] *= x;-
415 m[0][3] *= x;-
416 m[1][0] *= y;-
417 m[1][1] *= y;-
418 m[1][2] *= y;-
419 m[1][3] *= y;-
420 m[2][0] *= z;-
421 m[2][1] *= z;-
422 m[2][2] *= z;-
423 m[2][3] *= z;-
424 }
never executed: end of block
0
425 flagBits |= Scale;-
426}
never executed: end of block
0
427void QMatrix4x4::scale(float factor)-
428{-
429 if (flagBits < Scale
flagBits < ScaleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
430 m[0][0] = factor;-
431 m[1][1] = factor;-
432 m[2][2] = factor;-
433 }
never executed: end of block
else if (flagBits < Rotation2D
flagBits < Rotation2DDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
434 m[0][0] *= factor;-
435 m[1][1] *= factor;-
436 m[2][2] *= factor;-
437 }
never executed: end of block
else if (flagBits < Rotation
flagBits < RotationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
438 m[0][0] *= factor;-
439 m[0][1] *= factor;-
440 m[1][0] *= factor;-
441 m[1][1] *= factor;-
442 m[2][2] *= factor;-
443 }
never executed: end of block
else {
0
444 m[0][0] *= factor;-
445 m[0][1] *= factor;-
446 m[0][2] *= factor;-
447 m[0][3] *= factor;-
448 m[1][0] *= factor;-
449 m[1][1] *= factor;-
450 m[1][2] *= factor;-
451 m[1][3] *= factor;-
452 m[2][0] *= factor;-
453 m[2][1] *= factor;-
454 m[2][2] *= factor;-
455 m[2][3] *= factor;-
456 }
never executed: end of block
0
457 flagBits |= Scale;-
458}
never executed: end of block
0
459void QMatrix4x4::translate(const QVector3D& vector)-
460{-
461 float vx = vector.x();-
462 float vy = vector.y();-
463 float vz = vector.z();-
464 if (flagBits == Identity
flagBits == IdentityDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
465 m[3][0] = vx;-
466 m[3][1] = vy;-
467 m[3][2] = vz;-
468 }
never executed: end of block
else if (flagBits == Translation
flagBits == TranslationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
469 m[3][0] += vx;-
470 m[3][1] += vy;-
471 m[3][2] += vz;-
472 }
never executed: end of block
else if (flagBits == Scale
flagBits == ScaleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
473 m[3][0] = m[0][0] * vx;-
474 m[3][1] = m[1][1] * vy;-
475 m[3][2] = m[2][2] * vz;-
476 }
never executed: end of block
else if (flagBits == (Translation | Scale)
flagBits == (T...ation | Scale)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
477 m[3][0] += m[0][0] * vx;-
478 m[3][1] += m[1][1] * vy;-
479 m[3][2] += m[2][2] * vz;-
480 }
never executed: end of block
else if (flagBits < Rotation
flagBits < RotationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
481 m[3][0] += m[0][0] * vx + m[1][0] * vy;-
482 m[3][1] += m[0][1] * vx + m[1][1] * vy;-
483 m[3][2] += m[2][2] * vz;-
484 }
never executed: end of block
else {
0
485 m[3][0] += m[0][0] * vx + m[1][0] * vy + m[2][0] * vz;-
486 m[3][1] += m[0][1] * vx + m[1][1] * vy + m[2][1] * vz;-
487 m[3][2] += m[0][2] * vx + m[1][2] * vy + m[2][2] * vz;-
488 m[3][3] += m[0][3] * vx + m[1][3] * vy + m[2][3] * vz;-
489 }
never executed: end of block
0
490 flagBits |= Translation;-
491}
never executed: end of block
0
492void QMatrix4x4::translate(float x, float y)-
493{-
494 if (flagBits == Identity
flagBits == IdentityDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
495 m[3][0] = x;-
496 m[3][1] = y;-
497 }
never executed: end of block
else if (flagBits == Translation
flagBits == TranslationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
498 m[3][0] += x;-
499 m[3][1] += y;-
500 }
never executed: end of block
else if (flagBits == Scale
flagBits == ScaleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
501 m[3][0] = m[0][0] * x;-
502 m[3][1] = m[1][1] * y;-
503 }
never executed: end of block
else if (flagBits == (Translation | Scale)
flagBits == (T...ation | Scale)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
504 m[3][0] += m[0][0] * x;-
505 m[3][1] += m[1][1] * y;-
506 }
never executed: end of block
else if (flagBits < Rotation
flagBits < RotationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
507 m[3][0] += m[0][0] * x + m[1][0] * y;-
508 m[3][1] += m[0][1] * x + m[1][1] * y;-
509 }
never executed: end of block
else {
0
510 m[3][0] += m[0][0] * x + m[1][0] * y;-
511 m[3][1] += m[0][1] * x + m[1][1] * y;-
512 m[3][2] += m[0][2] * x + m[1][2] * y;-
513 m[3][3] += m[0][3] * x + m[1][3] * y;-
514 }
never executed: end of block
0
515 flagBits |= Translation;-
516}
never executed: end of block
0
517void QMatrix4x4::translate(float x, float y, float z)-
518{-
519 if (flagBits == Identity
flagBits == IdentityDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
520 m[3][0] = x;-
521 m[3][1] = y;-
522 m[3][2] = z;-
523 }
never executed: end of block
else if (flagBits == Translation
flagBits == TranslationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
524 m[3][0] += x;-
525 m[3][1] += y;-
526 m[3][2] += z;-
527 }
never executed: end of block
else if (flagBits == Scale
flagBits == ScaleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
528 m[3][0] = m[0][0] * x;-
529 m[3][1] = m[1][1] * y;-
530 m[3][2] = m[2][2] * z;-
531 }
never executed: end of block
else if (flagBits == (Translation | Scale)
flagBits == (T...ation | Scale)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
532 m[3][0] += m[0][0] * x;-
533 m[3][1] += m[1][1] * y;-
534 m[3][2] += m[2][2] * z;-
535 }
never executed: end of block
else if (flagBits < Rotation
flagBits < RotationDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
536 m[3][0] += m[0][0] * x + m[1][0] * y;-
537 m[3][1] += m[0][1] * x + m[1][1] * y;-
538 m[3][2] += m[2][2] * z;-
539 }
never executed: end of block
else {
0
540 m[3][0] += m[0][0] * x + m[1][0] * y + m[2][0] * z;-
541 m[3][1] += m[0][1] * x + m[1][1] * y + m[2][1] * z;-
542 m[3][2] += m[0][2] * x + m[1][2] * y + m[2][2] * z;-
543 m[3][3] += m[0][3] * x + m[1][3] * y + m[2][3] * z;-
544 }
never executed: end of block
0
545 flagBits |= Translation;-
546}
never executed: end of block
0
547void QMatrix4x4::rotate(float angle, const QVector3D& vector)-
548{-
549 rotate(angle, vector.x(), vector.y(), vector.z());-
550}
never executed: end of block
0
551void QMatrix4x4::rotate(float angle, float x, float y, float z)-
552{-
553 if (angle == 0.0f
angle == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
554 return;
never executed: return;
0
555 float c, s;-
556 if (angle == 90.0f
angle == 90.0fDescription
TRUEnever evaluated
FALSEnever evaluated
|| angle == -270.0f
angle == -270.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
557 s = 1.0f;-
558 c = 0.0f;-
559 }
never executed: end of block
else if (angle == -90.0f
angle == -90.0fDescription
TRUEnever evaluated
FALSEnever evaluated
|| angle == 270.0f
angle == 270.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
560 s = -1.0f;-
561 c = 0.0f;-
562 }
never executed: end of block
else if (angle == 180.0f
angle == 180.0fDescription
TRUEnever evaluated
FALSEnever evaluated
|| angle == -180.0f
angle == -180.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
563 s = 0.0f;-
564 c = -1.0f;-
565 }
never executed: end of block
else {
0
566 float a = angle * 3.14159265358979323846 / 180.0f;-
567 c = std::cos(a);-
568 s = std::sin(a);-
569 }
never executed: end of block
0
570 if (x == 0.0f
x == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
571 if (y == 0.0f
y == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
572 if (z != 0.0f
z != 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
573-
574 if (z < 0
z < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
575 s = -s;
never executed: s = -s;
0
576 float tmp;-
577 m[0][0] = (tmp = m[0][0]) * c + m[1][0] * s;-
578 m[1][0] = m[1][0] * c - tmp * s;-
579 m[0][1] = (tmp = m[0][1]) * c + m[1][1] * s;-
580 m[1][1] = m[1][1] * c - tmp * s;-
581 m[0][2] = (tmp = m[0][2]) * c + m[1][2] * s;-
582 m[1][2] = m[1][2] * c - tmp * s;-
583 m[0][3] = (tmp = m[0][3]) * c + m[1][3] * s;-
584 m[1][3] = m[1][3] * c - tmp * s;-
585-
586 flagBits |= Rotation2D;-
587 return;
never executed: return;
0
588 }-
589 }
never executed: end of block
else if (z == 0.0f
z == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
590-
591 if (y < 0
y < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
592 s = -s;
never executed: s = -s;
0
593 float tmp;-
594 m[2][0] = (tmp = m[2][0]) * c + m[0][0] * s;-
595 m[0][0] = m[0][0] * c - tmp * s;-
596 m[2][1] = (tmp = m[2][1]) * c + m[0][1] * s;-
597 m[0][1] = m[0][1] * c - tmp * s;-
598 m[2][2] = (tmp = m[2][2]) * c + m[0][2] * s;-
599 m[0][2] = m[0][2] * c - tmp * s;-
600 m[2][3] = (tmp = m[2][3]) * c + m[0][3] * s;-
601 m[0][3] = m[0][3] * c - tmp * s;-
602-
603 flagBits |= Rotation;-
604 return;
never executed: return;
0
605 }-
606 }
never executed: end of block
else if (y == 0.0f
y == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
&& z == 0.0f
z == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
607-
608 if (x < 0
x < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
609 s = -s;
never executed: s = -s;
0
610 float tmp;-
611 m[1][0] = (tmp = m[1][0]) * c + m[2][0] * s;-
612 m[2][0] = m[2][0] * c - tmp * s;-
613 m[1][1] = (tmp = m[1][1]) * c + m[2][1] * s;-
614 m[2][1] = m[2][1] * c - tmp * s;-
615 m[1][2] = (tmp = m[1][2]) * c + m[2][2] * s;-
616 m[2][2] = m[2][2] * c - tmp * s;-
617 m[1][3] = (tmp = m[1][3]) * c + m[2][3] * s;-
618 m[2][3] = m[2][3] * c - tmp * s;-
619-
620 flagBits |= Rotation;-
621 return;
never executed: return;
0
622 }-
623-
624 double len = double(x) * double(x) +-
625 double(y) * double(y) +-
626 double(z) * double(z);-
627 if (!qFuzzyCompare(len, 1.0)
!qFuzzyCompare(len, 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
&& !qFuzzyIsNull(len)
!qFuzzyIsNull(len)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
628 len = std::sqrt(len);-
629 x = float(double(x) / len);-
630 y = float(double(y) / len);-
631 z = float(double(z) / len);-
632 }
never executed: end of block
0
633 float ic = 1.0f - c;-
634 QMatrix4x4 rot(1);-
635 rot.m[0][0] = x * x * ic + c;-
636 rot.m[1][0] = x * y * ic - z * s;-
637 rot.m[2][0] = x * z * ic + y * s;-
638 rot.m[3][0] = 0.0f;-
639 rot.m[0][1] = y * x * ic + z * s;-
640 rot.m[1][1] = y * y * ic + c;-
641 rot.m[2][1] = y * z * ic - x * s;-
642 rot.m[3][1] = 0.0f;-
643 rot.m[0][2] = x * z * ic - y * s;-
644 rot.m[1][2] = y * z * ic + x * s;-
645 rot.m[2][2] = z * z * ic + c;-
646 rot.m[3][2] = 0.0f;-
647 rot.m[0][3] = 0.0f;-
648 rot.m[1][3] = 0.0f;-
649 rot.m[2][3] = 0.0f;-
650 rot.m[3][3] = 1.0f;-
651 rot.flagBits = Rotation;-
652 *this *= rot;-
653}
never executed: end of block
0
654-
655-
656-
657-
658void QMatrix4x4::projectedRotate(float angle, float x, float y, float z)-
659{-
660-
661-
662 if (angle == 0.0f
angle == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
663 return;
never executed: return;
0
664 float c, s;-
665 if (angle == 90.0f
angle == 90.0fDescription
TRUEnever evaluated
FALSEnever evaluated
|| angle == -270.0f
angle == -270.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
666 s = 1.0f;-
667 c = 0.0f;-
668 }
never executed: end of block
else if (angle == -90.0f
angle == -90.0fDescription
TRUEnever evaluated
FALSEnever evaluated
|| angle == 270.0f
angle == 270.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
669 s = -1.0f;-
670 c = 0.0f;-
671 }
never executed: end of block
else if (angle == 180.0f
angle == 180.0fDescription
TRUEnever evaluated
FALSEnever evaluated
|| angle == -180.0f
angle == -180.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
672 s = 0.0f;-
673 c = -1.0f;-
674 }
never executed: end of block
else {
0
675 float a = angle * 3.14159265358979323846 / 180.0f;-
676 c = std::cos(a);-
677 s = std::sin(a);-
678 }
never executed: end of block
0
679 if (x == 0.0f
x == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
680 if (y == 0.0f
y == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
681 if (z != 0.0f
z != 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
682-
683 if (z < 0
z < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
684 s = -s;
never executed: s = -s;
0
685 float tmp;-
686 m[0][0] = (tmp = m[0][0]) * c + m[1][0] * s;-
687 m[1][0] = m[1][0] * c - tmp * s;-
688 m[0][1] = (tmp = m[0][1]) * c + m[1][1] * s;-
689 m[1][1] = m[1][1] * c - tmp * s;-
690 m[0][2] = (tmp = m[0][2]) * c + m[1][2] * s;-
691 m[1][2] = m[1][2] * c - tmp * s;-
692 m[0][3] = (tmp = m[0][3]) * c + m[1][3] * s;-
693 m[1][3] = m[1][3] * c - tmp * s;-
694-
695 flagBits |= Rotation2D;-
696 return;
never executed: return;
0
697 }-
698 }
never executed: end of block
else if (z == 0.0f
z == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
699-
700 if (y < 0
y < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
701 s = -s;
never executed: s = -s;
0
702 m[0][0] = m[0][0] * c + m[3][0] * s * inv_dist_to_plane;-
703 m[0][1] = m[0][1] * c + m[3][1] * s * inv_dist_to_plane;-
704 m[0][2] = m[0][2] * c + m[3][2] * s * inv_dist_to_plane;-
705 m[0][3] = m[0][3] * c + m[3][3] * s * inv_dist_to_plane;-
706 flagBits = General;-
707 return;
never executed: return;
0
708 }-
709 }
never executed: end of block
else if (y == 0.0f
y == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
&& z == 0.0f
z == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
710-
711 if (x < 0
x < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
712 s = -s;
never executed: s = -s;
0
713 m[1][0] = m[1][0] * c - m[3][0] * s * inv_dist_to_plane;-
714 m[1][1] = m[1][1] * c - m[3][1] * s * inv_dist_to_plane;-
715 m[1][2] = m[1][2] * c - m[3][2] * s * inv_dist_to_plane;-
716 m[1][3] = m[1][3] * c - m[3][3] * s * inv_dist_to_plane;-
717 flagBits = General;-
718 return;
never executed: return;
0
719 }-
720 double len = double(x) * double(x) +-
721 double(y) * double(y) +-
722 double(z) * double(z);-
723 if (!qFuzzyCompare(len, 1.0)
!qFuzzyCompare(len, 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
&& !qFuzzyIsNull(len)
!qFuzzyIsNull(len)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
724 len = std::sqrt(len);-
725 x = float(double(x) / len);-
726 y = float(double(y) / len);-
727 z = float(double(z) / len);-
728 }
never executed: end of block
0
729 float ic = 1.0f - c;-
730 QMatrix4x4 rot(1);-
731 rot.m[0][0] = x * x * ic + c;-
732 rot.m[1][0] = x * y * ic - z * s;-
733 rot.m[2][0] = 0.0f;-
734 rot.m[3][0] = 0.0f;-
735 rot.m[0][1] = y * x * ic + z * s;-
736 rot.m[1][1] = y * y * ic + c;-
737 rot.m[2][1] = 0.0f;-
738 rot.m[3][1] = 0.0f;-
739 rot.m[0][2] = 0.0f;-
740 rot.m[1][2] = 0.0f;-
741 rot.m[2][2] = 1.0f;-
742 rot.m[3][2] = 0.0f;-
743 rot.m[0][3] = (x * z * ic - y * s) * -inv_dist_to_plane;-
744 rot.m[1][3] = (y * z * ic + x * s) * -inv_dist_to_plane;-
745 rot.m[2][3] = 0.0f;-
746 rot.m[3][3] = 1.0f;-
747 rot.flagBits = General;-
748 *this *= rot;-
749}
never executed: end of block
0
750void QMatrix4x4::rotate(const QQuaternion& quaternion)-
751{-
752-
753-
754-
755 QMatrix4x4 m(Qt::Uninitialized);-
756-
757 const float f2x = quaternion.x() + quaternion.x();-
758 const float f2y = quaternion.y() + quaternion.y();-
759 const float f2z = quaternion.z() + quaternion.z();-
760 const float f2xw = f2x * quaternion.scalar();-
761 const float f2yw = f2y * quaternion.scalar();-
762 const float f2zw = f2z * quaternion.scalar();-
763 const float f2xx = f2x * quaternion.x();-
764 const float f2xy = f2x * quaternion.y();-
765 const float f2xz = f2x * quaternion.z();-
766 const float f2yy = f2y * quaternion.y();-
767 const float f2yz = f2y * quaternion.z();-
768 const float f2zz = f2z * quaternion.z();-
769-
770 m.m[0][0] = 1.0f - (f2yy + f2zz);-
771 m.m[1][0] = f2xy - f2zw;-
772 m.m[2][0] = f2xz + f2yw;-
773 m.m[3][0] = 0.0f;-
774 m.m[0][1] = f2xy + f2zw;-
775 m.m[1][1] = 1.0f - (f2xx + f2zz);-
776 m.m[2][1] = f2yz - f2xw;-
777 m.m[3][1] = 0.0f;-
778 m.m[0][2] = f2xz - f2yw;-
779 m.m[1][2] = f2yz + f2xw;-
780 m.m[2][2] = 1.0f - (f2xx + f2yy);-
781 m.m[3][2] = 0.0f;-
782 m.m[0][3] = 0.0f;-
783 m.m[1][3] = 0.0f;-
784 m.m[2][3] = 0.0f;-
785 m.m[3][3] = 1.0f;-
786 m.flagBits = Rotation;-
787 *this *= m;-
788}
never executed: end of block
0
789void QMatrix4x4::ortho(const QRect& rect)-
790{-
791-
792-
793-
794-
795 ortho(rect.x(), rect.x() + rect.width(), rect.y() + rect.height(), rect.y(), -1.0f, 1.0f);-
796}
never executed: end of block
0
797void QMatrix4x4::ortho(const QRectF& rect)-
798{-
799 ortho(rect.left(), rect.right(), rect.bottom(), rect.top(), -1.0f, 1.0f);-
800}
never executed: end of block
0
801void QMatrix4x4::ortho(float left, float right, float bottom, float top, float nearPlane, float farPlane)-
802{-
803-
804 if (left == right
left == rightDescription
TRUEnever evaluated
FALSEnever evaluated
|| bottom == top
bottom == topDescription
TRUEnever evaluated
FALSEnever evaluated
|| nearPlane == farPlane
nearPlane == farPlaneDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
805 return;
never executed: return;
0
806-
807-
808 float width = right - left;-
809 float invheight = top - bottom;-
810 float clip = farPlane - nearPlane;-
811 QMatrix4x4 m(1);-
812 m.m[0][0] = 2.0f / width;-
813 m.m[1][0] = 0.0f;-
814 m.m[2][0] = 0.0f;-
815 m.m[3][0] = -(left + right) / width;-
816 m.m[0][1] = 0.0f;-
817 m.m[1][1] = 2.0f / invheight;-
818 m.m[2][1] = 0.0f;-
819 m.m[3][1] = -(top + bottom) / invheight;-
820 m.m[0][2] = 0.0f;-
821 m.m[1][2] = 0.0f;-
822 m.m[2][2] = -2.0f / clip;-
823 m.m[3][2] = -(nearPlane + farPlane) / clip;-
824 m.m[0][3] = 0.0f;-
825 m.m[1][3] = 0.0f;-
826 m.m[2][3] = 0.0f;-
827 m.m[3][3] = 1.0f;-
828 m.flagBits = Translation | Scale;-
829-
830-
831 *this *= m;-
832}
never executed: end of block
0
833void QMatrix4x4::frustum(float left, float right, float bottom, float top, float nearPlane, float farPlane)-
834{-
835-
836 if (left == right
left == rightDescription
TRUEnever evaluated
FALSEnever evaluated
|| bottom == top
bottom == topDescription
TRUEnever evaluated
FALSEnever evaluated
|| nearPlane == farPlane
nearPlane == farPlaneDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
837 return;
never executed: return;
0
838-
839-
840 QMatrix4x4 m(1);-
841 float width = right - left;-
842 float invheight = top - bottom;-
843 float clip = farPlane - nearPlane;-
844 m.m[0][0] = 2.0f * nearPlane / width;-
845 m.m[1][0] = 0.0f;-
846 m.m[2][0] = (left + right) / width;-
847 m.m[3][0] = 0.0f;-
848 m.m[0][1] = 0.0f;-
849 m.m[1][1] = 2.0f * nearPlane / invheight;-
850 m.m[2][1] = (top + bottom) / invheight;-
851 m.m[3][1] = 0.0f;-
852 m.m[0][2] = 0.0f;-
853 m.m[1][2] = 0.0f;-
854 m.m[2][2] = -(nearPlane + farPlane) / clip;-
855 m.m[3][2] = -2.0f * nearPlane * farPlane / clip;-
856 m.m[0][3] = 0.0f;-
857 m.m[1][3] = 0.0f;-
858 m.m[2][3] = -1.0f;-
859 m.m[3][3] = 0.0f;-
860 m.flagBits = General;-
861-
862-
863 *this *= m;-
864}
never executed: end of block
0
865void QMatrix4x4::perspective(float verticalAngle, float aspectRatio, float nearPlane, float farPlane)-
866{-
867-
868 if (nearPlane == farPlane
nearPlane == farPlaneDescription
TRUEnever evaluated
FALSEnever evaluated
|| aspectRatio == 0.0f
aspectRatio == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
869 return;
never executed: return;
0
870-
871-
872 QMatrix4x4 m(1);-
873 float radians = (verticalAngle / 2.0f) * 3.14159265358979323846 / 180.0f;-
874 float sine = std::sin(radians);-
875 if (sine == 0.0f
sine == 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
876 return;
never executed: return;
0
877 float cotan = std::cos(radians) / sine;-
878 float clip = farPlane - nearPlane;-
879 m.m[0][0] = cotan / aspectRatio;-
880 m.m[1][0] = 0.0f;-
881 m.m[2][0] = 0.0f;-
882 m.m[3][0] = 0.0f;-
883 m.m[0][1] = 0.0f;-
884 m.m[1][1] = cotan;-
885 m.m[2][1] = 0.0f;-
886 m.m[3][1] = 0.0f;-
887 m.m[0][2] = 0.0f;-
888 m.m[1][2] = 0.0f;-
889 m.m[2][2] = -(nearPlane + farPlane) / clip;-
890 m.m[3][2] = -(2.0f * nearPlane * farPlane) / clip;-
891 m.m[0][3] = 0.0f;-
892 m.m[1][3] = 0.0f;-
893 m.m[2][3] = -1.0f;-
894 m.m[3][3] = 0.0f;-
895 m.flagBits = General;-
896-
897-
898 *this *= m;-
899}
never executed: end of block
0
900void QMatrix4x4::lookAt(const QVector3D& eye, const QVector3D& center, const QVector3D& up)-
901{-
902 QVector3D forward = center - eye;-
903 if (qFuzzyIsNull(forward.x())
qFuzzyIsNull(forward.x())Description
TRUEnever evaluated
FALSEnever evaluated
&& qFuzzyIsNull(forward.y())
qFuzzyIsNull(forward.y())Description
TRUEnever evaluated
FALSEnever evaluated
&& qFuzzyIsNull(forward.z())
qFuzzyIsNull(forward.z())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
904 return;
never executed: return;
0
905-
906 forward.normalize();-
907 QVector3D side = QVector3D::crossProduct(forward, up).normalized();-
908 QVector3D upVector = QVector3D::crossProduct(side, forward);-
909-
910 QMatrix4x4 m(1);-
911 m.m[0][0] = side.x();-
912 m.m[1][0] = side.y();-
913 m.m[2][0] = side.z();-
914 m.m[3][0] = 0.0f;-
915 m.m[0][1] = upVector.x();-
916 m.m[1][1] = upVector.y();-
917 m.m[2][1] = upVector.z();-
918 m.m[3][1] = 0.0f;-
919 m.m[0][2] = -forward.x();-
920 m.m[1][2] = -forward.y();-
921 m.m[2][2] = -forward.z();-
922 m.m[3][2] = 0.0f;-
923 m.m[0][3] = 0.0f;-
924 m.m[1][3] = 0.0f;-
925 m.m[2][3] = 0.0f;-
926 m.m[3][3] = 1.0f;-
927 m.flagBits = Rotation;-
928-
929 *this *= m;-
930 translate(-eye);-
931}
never executed: end of block
0
932void QMatrix4x4::viewport(float left, float bottom, float width, float height, float nearPlane, float farPlane)-
933{-
934 const float w2 = width / 2.0f;-
935 const float h2 = height / 2.0f;-
936-
937 QMatrix4x4 m(1);-
938 m.m[0][0] = w2;-
939 m.m[1][0] = 0.0f;-
940 m.m[2][0] = 0.0f;-
941 m.m[3][0] = left + w2;-
942 m.m[0][1] = 0.0f;-
943 m.m[1][1] = h2;-
944 m.m[2][1] = 0.0f;-
945 m.m[3][1] = bottom + h2;-
946 m.m[0][2] = 0.0f;-
947 m.m[1][2] = 0.0f;-
948 m.m[2][2] = (farPlane - nearPlane) / 2.0f;-
949 m.m[3][2] = (nearPlane + farPlane) / 2.0f;-
950 m.m[0][3] = 0.0f;-
951 m.m[1][3] = 0.0f;-
952 m.m[2][3] = 0.0f;-
953 m.m[3][3] = 1.0f;-
954 m.flagBits = General;-
955-
956 *this *= m;-
957}
never executed: end of block
0
958void QMatrix4x4::flipCoordinates()-
959{-
960-
961-
962-
963 if (flagBits < Rotation2D
flagBits < Rotation2DDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
964-
965 m[1][1] = -m[1][1];-
966 m[2][2] = -m[2][2];-
967 }
never executed: end of block
else {
0
968 m[1][0] = -m[1][0];-
969 m[1][1] = -m[1][1];-
970 m[1][2] = -m[1][2];-
971 m[1][3] = -m[1][3];-
972 m[2][0] = -m[2][0];-
973 m[2][1] = -m[2][1];-
974 m[2][2] = -m[2][2];-
975 m[2][3] = -m[2][3];-
976 }
never executed: end of block
0
977 flagBits |= Scale;-
978}
never executed: end of block
0
979-
980-
981-
982-
983-
984void QMatrix4x4::copyDataTo(float *values) const-
985{-
986 for (int row = 0; row < 4
row < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++row)
0
987 for (int col = 0; col < 4
col < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++col)
0
988 values[row * 4 + col] = float(m[col][row]);
never executed: values[row * 4 + col] = float(m[col][row]);
0
989}
never executed: end of block
0
990QMatrix QMatrix4x4::toAffine() const-
991{-
992 return
never executed: return QMatrix(m[0][0], m[0][1], m[1][0], m[1][1], m[3][0], m[3][1]);
QMatrix(m[0][0], m[0][1],
never executed: return QMatrix(m[0][0], m[0][1], m[1][0], m[1][1], m[3][0], m[3][1]);
0
993 m[1][0], m[1][1],
never executed: return QMatrix(m[0][0], m[0][1], m[1][0], m[1][1], m[3][0], m[3][1]);
0
994 m[3][0], m[3][1]);
never executed: return QMatrix(m[0][0], m[0][1], m[1][0], m[1][1], m[3][0], m[3][1]);
0
995}-
996QTransform QMatrix4x4::toTransform() const-
997{-
998 return
never executed: return QTransform(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
QTransform(m[0][0], m[0][1], m[0][3],
never executed: return QTransform(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
0
999 m[1][0], m[1][1], m[1][3],
never executed: return QTransform(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
0
1000 m[3][0], m[3][1], m[3][3]);
never executed: return QTransform(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
0
1001}-
1002QTransform QMatrix4x4::toTransform(float distanceToPlane) const-
1003{-
1004 if (distanceToPlane == 1024.0f
distanceToPlane == 1024.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1005-
1006 return
never executed: return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * inv_dist_to_plane, m[1][0], m[1][1], m[1][3] - m[1][2] * inv_dist_to_plane, m[3][0], m[3][1], m[3][3] - m[3][2] * inv_dist_to_plane);
QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * inv_dist_to_plane,
never executed: return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * inv_dist_to_plane, m[1][0], m[1][1], m[1][3] - m[1][2] * inv_dist_to_plane, m[3][0], m[3][1], m[3][3] - m[3][2] * inv_dist_to_plane);
0
1007 m[1][0], m[1][1], m[1][3] - m[1][2] * inv_dist_to_plane,
never executed: return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * inv_dist_to_plane, m[1][0], m[1][1], m[1][3] - m[1][2] * inv_dist_to_plane, m[3][0], m[3][1], m[3][3] - m[3][2] * inv_dist_to_plane);
0
1008 m[3][0], m[3][1], m[3][3] - m[3][2] * inv_dist_to_plane);
never executed: return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * inv_dist_to_plane, m[1][0], m[1][1], m[1][3] - m[1][2] * inv_dist_to_plane, m[3][0], m[3][1], m[3][3] - m[3][2] * inv_dist_to_plane);
0
1009 } else if (distanceToPlane != 0.0f
distanceToPlane != 0.0fDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1010-
1011-
1012-
1013-
1014-
1015-
1016-
1017 float d = 1.0f / distanceToPlane;-
1018 return
never executed: return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * d, m[1][0], m[1][1], m[1][3] - m[1][2] * d, m[3][0], m[3][1], m[3][3] - m[3][2] * d);
QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * d,
never executed: return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * d, m[1][0], m[1][1], m[1][3] - m[1][2] * d, m[3][0], m[3][1], m[3][3] - m[3][2] * d);
0
1019 m[1][0], m[1][1], m[1][3] - m[1][2] * d,
never executed: return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * d, m[1][0], m[1][1], m[1][3] - m[1][2] * d, m[3][0], m[3][1], m[3][3] - m[3][2] * d);
0
1020 m[3][0], m[3][1], m[3][3] - m[3][2] * d);
never executed: return QTransform(m[0][0], m[0][1], m[0][3] - m[0][2] * d, m[1][0], m[1][1], m[1][3] - m[1][2] * d, m[3][0], m[3][1], m[3][3] - m[3][2] * d);
0
1021 } else {-
1022-
1023 return
never executed: return QTransform(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
QTransform(m[0][0], m[0][1], m[0][3],
never executed: return QTransform(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
0
1024 m[1][0], m[1][1], m[1][3],
never executed: return QTransform(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
0
1025 m[3][0], m[3][1], m[3][3]);
never executed: return QTransform(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]);
0
1026 }-
1027}-
1028QRect QMatrix4x4::mapRect(const QRect& rect) const-
1029{-
1030 if (flagBits < Scale
flagBits < ScaleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1031-
1032 return
never executed: return QRect(qRound(rect.x() + m[3][0]), qRound(rect.y() + m[3][1]), rect.width(), rect.height());
QRect(qRound(rect.x() + m[3][0]),
never executed: return QRect(qRound(rect.x() + m[3][0]), qRound(rect.y() + m[3][1]), rect.width(), rect.height());
0
1033 qRound(rect.y() + m[3][1]),
never executed: return QRect(qRound(rect.x() + m[3][0]), qRound(rect.y() + m[3][1]), rect.width(), rect.height());
0
1034 rect.width(), rect.height());
never executed: return QRect(qRound(rect.x() + m[3][0]), qRound(rect.y() + m[3][1]), rect.width(), rect.height());
0
1035 } else if (flagBits < Rotation2D
flagBits < Rotation2DDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1036-
1037 float x = rect.x() * m[0][0] + m[3][0];-
1038 float y = rect.y() * m[1][1] + m[3][1];-
1039 float w = rect.width() * m[0][0];-
1040 float h = rect.height() * m[1][1];-
1041 if (w < 0
w < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1042 w = -w;-
1043 x -= w;-
1044 }
never executed: end of block
0
1045 if (h < 0
h < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1046 h = -h;-
1047 y -= h;-
1048 }
never executed: end of block
0
1049 return
never executed: return QRect(qRound(x), qRound(y), qRound(w), qRound(h));
QRect(qRound(x), qRound(y), qRound(w), qRound(h));
never executed: return QRect(qRound(x), qRound(y), qRound(w), qRound(h));
0
1050 }-
1051-
1052 QPoint tl = map(rect.topLeft());-
1053 QPoint tr = map(QPoint(rect.x() + rect.width(), rect.y()));-
1054 QPoint bl = map(QPoint(rect.x(), rect.y() + rect.height()));-
1055 QPoint br = map(QPoint(rect.x() + rect.width(),-
1056 rect.y() + rect.height()));-
1057-
1058 int xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x()));-
1059 int xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x()));-
1060 int ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y()));-
1061 int ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y()));-
1062-
1063 return
never executed: return QRect(xmin, ymin, xmax - xmin, ymax - ymin);
QRect(xmin, ymin, xmax - xmin, ymax - ymin);
never executed: return QRect(xmin, ymin, xmax - xmin, ymax - ymin);
0
1064}-
1065QRectF QMatrix4x4::mapRect(const QRectF& rect) const-
1066{-
1067 if (flagBits < Scale
flagBits < ScaleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1068-
1069 return
never executed: return rect.translated(m[3][0], m[3][1]);
rect.translated(m[3][0], m[3][1]);
never executed: return rect.translated(m[3][0], m[3][1]);
0
1070 } else if (flagBits < Rotation2D
flagBits < Rotation2DDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1071-
1072 float x = rect.x() * m[0][0] + m[3][0];-
1073 float y = rect.y() * m[1][1] + m[3][1];-
1074 float w = rect.width() * m[0][0];-
1075 float h = rect.height() * m[1][1];-
1076 if (w < 0
w < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1077 w = -w;-
1078 x -= w;-
1079 }
never executed: end of block
0
1080 if (h < 0
h < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1081 h = -h;-
1082 y -= h;-
1083 }
never executed: end of block
0
1084 return
never executed: return QRectF(x, y, w, h);
QRectF(x, y, w, h);
never executed: return QRectF(x, y, w, h);
0
1085 }-
1086-
1087 QPointF tl = map(rect.topLeft()); QPointF tr = map(rect.topRight());-
1088 QPointF bl = map(rect.bottomLeft()); QPointF br = map(rect.bottomRight());-
1089-
1090 float xmin = qMin(qMin(tl.x(), tr.x()), qMin(bl.x(), br.x()));-
1091 float xmax = qMax(qMax(tl.x(), tr.x()), qMax(bl.x(), br.x()));-
1092 float ymin = qMin(qMin(tl.y(), tr.y()), qMin(bl.y(), br.y()));-
1093 float ymax = qMax(qMax(tl.y(), tr.y()), qMax(bl.y(), br.y()));-
1094-
1095 return
never executed: return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax));
QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax));
never executed: return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax));
0
1096}-
1097QMatrix4x4 QMatrix4x4::orthonormalInverse() const-
1098{-
1099 QMatrix4x4 result(1);-
1100-
1101 result.m[0][0] = m[0][0];-
1102 result.m[1][0] = m[0][1];-
1103 result.m[2][0] = m[0][2];-
1104-
1105 result.m[0][1] = m[1][0];-
1106 result.m[1][1] = m[1][1];-
1107 result.m[2][1] = m[1][2];-
1108-
1109 result.m[0][2] = m[2][0];-
1110 result.m[1][2] = m[2][1];-
1111 result.m[2][2] = m[2][2];-
1112-
1113 result.m[0][3] = 0.0f;-
1114 result.m[1][3] = 0.0f;-
1115 result.m[2][3] = 0.0f;-
1116-
1117 result.m[3][0] = -(result.m[0][0] * m[3][0] + result.m[1][0] * m[3][1] + result.m[2][0] * m[3][2]);-
1118 result.m[3][1] = -(result.m[0][1] * m[3][0] + result.m[1][1] * m[3][1] + result.m[2][1] * m[3][2]);-
1119 result.m[3][2] = -(result.m[0][2] * m[3][0] + result.m[1][2] * m[3][1] + result.m[2][2] * m[3][2]);-
1120 result.m[3][3] = 1.0f;-
1121-
1122 result.flagBits = flagBits;-
1123-
1124 return
never executed: return result;
result;
never executed: return result;
0
1125}-
1126void QMatrix4x4::optimize()-
1127{-
1128-
1129 flagBits = General;-
1130 if (m[0][3] != 0
m[0][3] != 0Description
TRUEnever evaluated
FALSEnever evaluated
|| m[1][3] != 0
m[1][3] != 0Description
TRUEnever evaluated
FALSEnever evaluated
|| m[2][3] != 0
m[2][3] != 0Description
TRUEnever evaluated
FALSEnever evaluated
|| m[3][3] != 1
m[3][3] != 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1131 return;
never executed: return;
0
1132-
1133 flagBits &= ~Perspective;-
1134-
1135-
1136 if (m[3][0] == 0
m[3][0] == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& m[3][1] == 0
m[3][1] == 0Description
TRUEnever evaluated
FALSEnever evaluated
&& m[3][2] == 0
m[3][2] == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1137 flagBits &= ~Translation;
never executed: flagBits &= ~Translation;
0
1138-
1139-
1140 if (!m[0][2]
!m[0][2]Description
TRUEnever evaluated
FALSEnever evaluated
&& !m[1][2]
!m[1][2]Description
TRUEnever evaluated
FALSEnever evaluated
&& !m[2][0]
!m[2][0]Description
TRUEnever evaluated
FALSEnever evaluated
&& !m[2][1]
!m[2][1]Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1141 flagBits &= ~Rotation;-
1142-
1143 if (!m[0][1]
!m[0][1]Description
TRUEnever evaluated
FALSEnever evaluated
&& !m[1][0]
!m[1][0]Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1144 flagBits &= ~Rotation2D;-
1145-
1146 if (m[0][0] == 1
m[0][0] == 1Description
TRUEnever evaluated
FALSEnever evaluated
&& m[1][1] == 1
m[1][1] == 1Description
TRUEnever evaluated
FALSEnever evaluated
&& m[2][2] == 1
m[2][2] == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1147 flagBits &= ~Scale;
never executed: flagBits &= ~Scale;
0
1148 }
never executed: end of block
else {
0
1149-
1150 double mm[4][4];-
1151 copyToDoubles(m, mm);-
1152 double det = matrixDet2(mm, 0, 1, 0, 1);-
1153 double lenX = mm[0][0] * mm[0][0] + mm[0][1] * mm[0][1];-
1154 double lenY = mm[1][0] * mm[1][0] + mm[1][1] * mm[1][1];-
1155 double lenZ = mm[2][2];-
1156 if (qFuzzyCompare(det, 1.0)
qFuzzyCompare(det, 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
&& qFuzzyCompare(lenX, 1.0)
qFuzzyCompare(lenX, 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1157 && qFuzzyCompare(lenY, 1.0)
qFuzzyCompare(lenY, 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
&& qFuzzyCompare(lenZ, 1.0)
qFuzzyCompare(lenZ, 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1158 {-
1159 flagBits &= ~Scale;-
1160 }
never executed: end of block
0
1161 }
never executed: end of block
0
1162 } else {-
1163-
1164 double mm[4][4];-
1165 copyToDoubles(m, mm);-
1166 double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2);-
1167 double lenX = mm[0][0] * mm[0][0] + mm[0][1] * mm[0][1] + mm[0][2] * mm[0][2];-
1168 double lenY = mm[1][0] * mm[1][0] + mm[1][1] * mm[1][1] + mm[1][2] * mm[1][2];-
1169 double lenZ = mm[2][0] * mm[2][0] + mm[2][1] * mm[2][1] + mm[2][2] * mm[2][2];-
1170 if (qFuzzyCompare(det, 1.0)
qFuzzyCompare(det, 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
&& qFuzzyCompare(lenX, 1.0)
qFuzzyCompare(lenX, 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1171 && qFuzzyCompare(lenY, 1.0)
qFuzzyCompare(lenY, 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
&& qFuzzyCompare(lenZ, 1.0)
qFuzzyCompare(lenZ, 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1172 {-
1173 flagBits &= ~Scale;-
1174 }
never executed: end of block
0
1175 }
never executed: end of block
0
1176}-
1177-
1178-
1179-
1180-
1181QMatrix4x4::operator QVariant() const-
1182{-
1183 return
never executed: return QVariant(QVariant::Matrix4x4, this);
QVariant(QVariant::Matrix4x4, this);
never executed: return QVariant(QVariant::Matrix4x4, this);
0
1184}-
1185-
1186-
1187-
1188QDebug operator<<(QDebug dbg, const QMatrix4x4 &m)-
1189{-
1190 QDebugStateSaver saver(dbg);-
1191-
1192 QByteArray bits;-
1193 if (m.flagBits == QMatrix4x4::Identity
m.flagBits == ...x4x4::IdentityDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1194 bits = "Identity";-
1195 }
never executed: end of block
else if (m.flagBits == QMatrix4x4::General
m.flagBits == ...ix4x4::GeneralDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1196 bits = "General";-
1197 }
never executed: end of block
else {
0
1198 if ((
(m.flagBits & ...nslation) != 0Description
TRUEnever evaluated
FALSEnever evaluated
m.flagBits & QMatrix4x4::Translation) != 0
(m.flagBits & ...nslation) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1199 bits += "Translation,";
never executed: bits += "Translation,";
0
1200 if ((
(m.flagBits & ...4::Scale) != 0Description
TRUEnever evaluated
FALSEnever evaluated
m.flagBits & QMatrix4x4::Scale) != 0
(m.flagBits & ...4::Scale) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1201 bits += "Scale,";
never executed: bits += "Scale,";
0
1202 if ((
(m.flagBits & ...tation2D) != 0Description
TRUEnever evaluated
FALSEnever evaluated
m.flagBits & QMatrix4x4::Rotation2D) != 0
(m.flagBits & ...tation2D) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1203 bits += "Rotation2D,";
never executed: bits += "Rotation2D,";
0
1204 if ((
(m.flagBits & ...Rotation) != 0Description
TRUEnever evaluated
FALSEnever evaluated
m.flagBits & QMatrix4x4::Rotation) != 0
(m.flagBits & ...Rotation) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1205 bits += "Rotation,";
never executed: bits += "Rotation,";
0
1206 if ((
(m.flagBits & ...spective) != 0Description
TRUEnever evaluated
FALSEnever evaluated
m.flagBits & QMatrix4x4::Perspective) != 0
(m.flagBits & ...spective) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1207 bits += "Perspective,";
never executed: bits += "Perspective,";
0
1208 if (bits.size() > 0
bits.size() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1209 bits = bits.left(bits.size() - 1);
never executed: bits = bits.left(bits.size() - 1);
0
1210 }
never executed: end of block
0
1211-
1212-
1213 dbg.nospace() << "QMatrix4x4(type:" << bits.constData() << endl-
1214 << qSetFieldWidth(10)-
1215 << m(0, 0) << m(0, 1) << m(0, 2) << m(0, 3) << endl-
1216 << m(1, 0) << m(1, 1) << m(1, 2) << m(1, 3) << endl-
1217 << m(2, 0) << m(2, 1) << m(2, 2) << m(2, 3) << endl-
1218 << m(3, 0) << m(3, 1) << m(3, 2) << m(3, 3) << endl-
1219 << qSetFieldWidth(0) << ')';-
1220 return
never executed: return dbg;
dbg;
never executed: return dbg;
0
1221}-
1222QDataStream &operator<<(QDataStream &stream, const QMatrix4x4 &matrix)-
1223{-
1224 for (int row = 0; row < 4
row < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++row)
0
1225 for (int col = 0; col < 4
col < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++col)
0
1226 stream << matrix(row, col);
never executed: stream << matrix(row, col);
0
1227 return
never executed: return stream;
stream;
never executed: return stream;
0
1228}-
1229QDataStream &operator>>(QDataStream &stream, QMatrix4x4 &matrix)-
1230{-
1231 float x;-
1232 for (int row = 0; row < 4
row < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++row) {
0
1233 for (int col = 0; col < 4
col < 4Description
TRUEnever evaluated
FALSEnever evaluated
; ++col) {
0
1234 stream >> x;-
1235 matrix(row, col) = x;-
1236 }
never executed: end of block
0
1237 }
never executed: end of block
0
1238 matrix.optimize();-
1239 return
never executed: return stream;
stream;
never executed: return stream;
0
1240}-
1241-
1242-
1243-
1244-
1245-
1246-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9