Fix: convert math::Axis to vector
This commit is contained in:
@@ -321,9 +321,9 @@ template<> inline AxisSigned abs(const AxisSigned &axis)
|
||||
/** Create basis vector. */
|
||||
template<typename T> T to_vector(const Axis axis)
|
||||
{
|
||||
BLI_assert(axis <= AxisSigned::from_int(T::type_length - 1));
|
||||
BLI_assert(axis.as_int() < T::type_length);
|
||||
T vec{};
|
||||
vec[axis] = 1;
|
||||
vec[axis.as_int()] = 1;
|
||||
return vec;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,13 @@ TEST(math_rotation_types, AxisSignedConvertToVec)
|
||||
EXPECT_EQ(to_vector<float2>(AxisSigned::Y_NEG), float2(0, -1));
|
||||
}
|
||||
|
||||
TEST(math_rotation_types, AxisConvertToVec)
|
||||
{
|
||||
EXPECT_EQ(to_vector<float3>(Axis::X), float3(1, 0, 0));
|
||||
EXPECT_EQ(to_vector<float3>(Axis::Y), float3(0, 1, 0));
|
||||
EXPECT_EQ(to_vector<float3>(Axis::Z), float3(0, 0, 1));
|
||||
}
|
||||
|
||||
TEST(math_rotation_types, Euler3Order)
|
||||
{
|
||||
/* Asserts those match.
|
||||
|
||||
Reference in New Issue
Block a user