Differential D16858 Diff 59005 source/blender/nodes/geometry/nodes/node_geo_mesh_face_set_boundaries.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/geometry/nodes/node_geo_mesh_face_set_boundaries.cc
| Show All 12 Lines | |||||
| { | { | ||||
| b.add_input<decl::Int>(N_("Face Set")) | b.add_input<decl::Int>(N_("Face Set")) | ||||
| .default_value(0) | .default_value(0) | ||||
| .hide_value() | .hide_value() | ||||
| .supports_field() | .supports_field() | ||||
| .description(N_("An identifier for the group of each face. All contiguous faces with the " | .description(N_("An identifier for the group of each face. All contiguous faces with the " | ||||
| "same value are in the same region")); | "same value are in the same region")); | ||||
| b.add_output<decl::Bool>(N_("Boundary Edges")) | b.add_output<decl::Bool>(N_("Boundary Edges")) | ||||
| .field_source() | .field_source_reference_all() | ||||
| .description(N_("The edges that lie on the boundaries between the different face sets")); | .description(N_("The edges that lie on the boundaries between the different face sets")); | ||||
| } | } | ||||
| class BoundaryFieldInput final : public bke::MeshFieldInput { | class BoundaryFieldInput final : public bke::MeshFieldInput { | ||||
| private: | private: | ||||
| const Field<int> face_set; | const Field<int> face_set_; | ||||
| public: | public: | ||||
| BoundaryFieldInput(const Field<int> face_set) | BoundaryFieldInput(const Field<int> face_set) | ||||
| : bke::MeshFieldInput(CPPType::get<bool>(), "Boundary Field"), face_set(face_set) | : bke::MeshFieldInput(CPPType::get<bool>(), "Boundary Field"), face_set_(face_set) | ||||
| { | { | ||||
| 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 | ||||
| { | { | ||||
| const bke::MeshFieldContext face_context{mesh, ATTR_DOMAIN_FACE}; | const bke::MeshFieldContext face_context{mesh, ATTR_DOMAIN_FACE}; | ||||
| FieldEvaluator face_evaluator{face_context, mesh.totpoly}; | FieldEvaluator face_evaluator{face_context, mesh.totpoly}; | ||||
| face_evaluator.add(face_set); | face_evaluator.add(face_set_); | ||||
| face_evaluator.evaluate(); | face_evaluator.evaluate(); | ||||
| const VArray<int> face_set = face_evaluator.get_evaluated<int>(0); | const VArray<int> face_set = face_evaluator.get_evaluated<int>(0); | ||||
| Array<bool> boundary(mesh.totedge, false); | Array<bool> boundary(mesh.totedge, false); | ||||
| Array<bool> edge_visited(mesh.totedge, false); | Array<bool> edge_visited(mesh.totedge, false); | ||||
| Array<int> edge_face_set(mesh.totedge, 0); | Array<int> edge_face_set(mesh.totedge, 0); | ||||
| const Span<MPoly> polys = mesh.polys(); | const Span<MPoly> polys = mesh.polys(); | ||||
| const Span<MLoop> loops = mesh.loops(); | const Span<MLoop> loops = mesh.loops(); | ||||
| Show All 10 Lines | for (const int i : polys.index_range()) { | ||||
| edge_visited[edge] = true; | edge_visited[edge] = true; | ||||
| edge_face_set[edge] = face_set[i]; | edge_face_set[edge] = face_set[i]; | ||||
| } | } | ||||
| } | } | ||||
| return mesh.attributes().adapt_domain<bool>( | return mesh.attributes().adapt_domain<bool>( | ||||
| VArray<bool>::ForContainer(std::move(boundary)), ATTR_DOMAIN_EDGE, domain); | VArray<bool>::ForContainer(std::move(boundary)), ATTR_DOMAIN_EDGE, domain); | ||||
| } | } | ||||
| void for_each_field_input_recursive(FunctionRef<void(const FieldInput &)> fn) const | |||||
| { | |||||
| face_set_.node().for_each_field_input_recursive(fn); | |||||
| } | |||||
| std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override | std::optional<eAttrDomain> preferred_domain(const Mesh & /*mesh*/) const override | ||||
| { | { | ||||
| return ATTR_DOMAIN_EDGE; | return ATTR_DOMAIN_EDGE; | ||||
| } | } | ||||
| }; | }; | ||||
| static void node_geo_exec(GeoNodeExecParams params) | static void node_geo_exec(GeoNodeExecParams params) | ||||
| { | { | ||||
| Show All 18 Lines | |||||