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" | ||||
JacquesLucke: Including that here seems unnecessary. You might have to add it in `BLI_math_vector.hh` and… | |||||
| #ifdef WITH_GMP | #ifdef WITH_GMP | ||||
| # include "BLI_math_mpq.hh" | # include "BLI_math_mpq.hh" | ||||
| #endif | #endif | ||||
| namespace blender { | namespace blender { | ||||
| /* clang-format off */ | /* clang-format off */ | ||||
| ▲ Show 20 Lines • Show All 292 Lines • ▼ Show 20 Lines | vec_base &operator-=(const T &b) | ||||
| BLI_VEC_OP_IMPL_SELF(i, (*this)[i] -= b); | BLI_VEC_OP_IMPL_SELF(i, (*this)[i] -= b); | ||||
| } | } | ||||
| friend vec_base operator*(const vec_base &a, const vec_base &b) | friend vec_base operator*(const vec_base &a, const vec_base &b) | ||||
| { | { | ||||
| BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] * b[i]); | BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] * b[i]); | ||||
| } | } | ||||
| friend vec_base operator*(const vec_base &a, T b) | template<typename FactorT> friend vec_base operator*(const vec_base &a, FactorT b) | ||||
| { | { | ||||
| BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] * b); | BLI_VEC_OP_IMPL(ret, i, ret[i] = a[i] * b); | ||||
| } | } | ||||
| friend vec_base operator*(T a, const vec_base &b) | friend vec_base operator*(T a, const vec_base &b) | ||||
Done Inline ActionsThis same change could be applied to other operations here, but maybe it's better to just do it where necessary? HooglyBoogly: This same change could be applied to other operations here, but maybe it's better to just do it… | |||||
Not Done Inline ActionsDoing it when necessary is fine. Looks like this should replace the function above though. JacquesLucke: Doing it when necessary is fine.
Looks like this should replace the function above though. | |||||
| { | { | ||||
| return b * a; | return b * a; | ||||
| } | } | ||||
| vec_base &operator*=(T b) | vec_base &operator*=(T b) | ||||
| { | { | ||||
| BLI_VEC_OP_IMPL_SELF(i, (*this)[i] *= b); | BLI_VEC_OP_IMPL_SELF(i, (*this)[i] *= b); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 236 Lines • ▼ Show 20 Lines | |||||
| using float2 = vec_base<float, 2>; | using float2 = vec_base<float, 2>; | ||||
| using float3 = vec_base<float, 3>; | using float3 = vec_base<float, 3>; | ||||
| using float4 = vec_base<float, 4>; | using float4 = vec_base<float, 4>; | ||||
| using double2 = vec_base<double, 2>; | using double2 = vec_base<double, 2>; | ||||
| using double3 = vec_base<double, 3>; | using double3 = vec_base<double, 3>; | ||||
| using double4 = vec_base<double, 4>; | using double4 = vec_base<double, 4>; | ||||
| template<typename T> | |||||
| inline constexpr bool is_math_float_type = (std::is_floating_point_v<T> | |||||
| #ifdef WITH_GMP | |||||
| || std::is_same_v<T, mpq_class> | |||||
| #endif | |||||
| ); | |||||
| template<typename T> inline constexpr bool is_math_integral_type = std::is_integral_v<T>; | |||||
| } // namespace blender | } // namespace blender | ||||
Including that here seems unnecessary. You might have to add it in BLI_math_vector.hh and BLI_float4x4.hh though.