Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_math_vec_types.hh
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2022 Blender Foundation. */ | * Copyright 2022 Blender Foundation. */ | ||||
| #pragma once | #pragma once | ||||
| /** \file | /** \file | ||||
| * \ingroup bli | * \ingroup bli | ||||
| */ | */ | ||||
| #include <array> | #include <array> | ||||
| #include <cmath> | #include <cmath> | ||||
| #include <iostream> | #include <iostream> | ||||
| #include <type_traits> | #include <type_traits> | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
HooglyBoogly: I think it's better to avoid including `BLI_math_base.h` in the C++ header, to make a clear… | |||||
| namespace blender { | namespace blender { | ||||
| /* clang-format off */ | /* clang-format off */ | ||||
| template<typename T> | template<typename T> | ||||
| using as_uint_type = std::conditional_t<sizeof(T) == sizeof(uint8_t), uint8_t, | using as_uint_type = std::conditional_t<sizeof(T) == sizeof(uint8_t), uint8_t, | ||||
| std::conditional_t<sizeof(T) == sizeof(uint16_t), uint16_t, | std::conditional_t<sizeof(T) == sizeof(uint16_t), uint16_t, | ||||
| std::conditional_t<sizeof(T) == sizeof(uint32_t), uint32_t, | std::conditional_t<sizeof(T) == sizeof(uint32_t), uint32_t, | ||||
| ▲ Show 20 Lines • Show All 573 Lines • ▼ Show 20 Lines | for (int i = 0; i < Size; i++) { | ||||
| stream << ", "; | stream << ", "; | ||||
| } | } | ||||
| } | } | ||||
| stream << ")"; | stream << ")"; | ||||
| return stream; | return stream; | ||||
| } | } | ||||
| }; | }; | ||||
| namespace math { | |||||
| template<typename T> struct AssertUnitEpsilon { | |||||
| /** \note Copy of BLI_ASSERT_UNIT_EPSILON_DB to avoid dragging the entire header. */ | |||||
| static constexpr T value = T(0.0002); | |||||
| }; | |||||
| } // namespace math | |||||
| using char3 = blender::vec_base<int8_t, 3>; | using char3 = blender::vec_base<int8_t, 3>; | ||||
| using uchar3 = blender::vec_base<uint8_t, 3>; | using uchar3 = blender::vec_base<uint8_t, 3>; | ||||
| using uchar4 = blender::vec_base<uint8_t, 4>; | using uchar4 = blender::vec_base<uint8_t, 4>; | ||||
| using int2 = vec_base<int32_t, 2>; | using int2 = vec_base<int32_t, 2>; | ||||
| using int3 = vec_base<int32_t, 3>; | using int3 = vec_base<int32_t, 3>; | ||||
| using int4 = vec_base<int32_t, 4>; | using int4 = vec_base<int32_t, 4>; | ||||
| Show All 21 Lines | |||||
I think it's better to avoid including BLI_math_base.h in the C++ header, to make a clear separation between the two. I tried to keep it that way with earlier refactors to this file anyway.