Differential D16893 Diff 59310 source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc
| Show All 19 Lines | b.add_output<decl::Int>(N_("Next Edge Index")) | ||||
| .description( | .description( | ||||
| N_("The edge after the corner in the face, in the direction of increasing indices")); | N_("The edge after the corner in the face, in the direction of increasing indices")); | ||||
| b.add_output<decl::Int>(N_("Previous Edge Index")) | b.add_output<decl::Int>(N_("Previous Edge Index")) | ||||
| .field_source_reference_all() | .field_source_reference_all() | ||||
| .description( | .description( | ||||
| N_("The edge before the corner in the face, in the direction of decreasing indices")); | N_("The edge before the corner in the face, in the direction of decreasing indices")); | ||||
| } | } | ||||
| static int get_loop_edge(const MLoop &loop) | |||||
| { | |||||
| return loop.e; | |||||
| } | |||||
| class CornerNextEdgeFieldInput final : public bke::MeshFieldInput { | class CornerNextEdgeFieldInput final : public bke::MeshFieldInput { | ||||
| public: | public: | ||||
| CornerNextEdgeFieldInput() : bke::MeshFieldInput(CPPType::get<int>(), "Corner Next Edge") | CornerNextEdgeFieldInput() : bke::MeshFieldInput(CPPType::get<int>(), "Corner Next Edge") | ||||
| { | { | ||||
| category_ = Category::Generated; | category_ = Category::Generated; | ||||
| } | } | ||||
| GVArray get_varray_for_context(const Mesh &mesh, | GVArray get_varray_for_context(const Mesh &mesh, | ||||
| const eAttrDomain domain, | const eAttrDomain domain, | ||||
| const IndexMask /*mask*/) const final | const IndexMask /*mask*/) const final | ||||
| { | { | ||||
| if (domain != ATTR_DOMAIN_CORNER) { | if (domain != ATTR_DOMAIN_CORNER) { | ||||
| return {}; | return {}; | ||||
| } | } | ||||
| return VArray<int>::ForDerivedSpan<MLoop, get_loop_edge>(mesh.loops()); | return VArray<int>::ForSpan(mesh.corner_edges()); | ||||
| } | } | ||||
| uint64_t hash() const final | uint64_t hash() const final | ||||
| { | { | ||||
| return 1892753404495; | return 1892753404495; | ||||
| } | } | ||||
| bool is_equal_to(const fn::FieldNode &other) const final | bool is_equal_to(const fn::FieldNode &other) const final | ||||
| Show All 20 Lines | public: | ||||
| GVArray get_varray_for_context(const Mesh &mesh, | GVArray get_varray_for_context(const Mesh &mesh, | ||||
| const eAttrDomain domain, | const eAttrDomain domain, | ||||
| const IndexMask /*mask*/) const final | const IndexMask /*mask*/) const final | ||||
| { | { | ||||
| if (domain != ATTR_DOMAIN_CORNER) { | if (domain != ATTR_DOMAIN_CORNER) { | ||||
| return {}; | return {}; | ||||
| } | } | ||||
| 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> loop_to_poly_map = bke::mesh_topology::build_loop_to_poly_map(polys, mesh.totloop); | Array<int> loop_to_poly_map = bke::mesh_topology::build_loop_to_poly_map(polys, mesh.totloop); | ||||
| return VArray<int>::ForFunc( | return VArray<int>::ForFunc( | ||||
| mesh.totloop, | mesh.totloop, | ||||
| [polys, loops, loop_to_poly_map = std::move(loop_to_poly_map)](const int corner_i) { | [polys, corner_edges, loop_to_poly_map = std::move(loop_to_poly_map)](const int corner_i) { | ||||
| const int poly_i = loop_to_poly_map[corner_i]; | const MPoly &poly = polys[loop_to_poly_map[corner_i]]; | ||||
| const MPoly &poly = polys[poly_i]; | return corner_edges[bke::mesh_topology::poly_loop_prev(poly, corner_i)]; | ||||
| const int corner_i_prev = bke::mesh_topology::poly_loop_prev(poly, corner_i); | |||||
| return loops[corner_i_prev].e; | |||||
| }); | }); | ||||
| } | } | ||||
| uint64_t hash() const final | uint64_t hash() const final | ||||
| { | { | ||||
| return 987298345762465; | return 987298345762465; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines | |||||