Blender V4.3
node_geo_mesh_topology_edges_of_corner.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_mesh.hh"
6
7#include "BLI_task.hh"
8
10
12
14{
15 b.add_input<decl::Int>("Corner Index")
16 .implicit_field(implicit_field_inputs::index)
17 .description("The corner to retrieve data from. Defaults to the corner from the context");
18 b.add_output<decl::Int>("Next Edge Index")
19 .field_source_reference_all()
21 "The edge after the corner in the face, in the direction of increasing indices");
22 b.add_output<decl::Int>("Previous Edge Index")
23 .field_source_reference_all()
25 "The edge before the corner in the face, in the direction of decreasing indices");
26}
27
29 public:
30 CornerNextEdgeFieldInput() : bke::MeshFieldInput(CPPType::get<int>(), "Corner Next Edge")
31 {
33 }
34
36 const AttrDomain domain,
37 const IndexMask & /*mask*/) const final
38 {
39 if (domain != AttrDomain::Corner) {
40 return {};
41 }
42 return VArray<int>::ForSpan(mesh.corner_edges());
43 }
44
45 uint64_t hash() const final
46 {
47 return 1892753404495;
48 }
49
50 bool is_equal_to(const fn::FieldNode &other) const final
51 {
52 return dynamic_cast<const CornerNextEdgeFieldInput *>(&other) != nullptr;
53 }
54
55 std::optional<AttrDomain> preferred_domain(const Mesh & /*mesh*/) const final
56 {
57 return AttrDomain::Corner;
58 }
59};
60
62 public:
63 CornerPreviousEdgeFieldInput() : bke::MeshFieldInput(CPPType::get<int>(), "Corner Previous Edge")
64 {
66 }
67
69 const AttrDomain domain,
70 const IndexMask & /*mask*/) const final
71 {
72 if (domain != AttrDomain::Corner) {
73 return {};
74 }
75 const OffsetIndices faces = mesh.faces();
76 const Span<int> corner_edges = mesh.corner_edges();
77 const Span<int> corner_to_face = mesh.corner_to_face_map();
79 corner_edges.size(), [faces, corner_edges, corner_to_face](const int corner) {
80 return corner_edges[bke::mesh::face_corner_prev(faces[corner_to_face[corner]], corner)];
81 });
82 }
83
84 uint64_t hash() const final
85 {
86 return 987298345762465;
87 }
88
89 bool is_equal_to(const fn::FieldNode &other) const final
90 {
91 return dynamic_cast<const CornerPreviousEdgeFieldInput *>(&other) != nullptr;
92 }
93
94 std::optional<AttrDomain> preferred_domain(const Mesh & /*mesh*/) const final
95 {
96 return AttrDomain::Corner;
97 }
98};
99
101{
102 const Field<int> corner_index = params.extract_input<Field<int>>("Corner Index");
103 if (params.output_is_required("Next Edge Index")) {
104 params.set_output("Next Edge Index",
105 Field<int>(std::make_shared<bke::EvaluateAtIndexInput>(
106 corner_index,
107 Field<int>(std::make_shared<CornerNextEdgeFieldInput>()),
108 AttrDomain::Corner)));
109 }
110 if (params.output_is_required("Previous Edge Index")) {
111 params.set_output("Previous Edge Index",
112 Field<int>(std::make_shared<bke::EvaluateAtIndexInput>(
113 corner_index,
114 Field<int>(std::make_shared<CornerPreviousEdgeFieldInput>()),
115 AttrDomain::Corner)));
116 }
117}
118
119static void node_register()
120{
121 static blender::bke::bNodeType ntype;
123 &ntype, GEO_NODE_MESH_TOPOLOGY_EDGES_OF_CORNER, "Edges of Corner", NODE_CLASS_INPUT);
125 ntype.declare = node_declare;
127}
129
130} // namespace blender::nodes::node_geo_mesh_topology_edges_of_corner_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:404
#define NOD_REGISTER_NODE(REGISTER_FUNC)
constexpr int64_t size() const
Definition BLI_span.hh:253
static VArray ForSpan(Span< T > values)
static VArray ForFunc(const int64_t size, GetFunc get_func)
GVArray get_varray_for_context(const Mesh &mesh, const AttrDomain domain, const IndexMask &) const final
GVArray get_varray_for_context(const Mesh &mesh, 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