diff options
Diffstat (limited to 'source/blender/blenkernel/intern/customdata.cc')
-rw-r--r-- | source/blender/blenkernel/intern/customdata.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index b348e18a6a8..251d73dc315 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -18,9 +18,11 @@ #include "DNA_meshdata_types.h" #include "BLI_bitmap.h" +#include "BLI_color.hh" #include "BLI_endian_switch.h" #include "BLI_math.h" #include "BLI_math_color_blend.h" +#include "BLI_math_vector.hh" #include "BLI_mempool.h" #include "BLI_path_util.h" #include "BLI_string.h" @@ -5234,3 +5236,56 @@ void CustomData_debug_info_from_layers(const CustomData *data, const char *inden } #endif /* NDEBUG */ + +namespace blender::bke { + +const blender::CPPType *custom_data_type_to_cpp_type(const CustomDataType type) +{ + switch (type) { + case CD_PROP_FLOAT: + return &CPPType::get<float>(); + case CD_PROP_FLOAT2: + return &CPPType::get<float2>(); + case CD_PROP_FLOAT3: + return &CPPType::get<float3>(); + case CD_PROP_INT32: + return &CPPType::get<int>(); + case CD_PROP_COLOR: + return &CPPType::get<ColorGeometry4f>(); + case CD_PROP_BOOL: + return &CPPType::get<bool>(); + case CD_PROP_INT8: + return &CPPType::get<int8_t>(); + default: + return nullptr; + } + return nullptr; +} + +CustomDataType cpp_type_to_custom_data_type(const blender::CPPType &type) +{ + if (type.is<float>()) { + return CD_PROP_FLOAT; + } + if (type.is<float2>()) { + return CD_PROP_FLOAT2; + } + if (type.is<float3>()) { + return CD_PROP_FLOAT3; + } + if (type.is<int>()) { + return CD_PROP_INT32; + } + if (type.is<ColorGeometry4f>()) { + return CD_PROP_COLOR; + } + if (type.is<bool>()) { + return CD_PROP_BOOL; + } + if (type.is<int8_t>()) { + return CD_PROP_INT8; + } + return static_cast<CustomDataType>(-1); +} + +} // namespace blender::bke |