diff options
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc index 50d6998bb27..bfe8753c039 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_edge_neighbors.cc @@ -16,34 +16,26 @@ static void node_declare(NodeDeclarationBuilder &b) .description(N_("The number of faces that use each edge as one of their sides")); } -class EdgeNeighborCountFieldInput final : public GeometryFieldInput { +class EdgeNeighborCountFieldInput final : public bke::MeshFieldInput { public: EdgeNeighborCountFieldInput() - : GeometryFieldInput(CPPType::get<int>(), "Edge Neighbor Count Field") + : bke::MeshFieldInput(CPPType::get<int>(), "Edge Neighbor Count Field") { category_ = Category::Generated; } - GVArray get_varray_for_context(const GeometryComponent &component, + GVArray get_varray_for_context(const Mesh &mesh, const eAttrDomain domain, IndexMask UNUSED(mask)) const final { - if (component.type() == GEO_COMPONENT_TYPE_MESH) { - const MeshComponent &mesh_component = static_cast<const MeshComponent &>(component); - const Mesh *mesh = mesh_component.get_for_read(); - if (mesh == nullptr) { - return {}; - } - - Array<int> face_count(mesh->totedge, 0); - for (const int i : IndexRange(mesh->totloop)) { - face_count[mesh->mloop[i].e]++; - } - - return mesh_component.attributes()->adapt_domain<int>( - VArray<int>::ForContainer(std::move(face_count)), ATTR_DOMAIN_EDGE, domain); + const Span<MLoop> loops = mesh.loops(); + Array<int> face_count(mesh.totedge, 0); + for (const MLoop &loop : loops) { + face_count[loop.e]++; } - return {}; + + return mesh.attributes().adapt_domain<int>( + VArray<int>::ForContainer(std::move(face_count)), ATTR_DOMAIN_EDGE, domain); } uint64_t hash() const override |