Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_math_vector.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 <cmath> | #include <cmath> | ||||
| #include <type_traits> | #include <type_traits> | ||||
| #include "BLI_math_base_safe.h" | #include "BLI_math_base.hh" | ||||
| #include "BLI_math_vec_types.hh" | #include "BLI_math_vec_types.hh" | ||||
| #include "BLI_span.hh" | #include "BLI_span.hh" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| namespace blender::math { | namespace blender::math { | ||||
| #ifndef NDEBUG | #ifndef NDEBUG | ||||
| # define BLI_ASSERT_UNIT(v) \ | # define BLI_ASSERT_UNIT(v) \ | ||||
| ▲ Show 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | for (int i = 0; i < nv;) { | ||||
| ++i; | ++i; | ||||
| if (i < nv) { | if (i < nv) { | ||||
| v_curr = &poly[i]; | v_curr = &poly[i]; | ||||
| } | } | ||||
| } | } | ||||
| return n; | return n; | ||||
| } | } | ||||
| template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))> | template<typename T, typename FactorT, int Size, BLI_ENABLE_IF((is_math_float_type<FactorT>))> | ||||
| inline vec_base<T, Size> interpolate(const vec_base<T, Size> &a, | inline vec_base<T, Size> interpolate(const vec_base<T, Size> &a, | ||||
| const vec_base<T, Size> &b, | const vec_base<T, Size> &b, | ||||
| const T &t) | const FactorT &t) | ||||
| { | { | ||||
| return a * (1 - t) + b * t; | return a * (1 - t) + b * t; | ||||
| } | } | ||||
| template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))> | template<typename T, int Size, BLI_ENABLE_IF((is_math_float_type<T>))> | ||||
| inline vec_base<T, Size> midpoint(const vec_base<T, Size> &a, const vec_base<T, Size> &b) | inline vec_base<T, Size> midpoint(const vec_base<T, Size> &a, const vec_base<T, Size> &b) | ||||
| { | { | ||||
| return (a + b) * 0.5; | return (a + b) * 0.5; | ||||
| Show All 35 Lines | |||||