Blender V4.5
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 b.add_output<decl::Int>("Vertex Index")
17 .field_source_reference_all()
18 .description("The vertex the corner is attached to");
19}
20
22 public:
23 CornerVertFieldInput() : bke::MeshFieldInput(CPPType::get<int>(), "Corner Vertex")
24 {
26 }
27
29 const AttrDomain domain,
30 const IndexMask & /*mask*/) const final
31 {
32 if (domain != AttrDomain::Corner) {
33 return {};
34 }
35 return VArray<int>::ForSpan(mesh.corner_verts());
36 }
37
39 {
40 return 30495867093876;
41 }
42
43 bool is_equal_to(const fn::FieldNode &other) const final
44 {
45 return dynamic_cast<const CornerVertFieldInput *>(&other) != nullptr;
46 }
47
48 std::optional<AttrDomain> preferred_domain(const Mesh & /*mesh*/) const final
49 {
50 return AttrDomain::Corner;
51 }
52};
53
55{
56 params.set_output("Vertex Index",
57 Field<int>(std::make_shared<bke::EvaluateAtIndexInput>(
58 params.extract_input<Field<int>>("Corner Index"),
59 Field<int>(std::make_shared<CornerVertFieldInput>()),
60 AttrDomain::Corner)));
61}
62
63static void node_register()
64{
65 static blender::bke::bNodeType ntype;
67 &ntype, "GeometryNodeVertexOfCorner", GEO_NODE_MESH_TOPOLOGY_VERTEX_OF_CORNER);
68 ntype.ui_name = "Vertex of Corner";
69 ntype.ui_description = "Retrieve the vertex each face corner is attached to";
70 ntype.enum_name_legacy = "VERTEX_OF_CORNER";
73 ntype.declare = node_declare;
75}
77
78} // namespace blender::nodes::node_geo_mesh_topology_vertex_of_corner_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:433
#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 ForSpan(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:2748
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:226
std::string ui_description
Definition BKE_node.hh:232
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:347
const char * enum_name_legacy
Definition BKE_node.hh:235
NodeDeclareFunction declare
Definition BKE_node.hh:355