Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc
| Show First 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | bool is_equal_to(const fn::FieldNode &other) const override | ||||
| if (const TotalFieldInput *other_field = dynamic_cast<const TotalFieldInput *>(&other)) { | if (const TotalFieldInput *other_field = dynamic_cast<const TotalFieldInput *>(&other)) { | ||||
| return input_ == other_field->input_ && group_index_ == other_field->group_index_ && | return input_ == other_field->input_ && group_index_ == other_field->group_index_ && | ||||
| source_domain_ == other_field->source_domain_; | source_domain_ == other_field->source_domain_; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| }; | }; | ||||
| template<typename T> std::string identifier_suffix() | |||||
| { | |||||
| if constexpr (std::is_same_v<T, int>) { | |||||
| return "Int"; | |||||
| } | |||||
| if constexpr (std::is_same_v<T, float>) { | |||||
| return "Float"; | |||||
| } | |||||
| if constexpr (std::is_same_v<T, float3>) { | |||||
| return "Vector"; | |||||
| } | |||||
| } | |||||
| static void node_geo_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| const NodeAccumulateField &storage = node_storage(params.node()); | const NodeAccumulateField &storage = node_storage(params.node()); | ||||
| const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); | const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type); | ||||
| const eAttrDomain source_domain = static_cast<eAttrDomain>(storage.domain); | const eAttrDomain source_domain = static_cast<eAttrDomain>(storage.domain); | ||||
| Field<int> group_index_field = params.extract_input<Field<int>>("Group Index"); | Field<int> group_index_field = params.extract_input<Field<int>>("Group Index"); | ||||
| attribute_math::convert_to_static_type(data_type, [&](auto dummy) { | attribute_math::convert_to_static_type(data_type, [&](auto dummy) { | ||||
| using T = decltype(dummy); | using T = decltype(dummy); | ||||
| if constexpr (std::is_same_v<T, int> || std::is_same_v<T, float> || | if constexpr (std::is_same_v<T, int> || std::is_same_v<T, float> || | ||||
| std::is_same_v<T, float3>) { | std::is_same_v<T, float3>) { | ||||
| const std::string suffix = " " + identifier_suffix<T>(); | const std::string suffix = " " + attribute_math::default_name<T>(); | ||||
| Field<T> input_field = params.extract_input<Field<T>>("Value" + suffix); | Field<T> input_field = params.extract_input<Field<T>>("Value" + suffix); | ||||
| if (params.output_is_required("Leading" + suffix)) { | if (params.output_is_required("Leading" + suffix)) { | ||||
| params.set_output( | params.set_output( | ||||
| "Leading" + suffix, | "Leading" + suffix, | ||||
| Field<T>{std::make_shared<AccumulateFieldInput<T>>( | Field<T>{std::make_shared<AccumulateFieldInput<T>>( | ||||
| source_domain, input_field, group_index_field, AccumulationMode::Leading)}); | source_domain, input_field, group_index_field, AccumulationMode::Leading)}); | ||||
| } | } | ||||
| if (params.output_is_required("Trailing" + suffix)) { | if (params.output_is_required("Trailing" + suffix)) { | ||||
| Show All 32 Lines | |||||