Blender V4.3
node_geo_mesh_topology_face_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
8
10
12{
13 b.add_input<decl::Int>("Corner Index")
14 .implicit_field(implicit_field_inputs::index)
15 .description("The corner to retrieve data from. Defaults to the corner from the context");
16 b.add_output<decl::Int>("Face Index")
17 .field_source_reference_all()
18 .description("The index of the face the corner is a part of");
19 b.add_output<decl::Int>("Index in Face")
20 .field_source_reference_all()
21 .description("The index of the corner starting from the first corner in the face");
22}
23
25 public:
26 CornerFaceIndexInput() : bke::MeshFieldInput(CPPType::get<int>(), "Corner Face Index")
27 {
29 }
30
32 const AttrDomain domain,
33 const IndexMask & /*mask*/) const final
34 {
35 if (domain != AttrDomain::Corner) {
36 return {};
37 }
38 return VArray<int>::ForSpan(mesh.corner_to_face_map());
39 }
40
41 uint64_t hash() const final
42 {
43 return 2348712958475728;
44 }
45
46 bool is_equal_to(const fn::FieldNode &other) const final
47 {
48 return dynamic_cast<const CornerFaceIndexInput *>(&other) != nullptr;
49 }
50};
51
53 public:
54 CornerIndexInFaceInput() : bke::MeshFieldInput(CPPType::get<int>(), "Corner Index In Face")
55 {
57 }
58
60 const AttrDomain domain,
61 const IndexMask & /*mask*/) const final
62 {
63 if (domain != AttrDomain::Corner) {
64 return {};
65 }
66 const OffsetIndices faces = mesh.faces();
67 const Span<int> corner_to_face = mesh.corner_to_face_map();
68 return VArray<int>::ForFunc(mesh.corners_num, [faces, corner_to_face](const int corner) {
69 const int face_i = corner_to_face[corner];
70 return corner - faces[face_i].start();
71 });
72 }
73
74 uint64_t hash() const final
75 {
76 return 97837176448;
77 }
78
79 bool is_equal_to(const fn::FieldNode &other) const final
80 {
81 return dynamic_cast<const CornerIndexInFaceInput *>(&other) != nullptr;
82 }
83
84 std::optional<AttrDomain> preferred_domain(const Mesh & /*mesh*/) const final
85 {
86 return AttrDomain::Corner;
87 }
88};
89
91{
92 const Field<int> corner_index = params.extract_input<Field<int>>("Corner Index");
93 if (params.output_is_required("Face Index")) {
94 params.set_output("Face Index",
95 Field<int>(std::make_shared<bke::EvaluateAtIndexInput>(
96 corner_index,
97 Field<int>(std::make_shared<CornerFaceIndexInput>()),
98 AttrDomain::Corner)));
99 }
100 if (params.output_is_required("Index in Face")) {
101 params.set_output("Index in Face",
102 Field<int>(std::make_shared<bke::EvaluateAtIndexInput>(
103 corner_index,
104 Field<int>(std::make_shared<CornerIndexInFaceInput>()),
105 AttrDomain::Corner)));
106 }
107}
108
109static void node_register()
110{
111 static blender::bke::bNodeType ntype;
113 &ntype, GEO_NODE_MESH_TOPOLOGY_FACE_OF_CORNER, "Face of Corner", NODE_CLASS_INPUT);
115 ntype.declare = node_declare;
117}
119
120} // namespace blender::nodes::node_geo_mesh_topology_face_of_corner_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:404
#define NOD_REGISTER_NODE(REGISTER_FUNC)
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