Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/BKE_attribute_math.hh
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| #pragma once | #pragma once | ||||
| #include "BLI_array.hh" | #include "BLI_array.hh" | ||||
| #include "BLI_color.hh" | #include "BLI_color.hh" | ||||
| #include "BLI_cpp_type.hh" | |||||
| #include "BLI_math_vector.h" | #include "BLI_math_vector.h" | ||||
| #include "BLI_math_vector.hh" | #include "BLI_math_vector.hh" | ||||
| #include "DNA_customdata_types.h" | #include "DNA_customdata_types.h" | ||||
| #include "FN_cpp_type.hh" | |||||
| namespace blender::attribute_math { | namespace blender::attribute_math { | ||||
| using fn::CPPType; | |||||
| /** | /** | ||||
| * Utility function that simplifies calling a templated function based on a custom data type. | * Utility function that simplifies calling a templated function based on a custom data type. | ||||
| */ | */ | ||||
| template<typename Func> | template<typename Func> | ||||
| inline void convert_to_static_type(const CustomDataType data_type, const Func &func) | inline void convert_to_static_type(const CustomDataType data_type, const Func &func) | ||||
| { | { | ||||
| switch (data_type) { | switch (data_type) { | ||||
| case CD_PROP_FLOAT: | case CD_PROP_FLOAT: | ||||
| Show All 19 Lines | case CD_PROP_COLOR: | ||||
| break; | break; | ||||
| default: | default: | ||||
| BLI_assert_unreachable(); | BLI_assert_unreachable(); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| template<typename Func> | template<typename Func> | ||||
| inline void convert_to_static_type(const fn::CPPType &cpp_type, const Func &func) | inline void convert_to_static_type(const CPPType &cpp_type, const Func &func) | ||||
| { | { | ||||
| if (cpp_type.is<float>()) { | if (cpp_type.is<float>()) { | ||||
| func(float()); | func(float()); | ||||
| } | } | ||||
| else if (cpp_type.is<float2>()) { | else if (cpp_type.is<float2>()) { | ||||
| func(float2()); | func(float2()); | ||||
| } | } | ||||
| else if (cpp_type.is<float3>()) { | else if (cpp_type.is<float3>()) { | ||||
| ▲ Show 20 Lines • Show All 342 Lines • Show Last 20 Lines | |||||