Skip to content

Commit c9c21d4

Browse files
committed
Optimize TRS computation
1 parent a8dd156 commit c9c21d4

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

irr/include/Transform.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ struct Transform {
2626

2727
matrix4 buildMatrix() const
2828
{
29-
matrix4 T;
30-
T.setTranslation(translation);
31-
matrix4 R;
32-
rotation.getMatrix_transposed(R);
33-
matrix4 S;
34-
S.setScale(scale);
35-
return T * R * S;
29+
matrix4 trs;
30+
rotation.getMatrix_transposed(trs);
31+
auto scale_row = [&trs](int col, f32 scale) {
32+
int i = 4 * col;
33+
trs[i] *= scale;
34+
trs[i + 1] *= scale;
35+
trs[i + 2] *= scale;
36+
};
37+
scale_row(0, scale.X);
38+
scale_row(1, scale.Y);
39+
scale_row(2, scale.Z);
40+
trs.setTranslation(translation);
41+
return trs;
3642
}
3743
};
3844

0 commit comments

Comments
 (0)