diff --git a/source/blender/blenlib/BLI_math_basis_types.hh b/source/blender/blenlib/BLI_math_basis_types.hh index 4bb4afbd3fd..f418eaf053c 100644 --- a/source/blender/blenlib/BLI_math_basis_types.hh +++ b/source/blender/blenlib/BLI_math_basis_types.hh @@ -321,9 +321,9 @@ template<> inline AxisSigned abs(const AxisSigned &axis) /** Create basis vector. */ template 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; } diff --git a/source/blender/blenlib/tests/BLI_math_rotation_types_test.cc b/source/blender/blenlib/tests/BLI_math_rotation_types_test.cc index d6dd329ab8c..011e1887251 100644 --- a/source/blender/blenlib/tests/BLI_math_rotation_types_test.cc +++ b/source/blender/blenlib/tests/BLI_math_rotation_types_test.cc @@ -60,6 +60,13 @@ TEST(math_rotation_types, AxisSignedConvertToVec) EXPECT_EQ(to_vector(AxisSigned::Y_NEG), float2(0, -1)); } +TEST(math_rotation_types, AxisConvertToVec) +{ + EXPECT_EQ(to_vector(Axis::X), float3(1, 0, 0)); + EXPECT_EQ(to_vector(Axis::Y), float3(0, 1, 0)); + EXPECT_EQ(to_vector(Axis::Z), float3(0, 0, 1)); +} + TEST(math_rotation_types, Euler3Order) { /* Asserts those match.