Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc
| Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | attribute_math::convert_to_static_type(*type_, [&](auto dummy) { | ||||
| }); | }); | ||||
| output_array = VArray<T>::ForContainer(std::move(dst_array)); | output_array = VArray<T>::ForContainer(std::move(dst_array)); | ||||
| }); | }); | ||||
| return output_array; | return output_array; | ||||
| } | } | ||||
| }; | }; | ||||
| 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 = static_cast<eAttrDomain>(node.custom1); | const eAttrDomain domain = static_cast<eAttrDomain>(node.custom1); | ||||
| const eCustomDataType data_type = static_cast<eCustomDataType>(node.custom2); | const eCustomDataType data_type = static_cast<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 socket_identifier = "Value_" + attribute_math::DefaultAttributeName<T>(); | ||||
| Field<T> value_field = params.extract_input<Field<T>>(identifier); | Field<T> value_field = params.extract_input<Field<T>>(socket_identifier); | ||||
| Field<T> output_field{ | Field<T> output_field{ | ||||
| std::make_shared<FieldAtIndex>(std::move(index_field), std::move(value_field), domain)}; | std::make_shared<FieldAtIndex>(std::move(index_field), std::move(value_field), domain)}; | ||||
| params.set_output(identifier, std::move(output_field)); | params.set_output(socket_identifier, std::move(output_field)); | ||||
| }); | }); | ||||
| } | } | ||||
| } // namespace blender::nodes::node_geo_field_at_index_cc | } // namespace blender::nodes::node_geo_field_at_index_cc | ||||
| void register_node_type_geo_field_at_index() | void register_node_type_geo_field_at_index() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_field_at_index_cc; | namespace file_ns = blender::nodes::node_geo_field_at_index_cc; | ||||
| Show All 11 Lines | |||||