Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/BKE_attribute.hh
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| #pragma once | #pragma once | ||||
| #include <optional> | #include <optional> | ||||
| #include "BLI_color.hh" | #include "BLI_color.hh" | ||||
| #include "BLI_function_ref.hh" | #include "BLI_function_ref.hh" | ||||
| #include "BLI_generic_span.hh" | #include "BLI_generic_span.hh" | ||||
| #include "BLI_generic_virtual_array.hh" | #include "BLI_generic_virtual_array.hh" | ||||
| #include "BLI_math_vec_types.hh" | #include "BLI_math_vec_types.hh" | ||||
| #include "BLI_set.hh" | #include "BLI_set.hh" | ||||
| #include "BKE_anonymous_attribute.hh" | #include "BKE_anonymous_attribute.hh" | ||||
| #include "BKE_attribute.h" | #include "BKE_attribute.h" | ||||
| #include "BKE_attribute_math.hh" | |||||
| struct Mesh; | struct Mesh; | ||||
| struct PointCloud; | struct PointCloud; | ||||
| namespace blender::fn { | namespace blender::fn { | ||||
| class MultiFunction; | class MultiFunction; | ||||
| class GField; | class GField; | ||||
| } // namespace blender::fn | } // namespace blender::fn | ||||
| ▲ Show 20 Lines • Show All 873 Lines • ▼ Show 20 Lines | |||||
| * processing or copying. Anonymous attributes can be removed when they no longer have any | * processing or copying. Anonymous attributes can be removed when they no longer have any | ||||
| * references. | * references. | ||||
| */ | */ | ||||
| inline bool AttributeIDRef::should_be_kept() const | inline bool AttributeIDRef::should_be_kept() const | ||||
| { | { | ||||
| return this->is_named() || BKE_anonymous_attribute_id_has_strong_references(anonymous_id_); | return this->is_named() || BKE_anonymous_attribute_id_has_strong_references(anonymous_id_); | ||||
| } | } | ||||
| /** \} */ | |||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Attribute type name collection. | |||||
| * | |||||
| * This is just basic name for indexing or printing. | |||||
| * \{ */ | |||||
| /* type_name_identifier can using in scope with attribute type info or with only eCustomDataType. | |||||
| More often than, type_name_identifier must accept eCustomDataType as a non-constant value, which | |||||
| is why it is used as a call parameter. */ | |||||
| inline StringRef type_name_identifier(const eCustomDataType attribute_type) | |||||
| { | |||||
| StringRef name; | |||||
| attribute_math::convert_to_static_type(attribute_type, [&](auto dummy) { | |||||
| using T = decltype(dummy); | |||||
| name = type_name_identifier<T>(); | |||||
| }); | |||||
| return name; | |||||
| } | |||||
| template<typename T> inline StringRef type_name_identifier() | |||||
| { | |||||
| BLI_assert_unreachable(); | |||||
| return ""; | |||||
| } | |||||
| template<> inline StringRef type_name_identifier<bool>() | |||||
| { | |||||
| return "Bool"; | |||||
| } | |||||
| template<> inline StringRef type_name_identifier<int>() | |||||
| { | |||||
| return "Int"; | |||||
| } | |||||
| template<> inline StringRef type_name_identifier<float>() | |||||
| { | |||||
| return "Float"; | |||||
| } | |||||
| template<> inline StringRef type_name_identifier<float2>() | |||||
| { | |||||
| return "Vector 2"; | |||||
| } | |||||
| template<> inline StringRef type_name_identifier<float3>() | |||||
| { | |||||
| return "Vector"; | |||||
| } | |||||
| template<> inline StringRef type_name_identifier<ColorGeometry4f>() | |||||
| { | |||||
| return "Color"; | |||||
| } | |||||
| template<> inline StringRef type_name_identifier<std::string>() | |||||
| { | |||||
| return "String"; | |||||
| } | |||||
| /* | |||||
| * You can map these names to hint names to switch socket types, | |||||
| * but be sure you don't have a Byte Color socket. | |||||
| */ | |||||
| template<> inline StringRef type_name_identifier<ColorGeometry4b>() | |||||
| { | |||||
| return "Byte Color"; | |||||
| } | |||||
| /** \} */ | |||||
| } // namespace blender::bke | } // namespace blender::bke | ||||