Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_area.cc
| Show All 12 Lines | |||||
| { | { | ||||
| b.add_output<decl::Float>(N_("Area")) | b.add_output<decl::Float>(N_("Area")) | ||||
| .field_source() | .field_source() | ||||
| .description(N_("The surface area of each of the mesh's faces")); | .description(N_("The surface area of each of the mesh's faces")); | ||||
| } | } | ||||
| static VArray<float> construct_face_area_varray(const Mesh &mesh, const eAttrDomain domain) | static VArray<float> construct_face_area_varray(const Mesh &mesh, const eAttrDomain domain) | ||||
| { | { | ||||
| const Span<MVert> verts = mesh.verts(); | const Span<float3> positions = mesh.positions(); | ||||
| const Span<MPoly> polys = mesh.polys(); | const Span<MPoly> polys = mesh.polys(); | ||||
| const Span<MLoop> loops = mesh.loops(); | const Span<MLoop> loops = mesh.loops(); | ||||
| auto area_fn = [verts, polys, loops](const int i) -> float { | auto area_fn = [positions, polys, loops](const int i) -> float { | ||||
| const MPoly &poly = polys[i]; | const MPoly &poly = polys[i]; | ||||
| return BKE_mesh_calc_poly_area(&poly, &loops[poly.loopstart], verts.data()); | return BKE_mesh_calc_poly_area( | ||||
| &poly, &loops[poly.loopstart], reinterpret_cast<const float(*)[3]>(positions.data())); | |||||
| }; | }; | ||||
| return mesh.attributes().adapt_domain<float>( | return mesh.attributes().adapt_domain<float>( | ||||
| VArray<float>::ForFunc(polys.size(), area_fn), ATTR_DOMAIN_FACE, domain); | VArray<float>::ForFunc(polys.size(), area_fn), ATTR_DOMAIN_FACE, domain); | ||||
| } | } | ||||
| class FaceAreaFieldInput final : public bke::MeshFieldInput { | class FaceAreaFieldInput final : public bke::MeshFieldInput { | ||||
| public: | public: | ||||
| ▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines | |||||