Blender V5.0
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")
14 .implicit_field(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")
18 .field_source_reference_all()
19 .description("The vertex the corner is attached to");
20}
21
23 public:
24 CornerVertFieldInput() : bke::MeshFieldInput(CPPType::get<int>(), "Corner Vertex")
25 {
27 }
28
30 const AttrDomain domain,
31 const IndexMask & /*mask*/) const final
32 {
33 if (domain != AttrDomain::Corner) {
34 return {};
35 }
36 return VArray<int>::from_span(mesh.corner_verts());
37 }
38
40 {
41 return 30495867093876;
42 }
43
44 bool is_equal_to(const fn::FieldNode &other) const final
45 {
46 return dynamic_cast<const CornerVertFieldInput *>(&other) != nullptr;
47 }
48
49 std::optional<AttrDomain> preferred_domain(const Mesh & /*mesh*/) const final
50 {
51 return AttrDomain::Corner;
52 }
53};
54
56{
57 params.set_output("Vertex Index",
58 Field<int>(std::make_shared<bke::EvaluateAtIndexInput>(
59 params.extract_input<Field<int>>("Corner Index"),
60 Field<int>(std::make_shared<CornerVertFieldInput>()),
61 AttrDomain::Corner)));
62}
63
64static void node_register()
65{
66 static blender::bke::bNodeType ntype;
68 &ntype, "GeometryNodeVertexOfCorner", GEO_NODE_MESH_TOPOLOGY_VERTEX_OF_CORNER);
69 ntype.ui_name = "Vertex of Corner";
70 ntype.ui_description = "Retrieve the vertex each face corner is attached to";
71 ntype.enum_name_legacy = "VERTEX_OF_CORNER";
74 ntype.declare = node_declare;
76}
78
79} // namespace blender::nodes::node_geo_mesh_topology_vertex_of_corner_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define GEO_NODE_MESH_TOPOLOGY_VERTEX_OF_CORNER
#define final(a, b, c)
Definition BLI_hash.h:19
#define NOD_REGISTER_NODE(REGISTER_FUNC)
unsigned long long int uint64_t
static VArray from_span(Span< T > values)
GVArray get_varray_for_context(const Mesh &mesh, const AttrDomain domain, const IndexMask &) const final
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:354
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362