Blender V5.3
node_geo_tool_set_face_set.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
5#include "DNA_mesh_types.h"
6
8
10
12
14{
15 b.use_custom_socket_order();
16 b.allow_any_socket_order();
17 b.add_input<decl::Geometry>("Mesh"_ustr);
18 b.add_output<decl::Geometry>("Mesh"_ustr)
19 .align_with_previous()
20 .description("Mesh to override the face set attribute on");
21 b.add_input<decl::Bool>("Selection"_ustr)
22 .default_value(true)
23 .hide_value()
24 .evaluated_geometry_field();
25 b.add_input<decl::Int>("Face Set"_ustr).hide_value().evaluated_geometry_field();
26}
27
29{
30 if (face_set.depends_on_input()) {
31 return false;
32 }
34}
35
37{
38 if (!check_tool_context_and_error(params)) {
39 return;
40 }
41 const Field<bool> selection = params.extract_input<Field<bool>>("Selection"_ustr);
42 const Field<int> face_set = params.extract_input<Field<int>>("Face Set"_ustr);
43 const bool is_zero = is_constant_zero(face_set);
44
45 GeometrySet geometry = params.extract_input<GeometrySet>("Mesh"_ustr);
47 if (Mesh *mesh = geometry.get_mesh_for_write()) {
48 if (is_zero) {
49 mesh->attributes_for_write().remove(".sculpt_face_set");
50 }
51 else {
53 ".sculpt_face_set",
54 AttrDomain::Face,
55 selection,
56 face_set);
57 }
58 }
59 });
60 params.set_output("Mesh"_ustr, std::move(geometry));
61}
62
63static void node_register()
64{
65 static bke::bNodeType ntype;
66 geo_node_type_base(&ntype, "GeometryNodeToolSetFaceSet"_ustr, GEO_NODE_TOOL_SET_FACE_SET);
67 ntype.ui_name = "Set Face Set";
68 ntype.ui_description = "Set sculpt face set values for faces";
69 ntype.enum_name_legacy = "TOOL_SET_FACE_SET";
71 ntype.declare = node_declare;
75}
77
78} // namespace blender::nodes::node_geo_tool_set_face_set_cc
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:492
#define GEO_NODE_TOOL_SET_FACE_SET
#define NOD_REGISTER_NODE(REGISTER_FUNC)
T extract_input(const UString identifier)
void set_output(const UString identifier, T &&value)
bool is_zero(float3x3 a)
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 evaluate_constant_field(const GField &field, void *r_value)
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
static void node_declare(NodeDeclarationBuilder &b)
static bool is_constant_zero(const Field< int > &face_set)
static void node_geo_exec(GeoNodeExecParams params)
void search_link_ops_for_tool_node(GatherLinkSearchOpParams &params)
bool check_tool_context_and_error(GeoNodeExecParams &params)
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
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
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:409
NodeDeclareFunction declare
Definition BKE_node.hh:393