Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/BKE_attribute_math.hh
| Show First 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | |||||
| using DefaultPropatationMixer = typename DefaultPropatationMixerStruct<T>::type; | using DefaultPropatationMixer = typename DefaultPropatationMixerStruct<T>::type; | ||||
| /* Utility to get a good default mixer for a given type. This is `void` when there is no default | /* Utility to get a good default mixer for a given type. This is `void` when there is no default | ||||
| * mixer for the given type. */ | * mixer for the given type. */ | ||||
| template<typename T> using DefaultMixer = typename DefaultMixerStruct<T>::type; | template<typename T> using DefaultMixer = typename DefaultMixerStruct<T>::type; | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Attribute type name collection. | |||||
| * | |||||
| * This is just basic name for indexing or printing. | |||||
| * \{ */ | |||||
| /* DefaultName can using in scope with attribute type info or with only eCustomDataType. | |||||
| More often than, DefaultName must accept eCustomDataType as a non-constant value, which is why | |||||
| it is used as a call parameter. */ | |||||
| inline StringRefNull default_name(const eCustomDataType attribute_type) | |||||
HooglyBoogly: How about using `StringRef` instead of `StringRefNull`?
Also, maybe `type_name_identifier`… | |||||
| { | |||||
| StringRefNull name; | |||||
| convert_to_static_type(attribute_type, [&](auto dummy) { | |||||
Done Inline ActionsThese template specializations might make more sense in BKE_attribute.hh, they're not really math HooglyBoogly: These template specializations might make more sense in `BKE_attribute.hh`, they're not really… | |||||
| using T = decltype(dummy); | |||||
| name = default_name<T>(); | |||||
| }); | |||||
| return name; | |||||
| } | |||||
| template<typename T> inline StringRefNull default_name() | |||||
| { | |||||
| BLI_assert_unreachable(); | |||||
| return ""; | |||||
| } | |||||
| template<> inline StringRefNull default_name<bool>() | |||||
| { | |||||
| return "Bool"; | |||||
| } | |||||
| template<> inline StringRefNull default_name<int>() | |||||
| { | |||||
| return "Int"; | |||||
| } | |||||
| template<> inline StringRefNull default_name<float>() | |||||
| { | |||||
| return "Float"; | |||||
| } | |||||
| template<> inline StringRefNull default_name<float2>() | |||||
| { | |||||
| return "Vector 2"; | |||||
| } | |||||
| template<> inline StringRefNull default_name<float3>() | |||||
| { | |||||
| return "Vector"; | |||||
| } | |||||
| template<> inline StringRefNull default_name<ColorGeometry4f>() | |||||
| { | |||||
| return "Color"; | |||||
| } | |||||
| template<> inline StringRefNull default_name<ColorGeometry4b>() | |||||
| { | |||||
| return "Byte Color"; | |||||
| } | |||||
| /** \} */ | |||||
| } // namespace blender::attribute_math | } // namespace blender::attribute_math | ||||
How about using StringRef instead of StringRefNull?
Also, maybe type_name_identifier would be a clearer name? "Default" is a bit vague.