Blender V5.0
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")
18 .supported_type(GeometryComponent::Type::PointCloud)
19 .description("Points to set the radius of");
20 b.add_output<decl::Geometry>("Points").propagate_all().align_with_previous();
21 b.add_input<decl::Bool>("Selection").default_value(true).hide_value().field_on_all();
22 b.add_input<decl::Float>("Radius")
23 .default_value(0.05f)
24 .min(0.0f)
26 .field_on_all();
27}
28
30{
31 GeometrySet geometry_set = params.extract_input<GeometrySet>("Points");
32 const Field<bool> selection = params.extract_input<Field<bool>>("Selection");
33 const Field<float> radius = params.extract_input<Field<float>>("Radius");
34
35 geometry::foreach_real_geometry(geometry_set, [&](GeometrySet &geometry_set) {
36 if (PointCloud *pointcloud = geometry_set.get_pointcloud_for_write()) {
37 bke::try_capture_field_on_geometry(pointcloud->attributes_for_write(),
38 bke::PointCloudFieldContext(*pointcloud),
39 "radius",
41 selection,
42 radius);
43 }
44 });
45
46 params.set_output("Points", std::move(geometry_set));
47}
48
49static void node_register()
50{
51 static blender::bke::bNodeType ntype;
52
53 geo_node_type_base(&ntype, "GeometryNodeSetPointRadius", GEO_NODE_SET_POINT_RADIUS);
54 ntype.ui_name = "Set Point Radius";
55 ntype.ui_description = "Set the display size of point cloud points";
56 ntype.enum_name_legacy = "SET_POINT_RADIUS";
59 ntype.declare = node_declare;
61}
63
64} // namespace blender::nodes::node_geo_set_point_radius_cc
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:461
#define GEO_NODE_SET_POINT_RADIUS
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ PROP_DISTANCE
Definition RNA_types.hh:256
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
bool try_capture_field_on_geometry(MutableAttributeAccessor attributes, const fn::FieldContext &field_context, const StringRef attribute_id, AttrDomain domain, const fn::Field< bool > &selection, const fn::GField &field)
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)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
PointCloud * get_pointcloud_for_write()
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:354
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362