Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_attribute_remove.cc
| Show All 12 Lines | |||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| */ | */ | ||||
| #include "node_geometry_util.hh" | #include "node_geometry_util.hh" | ||||
| static bNodeSocketTemplate geo_node_attribute_remove_in[] = { | static bNodeSocketTemplate geo_node_attribute_remove_in[] = { | ||||
| {SOCK_GEOMETRY, N_("Geometry")}, | {SOCK_GEOMETRY, N_("Geometry")}, | ||||
| {SOCK_STRING, N_("Attribute")}, | {SOCK_STRING, | ||||
| N_("Attribute"), | |||||
| 0.0f, | |||||
| 0.0f, | |||||
| 0.0f, | |||||
| 1.0f, | |||||
| -1.0f, | |||||
| 1.0f, | |||||
| PROP_NONE, | |||||
| SOCK_MULTI_INPUT}, | |||||
| {-1, ""}, | {-1, ""}, | ||||
| }; | }; | ||||
| static bNodeSocketTemplate geo_node_attribute_remove_out[] = { | static bNodeSocketTemplate geo_node_attribute_remove_out[] = { | ||||
| {SOCK_GEOMETRY, N_("Geometry")}, | {SOCK_GEOMETRY, N_("Geometry")}, | ||||
| {-1, ""}, | {-1, ""}, | ||||
| }; | }; | ||||
| namespace blender::nodes { | namespace blender::nodes { | ||||
| static void remove_attribute(GeometryComponent &component, const GeoNodeExecParams ¶ms) | static void remove_attribute(GeometryComponent &component, GeoNodeExecParams ¶ms) | ||||
| { | { | ||||
| const std::string attribute_name = params.get_input<std::string>("Attribute"); | Vector<std::string> attribute_names = params.get_multi_input<std::string>("Attribute"); | ||||
HooglyBoogly: You wouldn't need to add a new `get_multi_input` function if you used `extract_input` in… | |||||
Done Inline ActionsThis check is not necessary. JacquesLucke: This check is not necessary. | |||||
| for(std::string attribute_name : attribute_names){ | |||||
| if (attribute_name.empty()) { | if (attribute_name.empty()) { | ||||
| return; | continue; | ||||
| } | } | ||||
| if (!component.attribute_try_delete(attribute_name)) { | if (!component.attribute_try_delete(attribute_name)) { | ||||
| params.error_message_add(NodeWarningType::Error, | params.error_message_add(NodeWarningType::Error, | ||||
| TIP_("Cannot delete attribute with name \"") + attribute_name + "\""); | TIP_("Cannot delete attribute with name \"") + attribute_name + "\""); | ||||
Done Inline ActionsThis should probably be continue. JacquesLucke: This should probably be `continue`. | |||||
| } | } | ||||
| } | } | ||||
| } | |||||
| static void geo_node_attribute_remove_exec(GeoNodeExecParams params) | static void geo_node_attribute_remove_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| geometry_set = geometry_set_realize_instances(geometry_set); | geometry_set = geometry_set_realize_instances(geometry_set); | ||||
| if (geometry_set.has<MeshComponent>()) { | if (geometry_set.has<MeshComponent>()) { | ||||
| Show All 20 Lines | |||||
You wouldn't need to add a new get_multi_input function if you used extract_input in geo_node_attribute_remove_exec and passed a span into this function.
I'd like to move in that direction anyway, since getting inputs twice will only add more overhead as we add more geometry component types