Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "BKE_attribute.hh" | |||||
| #include "BKE_attribute_math.hh" | #include "BKE_attribute_math.hh" | ||||
| #include "BLI_task.hh" | #include "BLI_task.hh" | ||||
| #include "NOD_socket_search_link.hh" | #include "NOD_socket_search_link.hh" | ||||
| namespace blender::nodes { | namespace blender::nodes { | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | if (type && *type != CD_PROP_STRING) { | ||||
| params.add_item(IFACE_("Value"), [node_type, type](LinkSearchOpParams ¶ms) { | params.add_item(IFACE_("Value"), [node_type, type](LinkSearchOpParams ¶ms) { | ||||
| bNode &node = params.add_node(node_type); | bNode &node = params.add_node(node_type); | ||||
| node.custom2 = *type; | node.custom2 = *type; | ||||
| params.update_and_connect_available_socket(node, "Value"); | params.update_and_connect_available_socket(node, "Value"); | ||||
| }); | }); | ||||
| } | } | ||||
| } | } | ||||
| static StringRefNull identifier_suffix(eCustomDataType data_type) | |||||
| { | |||||
| switch (data_type) { | |||||
| case CD_PROP_BOOL: | |||||
| return "Bool"; | |||||
| case CD_PROP_FLOAT: | |||||
| return "Float"; | |||||
| case CD_PROP_INT32: | |||||
| return "Int"; | |||||
| case CD_PROP_COLOR: | |||||
| return "Color"; | |||||
| case CD_PROP_FLOAT3: | |||||
| return "Vector"; | |||||
| default: | |||||
| BLI_assert_unreachable(); | |||||
| return ""; | |||||
| } | |||||
| } | |||||
| static void node_geo_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| const bNode &node = params.node(); | const bNode &node = params.node(); | ||||
| const eAttrDomain domain = eAttrDomain(node.custom1); | const eAttrDomain domain = eAttrDomain(node.custom1); | ||||
| const eCustomDataType data_type = eCustomDataType(node.custom2); | const eCustomDataType data_type = eCustomDataType(node.custom2); | ||||
| Field<int> index_field = params.extract_input<Field<int>>("Index"); | Field<int> index_field = params.extract_input<Field<int>>("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); | ||||
| static const std::string identifier = "Value_" + identifier_suffix(data_type); | const std::string identifier = "Value_" + bke::type_name_identifier<T>(); | ||||
| Field<T> value_field = params.extract_input<Field<T>>(identifier); | Field<T> value_field = params.extract_input<Field<T>>(identifier); | ||||
| Field<T> output_field{std::make_shared<FieldAtIndexInput>( | Field<T> output_field{std::make_shared<FieldAtIndexInput>( | ||||
| std::move(index_field), std::move(value_field), domain)}; | std::move(index_field), std::move(value_field), domain)}; | ||||
| params.set_output(identifier, std::move(output_field)); | params.set_output(identifier, std::move(output_field)); | ||||
| }); | }); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_geo_field_at_index_cc | } // namespace blender::nodes::node_geo_field_at_index_cc | ||||
| Show All 16 Lines | |||||