Blender V4.5
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{
13 b.use_custom_socket_order();
14 b.allow_any_socket_order();
15 b.add_input<decl::Geometry>("Points").supported_type(GeometryComponent::Type::PointCloud);
16 b.add_output<decl::Geometry>("Points").propagate_all().align_with_previous();
17 b.add_input<decl::Bool>("Selection").default_value(true).hide_value().field_on_all();
18 b.add_input<decl::Float>("Radius")
19 .default_value(0.05f)
20 .min(0.0f)
22 .field_on_all();
23}
24
26{
27 GeometrySet geometry_set = params.extract_input<GeometrySet>("Points");
28 const Field<bool> selection = params.extract_input<Field<bool>>("Selection");
29 const Field<float> radius = params.extract_input<Field<float>>("Radius");
30
31 geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
32 if (PointCloud *pointcloud = geometry_set.get_pointcloud_for_write()) {
33 bke::try_capture_field_on_geometry(pointcloud->attributes_for_write(),
34 bke::PointCloudFieldContext(*pointcloud),
35 "radius",
37 selection,
38 radius);
39 }
40 });
41
42 params.set_output("Points", std::move(geometry_set));
43}
44
45static void node_register()
46{
47 static blender::bke::bNodeType ntype;
48
49 geo_node_type_base(&ntype, "GeometryNodeSetPointRadius", GEO_NODE_SET_POINT_RADIUS);
50 ntype.ui_name = "Set Point Radius";
51 ntype.ui_description = "Set the display size of point cloud points";
52 ntype.enum_name_legacy = "SET_POINT_RADIUS";
55 ntype.declare = node_declare;
57}
59
60} // namespace blender::nodes::node_geo_set_point_radius_cc
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:447
#define GEO_NODE_SET_POINT_RADIUS
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ PROP_DISTANCE
Definition RNA_types.hh:244
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2748
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)
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()
void modify_geometry_sets(ForeachSubGeometryCallback callback)
Defines a node type.
Definition BKE_node.hh:226
std::string ui_description
Definition BKE_node.hh:232
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:347
const char * enum_name_legacy
Definition BKE_node.hh:235
NodeDeclareFunction declare
Definition BKE_node.hh:355