Blender V5.3
node_geo_set_point_radius.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
8
10
12
14{
15 b.use_custom_socket_order();
16 b.allow_any_socket_order();
17 b.add_input<decl::Geometry>("Points"_ustr)
19 .description("Points to set the radius of");
20 b.add_output<decl::Geometry>("Points"_ustr).propagate_all_geometry().align_with_previous();
21 b.add_input<decl::Bool>("Selection"_ustr)
22 .default_value(true)
23 .hide_value()
24 .evaluated_geometry_field();
25 b.add_input<decl::Float>("Radius"_ustr)
26 .default_value(0.05f)
27 .min(0.0f)
29 .evaluated_geometry_field();
30}
31
33{
34 GeometrySet geometry_set = params.extract_input<GeometrySet>("Points"_ustr);
35 const Field<bool> selection = params.extract_input<Field<bool>>("Selection"_ustr);
36 const Field<float> radius = params.extract_input<Field<float>>("Radius"_ustr);
37
38 geometry::foreach_real_geometry(geometry_set, [&](GeometrySet &geometry_set) {
39 if (PointCloud *pointcloud = geometry_set.get_pointcloud_for_write()) {
40 bke::try_capture_field_on_geometry(pointcloud->attributes_for_write(),
41 bke::PointCloudFieldContext(*pointcloud),
42 "radius",
44 selection,
45 radius);
46 }
47 });
48
49 params.set_output("Points"_ustr, std::move(geometry_set));
50}
51
52static void node_register()
53{
54 static bke::bNodeType ntype;
55
56 geo_node_type_base(&ntype, "GeometryNodeSetPointRadius"_ustr, GEO_NODE_SET_POINT_RADIUS);
57 ntype.ui_name = "Set Point Radius";
58 ntype.ui_description = "Set the display size of point cloud points";
59 ntype.enum_name_legacy = "SET_POINT_RADIUS";
62 ntype.declare = node_declare;
64}
66
67} // namespace blender::nodes::node_geo_set_point_radius_cc
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:492
#define GEO_NODE_SET_POINT_RADIUS
#define NOD_REGISTER_NODE(REGISTER_FUNC)
T extract_input(const UString identifier)
void set_output(const UString identifier, T &&value)
bool try_capture_field_on_geometry(MutableAttributeAccessor attributes, const fn::FieldContext &field_context, const StringRef name, AttrDomain domain, const fn::Field< bool > &selection, const fn::GField &field)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
@ PROP_DISTANCE
Definition RNA_types.hh:313
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
PointCloud * get_pointcloud_for_write()
Defines a node type.
Definition BKE_node.hh:265
std::string ui_description
Definition BKE_node.hh:271
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:385
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393