[Bf-blender-cvs] [11ceeef00c5] soc-2021-adaptive-cloth: adaptive_cloth: AdaptiveMesh: flip_edges()
ishbosamiya
noreply at git.blender.org
Mon Jul 26 08:17:43 CEST 2021
Commit: 11ceeef00c59848809375a4da96a9b8725aed843
Author: ishbosamiya
Date: Thu Jul 22 17:39:03 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB11ceeef00c59848809375a4da96a9b8725aed843
adaptive_cloth: AdaptiveMesh: flip_edges()
Flips edges of the `active_faces` if needed.
* Get the maximally independent set of flippable `AdaptiveEdge`s.
* Flip each edge in this set and update `active_faces` with the faces
affected by this operation.
* Repeat until the set has 0 flippable `AdaptiveEdge`s
===================================================================
M source/blender/blenkernel/intern/cloth_remesh.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc
index 47bb922152e..737aa60710a 100644
--- a/source/blender/blenkernel/intern/cloth_remesh.cc
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -322,6 +322,41 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
}
}
+ /**
+ * Flip edges of the `active_faces` if needed.
+ *
+ * Might make sense to take `active_faces` by move semantics later.
+ */
+ void flip_edges(blender::Vector<FaceIndex> active_faces)
+ {
+ auto flippable_edge_indices_set = this->get_flippable_edge_indices_set(active_faces);
+ do {
+ for (const auto &edge_index : flippable_edge_indices_set) {
+ auto &edge = this->get_checked_edge(edge_index);
+
+ auto mesh_diff = this->flip_edge_triangulate(edge.get_self_index(), false);
+
+ /* Update `active_faces` */
+ {
+ /* Update `active_faces` to contain only face indices that
+ * still exist in the mesh */
+ blender::Vector<FaceIndex> new_active_faces;
+ for (const auto &face_index : active_faces) {
+ if (this->does_face_exist(face_index)) {
+ new_active_faces.append(face_index);
+ }
+ }
+ active_faces = std::move(new_active_faces);
+
+ /* Add the newly created faces */
+ active_faces.extend(mesh_diff.get_added_faces().as_span());
+ }
+ }
+
+ flippable_edge_indices_set = this->get_flippable_edge_indices_set(active_faces);
+ } while (flippable_edge_indices_set.size() != 0);
+ }
+
/**
* Splits edges whose "size" is greater than 1.0
*
More information about the Bf-blender-cvs
mailing list