Differential D15387 Diff 53347 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) | ||||
| { | { | ||||
| b.add_input<decl::String>(N_("Name")).is_attribute_name(); | b.add_input<decl::String>(N_("Name")).is_attribute_name(); | ||||
| b.add_output<decl::Vector>(N_("Attribute"), "Attribute_Vector").field_source(); | b.add_output<decl::Vector>(N_("Attribute"), "Vector").field_source(); | ||||
| b.add_output<decl::Float>(N_("Attribute"), "Attribute_Float").field_source(); | b.add_output<decl::Float>(N_("Attribute"), "Float").field_source(); | ||||
| b.add_output<decl::Color>(N_("Attribute"), "Attribute_Color").field_source(); | b.add_output<decl::Color>(N_("Attribute"), "Color").field_source(); | ||||
| b.add_output<decl::Bool>(N_("Attribute"), "Attribute_Bool").field_source(); | b.add_output<decl::Bool>(N_("Attribute"), "Bool").field_source(); | ||||
| b.add_output<decl::Int>(N_("Attribute"), "Attribute_Int").field_source(); | b.add_output<decl::Int>(N_("Attribute"), "Int").field_source(); | ||||
| } | } | ||||
| static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | ||||
| { | { | ||||
| uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE); | uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE); | ||||
| } | } | ||||
| static void node_init(bNodeTree *UNUSED(tree), bNode *node) | static void node_init(bNodeTree *UNUSED(tree), bNode *node) | ||||
| ▲ Show 20 Lines • Show All 54 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))); | params.set_output(attribute_math::default_name<T>(), | ||||
| break; | 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 | |||||