@@ -24,41 +24,40 @@ struct Transform {
24
24
}};
25
25
26
26
static Transform Identity () {
27
- Transform transform;
28
- return transform;
27
+ return {};
29
28
}
30
29
31
30
static Transform Perspective (const Float &perspective) {
32
- Transform transform;
31
+ auto transform = Transform {} ;
33
32
transform.matrix [11 ] = -1.0 / perspective;
34
33
return transform;
35
34
}
36
35
37
36
static Transform Scale (const Float &factorX, const Float &factorY, const Float &factorZ) {
38
- Transform transform;
37
+ auto transform = Transform {} ;
39
38
transform.matrix [0 ] = factorX;
40
39
transform.matrix [5 ] = factorY;
41
40
transform.matrix [10 ] = factorZ;
42
41
return transform;
43
42
}
44
43
45
44
static Transform Translate (const Float &x, const Float &y, const Float &z) {
46
- Transform transform;
45
+ auto transform = Transform {} ;
47
46
transform.matrix [12 ] = x;
48
47
transform.matrix [13 ] = y;
49
48
transform.matrix [14 ] = z;
50
49
return transform;
51
50
}
52
51
53
52
static Transform Skew (const Float &x, const Float &y) {
54
- Transform transform;
53
+ auto transform = Transform {} ;
55
54
transform.matrix [4 ] = std::tan (x);
56
55
transform.matrix [1 ] = std::tan (y);
57
56
return transform;
58
57
}
59
58
60
59
static Transform RotateX (const Float &radians) {
61
- Transform transform;
60
+ auto transform = Transform {} ;
62
61
transform.matrix [5 ] = std::cos (radians);
63
62
transform.matrix [6 ] = std::sin (radians);
64
63
transform.matrix [9 ] = -std::sin (radians);
@@ -67,7 +66,7 @@ struct Transform {
67
66
}
68
67
69
68
static Transform RotateY (const Float &radians) {
70
- Transform transform;
69
+ auto transform = Transform {} ;
71
70
transform.matrix [0 ] = std::cos (radians);
72
71
transform.matrix [2 ] = -std::sin (radians);
73
72
transform.matrix [8 ] = std::sin (radians);
@@ -76,7 +75,7 @@ struct Transform {
76
75
}
77
76
78
77
static Transform RotateZ (const Float &radians) {
79
- Transform transform;
78
+ auto transform = Transform {} ;
80
79
transform.matrix [0 ] = std::cos (radians);
81
80
transform.matrix [1 ] = std::sin (radians);
82
81
transform.matrix [4 ] = -std::sin (radians);
@@ -85,15 +84,15 @@ struct Transform {
85
84
}
86
85
87
86
static Transform Rotate (const Float &x, const Float &y, const Float &z) {
88
- Transform transform;
87
+ auto transform = Transform {} ;
89
88
if (x != 0 ) { transform = transform * Transform::RotateX (x); }
90
89
if (y != 0 ) { transform = transform * Transform::RotateY (y); }
91
90
if (z != 0 ) { transform = transform * Transform::RotateZ (z); }
92
91
return transform;
93
92
}
94
93
95
94
bool operator ==(const Transform& rhs) const {
96
- for (int i = 0 ; i < 16 ; i++) {
95
+ for (auto i = 0 ; i < 16 ; i++) {
97
96
if (matrix[i] != rhs.matrix [i]) {
98
97
return false ;
99
98
}
@@ -110,15 +109,15 @@ struct Transform {
110
109
return rhs;
111
110
}
112
111
113
- const Transform &lhs = *this ;
114
- Transform result;
112
+ const auto &lhs = *this ;
113
+ auto result = Transform {} ;
115
114
116
- Float lhs00 = lhs.matrix [0 ], lhs01 = lhs.matrix [1 ], lhs02 = lhs.matrix [2 ], lhs03 = lhs.matrix [3 ],
115
+ auto lhs00 = lhs.matrix [0 ], lhs01 = lhs.matrix [1 ], lhs02 = lhs.matrix [2 ], lhs03 = lhs.matrix [3 ],
117
116
lhs10 = lhs.matrix [4 ], lhs11 = lhs.matrix [5 ], lhs12 = lhs.matrix [6 ], lhs13 = lhs.matrix [7 ],
118
117
lhs20 = lhs.matrix [8 ], lhs21 = lhs.matrix [9 ], lhs22 = lhs.matrix [10 ], lhs23 = lhs.matrix [11 ],
119
118
lhs30 = lhs.matrix [12 ], lhs31 = lhs.matrix [13 ], lhs32 = lhs.matrix [14 ], lhs33 = lhs.matrix [15 ];
120
119
121
- Float rhs0 = rhs.matrix [0 ], rhs1 = rhs.matrix [1 ], rhs2 = rhs.matrix [2 ], rhs3 = rhs.matrix [3 ];
120
+ auto rhs0 = rhs.matrix [0 ], rhs1 = rhs.matrix [1 ], rhs2 = rhs.matrix [2 ], rhs3 = rhs.matrix [3 ];
122
121
result.matrix [0 ] = rhs0 * lhs00 + rhs1 * lhs10 + rhs2 * lhs20 + rhs3 * lhs30;
123
122
result.matrix [1 ] = rhs0 * lhs01 + rhs1 * lhs11 + rhs2 * lhs21 + rhs3 * lhs31;
124
123
result.matrix [2 ] = rhs0 * lhs02 + rhs1 * lhs12 + rhs2 * lhs22 + rhs3 * lhs32;
0 commit comments