Blender V4.3
node_geo_input_mesh_edge_neighbors.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 "BLI_array_utils.hh"
6
7#include "BKE_mesh.hh"
8
10
12
14{
15 b.add_output<decl::Int>("Face Count")
16 .field_source()
17 .description("The number of faces that use each edge as one of their sides");
18}
19
21 public:
23 : bke::MeshFieldInput(CPPType::get<int>(), "Edge Neighbor Count Field")
24 {
26 }
27
29 const AttrDomain domain,
30 const IndexMask & /*mask*/) const final
31 {
32 Array<int> counts(mesh.edges_num, 0);
33 array_utils::count_indices(mesh.corner_edges(), counts);
34 return mesh.attributes().adapt_domain<int>(
35 VArray<int>::ForContainer(std::move(counts)), AttrDomain::Edge, domain);
36 }
37
38 uint64_t hash() const override
39 {
40 /* Some random constant hash. */
41 return 985671075;
42 }
43
44 bool is_equal_to(const fn::FieldNode &other) const override
45 {
46 return dynamic_cast<const EdgeNeighborCountFieldInput *>(&other) != nullptr;
47 }
48
49 std::optional<AttrDomain> preferred_domain(const Mesh & /*mesh*/) const override
50 {
51 return AttrDomain::Edge;
52 }
53};
54
56{
57 Field<int> neighbor_count_field{std::make_shared<EdgeNeighborCountFieldInput>()};
58 params.set_output("Face Count", std::move(neighbor_count_field));
59}
60
61static void node_register()
62{
63 static blender::bke::bNodeType ntype;
65 &ntype, GEO_NODE_INPUT_MESH_EDGE_NEIGHBORS, "Edge Neighbors", NODE_CLASS_INPUT);
66 ntype.declare = node_declare;
69}
71
72} // namespace blender::nodes::node_geo_input_mesh_edge_neighbors_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:404
#define NOD_REGISTER_NODE(REGISTER_FUNC)
static VArray ForContainer(ContainerT container)
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 count_indices(Span< int > indices, MutableSpan< int > counts)
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
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