Blender V5.3
node_geo_mesh_topology_vertex_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 "DNA_mesh_types.h"
6
8
10
12{
13 b.add_input<decl::Int>("Corner Index"_ustr)
14 .default_input_type(NODE_DEFAULT_INPUT_INDEX_FIELD)
15 .description("The corner to retrieve data from. Defaults to the corner from the context")
16 .structure_type(StructureType::Field);
17 b.add_output<decl::Int>("Vertex Index"_ustr)
18 .structure_type(StructureType::Field)
19 .propagate_references()
20 .description("The vertex the corner is attached to");
21}
22
24 public:
25 CornerVertFieldInput() : bke::MeshFieldInput(CPPType::get<int>(), "Corner Vertex") {}
26
28 const AttrDomain domain,
29 const IndexMask & /*mask*/) const final
30 {
31 if (domain != AttrDomain::Corner) {
32 return {};
33 }
34 return VArray<int>::from_span(mesh.corner_verts());
35 }
36
37 void hash_unique(UniqueHashBytes &hash, fn::FieldHashDeep & /*deep_hash_cache*/) const override
38 {
39 static constexpr int8_t id = 0;
40 hash.add(&id);
41 }
42
43 std::optional<AttrDomain> preferred_domain(const Mesh & /*mesh*/) const final
44 {
45 return AttrDomain::Corner;
46 }
47};
48
50{
51 params.set_output("Vertex Index"_ustr,
53 params.extract_input<Field<int>>("Corner Index"_ustr),
55 AttrDomain::Corner));
56}
57
58static void node_register()
59{
60 static bke::bNodeType ntype;
62 &ntype, "GeometryNodeVertexOfCorner"_ustr, GEO_NODE_MESH_TOPOLOGY_VERTEX_OF_CORNER);
63 ntype.ui_name = "Vertex of Corner";
64 ntype.ui_description = "Retrieve the vertex each face corner is attached to";
65 ntype.enum_name_legacy = "VERTEX_OF_CORNER";
68 ntype.declare = node_declare;
70}
72
73} // namespace blender::nodes::node_geo_mesh_topology_vertex_of_corner_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define GEO_NODE_MESH_TOPOLOGY_VERTEX_OF_CORNER
#define final(a, b, c)
Definition BLI_hash_c.hh:21
#define NOD_REGISTER_NODE(REGISTER_FUNC)
static VArray from_span(Span< T > values)
uint64_t hash() const
Definition field.cc:185
static Field from_input(Args &&...args)
T extract_input(const UString identifier)
void set_output(const UString identifier, T &&value)
GVArray get_varray_for_context(const Mesh &mesh, const AttrDomain domain, const IndexMask &) const final
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
signed char int8_t
Definition BKE_text.h:76
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
NodeDeclareFunction declare
Definition BKE_node.hh:393