Blender  V3.3
node_geo_curve_reverse.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include "BLI_task.hh"
4 
5 #include "BKE_curves.hh"
6 
7 #include "node_geometry_util.hh"
8 
10 
12 {
13  b.add_input<decl::Geometry>(N_("Curve")).supported_type(GEO_COMPONENT_TYPE_CURVE);
14  b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field();
15  b.add_output<decl::Geometry>(N_("Curve"));
16 }
17 
19 {
20  GeometrySet geometry_set = params.extract_input<GeometrySet>("Curve");
21 
22  geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
23  if (!geometry_set.has_curves()) {
24  return;
25  }
26 
27  Field<bool> selection_field = params.get_input<Field<bool>>("Selection");
30  const int domain_size = component.attribute_domain_size(ATTR_DOMAIN_CURVE);
31 
32  fn::FieldEvaluator selection_evaluator{field_context, domain_size};
33  selection_evaluator.add(selection_field);
34  selection_evaluator.evaluate();
35  const IndexMask selection = selection_evaluator.get_evaluated_as_mask(0);
36  if (selection.is_empty()) {
37  return;
38  }
39 
40  Curves &curves_id = *geometry_set.get_curves_for_write();
42  curves.reverse_curves(selection);
43  });
44 
45  params.set_output("Curve", std::move(geometry_set));
46 }
47 
48 } // namespace blender::nodes::node_geo_curve_reverse_cc
49 
51 {
53 
54  static bNodeType ntype;
58  nodeRegisterType(&ntype);
59 }
@ ATTR_DOMAIN_CURVE
Definition: BKE_attribute.h:31
Low-level operations for curves.
@ GEO_COMPONENT_TYPE_CURVE
#define GEO_NODE_REVERSE_CURVE
Definition: BKE_node.h:1437
#define NODE_CLASS_GEOMETRY
Definition: BKE_node.h:359
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
static uint8 component(Color32 c, uint i)
Definition: ColorBlock.cpp:108
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
bool is_empty() const
static CurvesGeometry & wrap(::CurvesGeometry &dna_struct)
Definition: BKE_curves.hh:138
int add(GField field, GVArray *varray_ptr)
Definition: field.cc:731
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
static void node_declare(NodeDeclarationBuilder &b)
static void node_geo_exec(GeoNodeExecParams params)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_geo_curve_reverse()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
CurvesGeometry geometry
Curves * get_curves_for_write()
const GeometryComponent * get_component_for_read(GeometryComponentType component_type) const
void modify_geometry_sets(ForeachSubGeometryCallback callback)
bool has_curves() const
Defines a node type.
Definition: BKE_node.h:226
NodeGeometryExecFunction geometry_node_execute
Definition: BKE_node.h:316
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)