Differential D16893 Diff 59609 source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_neighbors.cc
| Show All 16 Lines | static void node_declare(NodeDeclarationBuilder &b) | ||||
| b.add_output<decl::Int>(N_("Face Count")) | b.add_output<decl::Int>(N_("Face Count")) | ||||
| .field_source() | .field_source() | ||||
| .description(N_("Number of faces which share an edge with the face")); | .description(N_("Number of faces which share an edge with the face")); | ||||
| } | } | ||||
| static VArray<int> construct_neighbor_count_varray(const Mesh &mesh, const eAttrDomain domain) | static VArray<int> construct_neighbor_count_varray(const Mesh &mesh, const eAttrDomain domain) | ||||
| { | { | ||||
| const Span<MPoly> polys = mesh.polys(); | const Span<MPoly> polys = mesh.polys(); | ||||
| const Span<MLoop> loops = mesh.loops(); | const Span<int> corner_edges = mesh.corner_edges(); | ||||
| Array<int> edge_count(mesh.totedge, 0); | Array<int> edge_count(mesh.totedge, 0); | ||||
| for (const MLoop &loop : loops) { | for (const int edge : corner_edges) { | ||||
| edge_count[loop.e]++; | edge_count[edge]++; | ||||
| } | } | ||||
| Array<int> poly_count(polys.size(), 0); | Array<int> poly_count(polys.size(), 0); | ||||
| for (const int poly_index : polys.index_range()) { | for (const int poly_index : polys.index_range()) { | ||||
| const MPoly &poly = polys[poly_index]; | const MPoly &poly = polys[poly_index]; | ||||
| for (const MLoop &loop : loops.slice(poly.loopstart, poly.totloop)) { | for (const int edge : corner_edges.slice(poly.loopstart, poly.totloop)) { | ||||
| poly_count[poly_index] += edge_count[loop.e] - 1; | poly_count[poly_index] += edge_count[edge] - 1; | ||||
| } | } | ||||
| } | } | ||||
| return mesh.attributes().adapt_domain<int>( | return mesh.attributes().adapt_domain<int>( | ||||
| VArray<int>::ForContainer(std::move(poly_count)), ATTR_DOMAIN_FACE, domain); | VArray<int>::ForContainer(std::move(poly_count)), ATTR_DOMAIN_FACE, domain); | ||||
| } | } | ||||
| class FaceNeighborCountFieldInput final : public bke::MeshFieldInput { | class FaceNeighborCountFieldInput final : public bke::MeshFieldInput { | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||