Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_set_id.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" | ||||
| namespace blender::nodes::node_geo_set_id_cc { | namespace blender::nodes::node_geo_set_id_cc { | ||||
| static void geo_node_set_id_declare(NodeDeclarationBuilder &b) | static void node_declare(NodeDeclarationBuilder &b) | ||||
| { | { | ||||
| b.add_input<decl::Geometry>(N_("Geometry")); | b.add_input<decl::Geometry>(N_("Geometry")); | ||||
| b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field(); | b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field(); | ||||
| b.add_input<decl::Int>(N_("ID")).implicit_field(); | b.add_input<decl::Int>(N_("ID")).implicit_field(); | ||||
| b.add_output<decl::Geometry>(N_("Geometry")); | b.add_output<decl::Geometry>(N_("Geometry")); | ||||
| } | } | ||||
| static void set_id_in_component(GeometryComponent &component, | static void set_id_in_component(GeometryComponent &component, | ||||
| Show All 28 Lines | else { | ||||
| const VArray<int> &result_ids = id_evaluator.get_evaluated<int>(0); | const VArray<int> &result_ids = id_evaluator.get_evaluated<int>(0); | ||||
| OutputAttribute_Typed<int> id_attribute = component.attribute_try_get_for_output_only<int>( | OutputAttribute_Typed<int> id_attribute = component.attribute_try_get_for_output_only<int>( | ||||
| "id", ATTR_DOMAIN_POINT); | "id", ATTR_DOMAIN_POINT); | ||||
| result_ids.materialize(selection, id_attribute.as_span()); | result_ids.materialize(selection, id_attribute.as_span()); | ||||
| id_attribute.save(); | id_attribute.save(); | ||||
| } | } | ||||
| } | } | ||||
| static void geo_node_set_id_exec(GeoNodeExecParams params) | static void node_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry"); | ||||
| Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); | Field<bool> selection_field = params.extract_input<Field<bool>>("Selection"); | ||||
| Field<int> id_field = params.extract_input<Field<int>>("ID"); | Field<int> id_field = params.extract_input<Field<int>>("ID"); | ||||
| for (const GeometryComponentType type : {GEO_COMPONENT_TYPE_INSTANCES, | for (const GeometryComponentType type : {GEO_COMPONENT_TYPE_INSTANCES, | ||||
| GEO_COMPONENT_TYPE_MESH, | GEO_COMPONENT_TYPE_MESH, | ||||
| GEO_COMPONENT_TYPE_POINT_CLOUD, | GEO_COMPONENT_TYPE_POINT_CLOUD, | ||||
| Show All 10 Lines | |||||
| void register_node_type_geo_set_id() | void register_node_type_geo_set_id() | ||||
| { | { | ||||
| namespace file_ns = blender::nodes::node_geo_set_id_cc; | namespace file_ns = blender::nodes::node_geo_set_id_cc; | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| geo_node_type_base(&ntype, GEO_NODE_SET_ID, "Set ID", NODE_CLASS_GEOMETRY, 0); | geo_node_type_base(&ntype, GEO_NODE_SET_ID, "Set ID", NODE_CLASS_GEOMETRY, 0); | ||||
| ntype.geometry_node_execute = file_ns::geo_node_set_id_exec; | ntype.geometry_node_execute = file_ns::node_exec; | ||||
| ntype.declare = file_ns::geo_node_set_id_declare; | ntype.declare = file_ns::node_declare; | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||