Blender V4.3
node_geo_curve_topology_curve_of_point.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 "BKE_curves.hh"
6
8
10
12{
13 b.add_input<decl::Int>("Point Index")
14 .implicit_field(implicit_field_inputs::index)
15 .description("The control point to retrieve data from");
16 b.add_output<decl::Int>("Curve Index")
17 .field_source_reference_all()
18 .description("The curve the control point is part of");
19 b.add_output<decl::Int>("Index in Curve")
20 .field_source_reference_all()
21 .description("How far along the control point is along its curve");
22}
23
25 public:
26 CurveOfPointInput() : bke::CurvesFieldInput(CPPType::get<int>(), "Point Curve Index")
27 {
29 }
30
32 const AttrDomain domain,
33 const IndexMask & /*mask*/) const final
34 {
35 if (domain != AttrDomain::Point) {
36 return {};
37 }
38 return VArray<int>::ForContainer(curves.point_to_curve_map());
39 }
40
41 uint64_t hash() const override
42 {
43 return 413209687345908697;
44 }
45
46 bool is_equal_to(const fn::FieldNode &other) const override
47 {
48 return dynamic_cast<const CurveOfPointInput *>(&other) != nullptr;
49 }
50
51 std::optional<AttrDomain> preferred_domain(const bke::CurvesGeometry & /*curves*/) const final
52 {
53 return AttrDomain::Point;
54 }
55};
56
58 public:
59 PointIndexInCurveInput() : bke::CurvesFieldInput(CPPType::get<int>(), "Point Index in Curve")
60 {
62 }
63
65 const AttrDomain domain,
66 const IndexMask & /*mask*/) const final
67 {
68 if (domain != AttrDomain::Point) {
69 return {};
70 }
71 const Span<int> offsets = curves.offsets();
72 Array<int> point_to_curve_map = curves.point_to_curve_map();
74 curves.points_num(),
75 [offsets, point_to_curve_map = std::move(point_to_curve_map)](const int point_i) {
76 const int curve_i = point_to_curve_map[point_i];
77 return point_i - offsets[curve_i];
78 });
79 }
80
81 uint64_t hash() const final
82 {
83 return 9834765987345677;
84 }
85
86 bool is_equal_to(const fn::FieldNode &other) const final
87 {
88 return dynamic_cast<const PointIndexInCurveInput *>(&other) != nullptr;
89 }
90
91 std::optional<AttrDomain> preferred_domain(const bke::CurvesGeometry & /*curves*/) const override
92 {
93 return AttrDomain::Point;
94 }
95};
96
98{
99 const Field<int> point_index = params.extract_input<Field<int>>("Point Index");
100 if (params.output_is_required("Curve Index")) {
101 params.set_output(
102 "Curve Index",
103 Field<int>(std::make_shared<bke::EvaluateAtIndexInput>(
104 point_index, Field<int>(std::make_shared<CurveOfPointInput>()), AttrDomain::Point)));
105 }
106 if (params.output_is_required("Index in Curve")) {
107 params.set_output("Index in Curve",
108 Field<int>(std::make_shared<bke::EvaluateAtIndexInput>(
109 point_index,
110 Field<int>(std::make_shared<PointIndexInCurveInput>()),
111 AttrDomain::Point)));
112 }
113}
114
115static void node_register()
116{
117 static blender::bke::bNodeType ntype;
119 &ntype, GEO_NODE_CURVE_TOPOLOGY_CURVE_OF_POINT, "Curve of Point", NODE_CLASS_INPUT);
121 ntype.declare = node_declare;
123}
125
126} // namespace blender::nodes::node_geo_curve_topology_curve_of_point_cc
Low-level operations for curves.
#define NODE_CLASS_INPUT
Definition BKE_node.hh:404
#define NOD_REGISTER_NODE(REGISTER_FUNC)
static VArray ForContainer(ContainerT container)
static VArray ForFunc(const int64_t size, GetFunc get_func)
GVArray get_varray_for_context(const bke::CurvesGeometry &curves, const AttrDomain domain, const IndexMask &) const final
std::optional< AttrDomain > preferred_domain(const bke::CurvesGeometry &) const final
std::optional< AttrDomain > preferred_domain(const bke::CurvesGeometry &) const override
GVArray get_varray_for_context(const bke::CurvesGeometry &curves, const AttrDomain domain, const IndexMask &) const final
local_group_size(16, 16) .push_constant(Type b
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
void index(const bNode &, void *r_value)
void geo_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
unsigned __int64 uint64_t
Definition stdint.h:90
Defines a node type.
Definition BKE_node.hh:218
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:339
NodeDeclareFunction declare
Definition BKE_node.hh:347