Differential D15387 Diff 53306 source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "NOD_socket_search_link.hh" | #include "NOD_socket_search_link.hh" | ||||
| #include "BKE_attribute_math.hh" | |||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| namespace blender::nodes::node_geo_input_named_attribute_cc { | namespace blender::nodes::node_geo_input_named_attribute_cc { | ||||
| NODE_STORAGE_FUNCS(NodeGeometryInputNamedAttribute) | NODE_STORAGE_FUNCS(NodeGeometryInputNamedAttribute) | ||||
| static void node_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | static void node_geo_exec(GeoNodeExecParams params) | ||||
| if (!bke::allow_procedural_attribute_access(name)) { | if (!bke::allow_procedural_attribute_access(name)) { | ||||
| params.error_message_add(NodeWarningType::Info, TIP_(bke::no_procedural_access_message)); | params.error_message_add(NodeWarningType::Info, TIP_(bke::no_procedural_access_message)); | ||||
| params.set_default_remaining_outputs(); | params.set_default_remaining_outputs(); | ||||
| return; | return; | ||||
| } | } | ||||
| params.used_named_attribute(name, eNamedAttrUsage::Read); | params.used_named_attribute(name, eNamedAttrUsage::Read); | ||||
| switch (data_type) { | attribute_math::convert_to_static_type(data_type, [&](auto dummy) { | ||||
| case CD_PROP_FLOAT: | using T = decltype(dummy); | ||||
| params.set_output("Attribute_Float", AttributeFieldInput::Create<float>(std::move(name))); | const std::string socket_identifier = "Attribute_" + attribute_math::DefaultAttributeName<T>(); | ||||
| break; | params.set_output(socket_identifier, AttributeFieldInput::Create<T>(std::move(name))); | ||||
| case CD_PROP_FLOAT3: | }); | ||||
| params.set_output("Attribute_Vector", AttributeFieldInput::Create<float3>(std::move(name))); | |||||
| break; | |||||
| case CD_PROP_COLOR: | |||||
| params.set_output("Attribute_Color", | |||||
| AttributeFieldInput::Create<ColorGeometry4f>(std::move(name))); | |||||
| break; | |||||
| case CD_PROP_BOOL: | |||||
| params.set_output("Attribute_Bool", AttributeFieldInput::Create<bool>(std::move(name))); | |||||
| break; | |||||
| case CD_PROP_INT32: | |||||
| params.set_output("Attribute_Int", AttributeFieldInput::Create<int>(std::move(name))); | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| } // namespace blender::nodes::node_geo_input_named_attribute_cc | } // namespace blender::nodes::node_geo_input_named_attribute_cc | ||||
| void register_node_type_geo_input_named_attribute() | void register_node_type_geo_input_named_attribute() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_input_named_attribute_cc; | namespace file_ns = blender::nodes::node_geo_input_named_attribute_cc; | ||||
| Show All 15 Lines | |||||