@@ -17,7 +17,7 @@ namespace math
17
17
namespace linalg
18
18
{
19
19
20
- /// Builds a rotation 4 * 4 matrix created from an axis vector and an angle.
20
+ /// Builds a rotation 3 * 3 matrix created from an axis vector and an angle.
21
21
///
22
22
/// @param angle Rotation angle expressed in radians.
23
23
/// @param axis Rotation axis, must be normalized.
@@ -53,15 +53,15 @@ namespace impl
53
53
template<uint16_t MOut, uint16_t MIn , typename T>
54
54
struct zero_expand_helper
55
55
{
56
- static vector <T, MOut> __call (vector <T, MIn > inVec)
56
+ static vector <T, MOut> __call (const vector <T, MIn > inVec)
57
57
{
58
58
return vector <T, MOut>(inVec, vector <T, MOut - MIn >(0 ));
59
59
}
60
60
};
61
61
template<uint16_t M, typename T>
62
62
struct zero_expand_helper<M,M,T>
63
63
{
64
- static vector <T, M> __call (vector <T, M> inVec)
64
+ static vector <T, M> __call (const vector <T, M> inVec)
65
65
{
66
66
return inVec;
67
67
}
@@ -81,10 +81,14 @@ matrix<T, NOut, MOut> promote_affine(const matrix<T, NIn, MIn> inMatrix)
81
81
82
82
using out_row_t = hlsl::vector <T, MOut>;
83
83
84
- for (uint32_t row_i = 0 ; row_i < NOut ; row_i++)
84
+ NBL_UNROLL for (uint32_t row_i = 0 ; row_i < NIn ; row_i++)
85
85
{
86
- retval[row_i] = hlsl::mix (promote<out_row_t>(0.0 ), zero_expand<MOut, MIn >(inMatrix[row_i]), row_i < NIn);
87
- if ((row_i >= NIn || row_i >= MIn ) && row_i < MOut)
86
+ retval[row_i] = zero_expand<MOut, MIn >(inMatrix[row_i]);
87
+ }
88
+ NBL_UNROLL for (uint32_t row_i = NIn; row_i < NOut; row_i++)
89
+ {
90
+ retval[row_i] = promote<out_row_t>(0.0 );
91
+ if (row_i >= MIn && row_i < MOut)
88
92
retval[row_i][row_i] = T (1.0 );
89
93
}
90
94
return retval;
0 commit comments