From 8abda209a45959307e02552a3c035cbd63e0794a Mon Sep 17 00:00:00 2001 From: ishbosamiya Date: Sat, 28 Aug 2021 17:28:36 +0530 Subject: adaptive_cloth: AdaptiveMesh: split edge: verts added during split Split edge now appends the flip edges mesh diff to the split edge mesh diff and returns this complete mesh diff and the verts that were added during split operation. --- source/blender/blenkernel/intern/cloth_remesh.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc index d321d677900..dd7c711e11c 100644 --- a/source/blender/blenkernel/intern/cloth_remesh.cc +++ b/source/blender/blenkernel/intern/cloth_remesh.cc @@ -689,8 +689,13 @@ class AdaptiveMesh : public Mesh, VertData, EdgeData, internal::Em * Split the given edge and handle adaptivemesh specific * requirements like running `this->flip_edges` on faces created * during splitting, handling sewing if enabled. + * + * Returns a tuple of the MeshDiff of the entire split edge + * operation (includes sewing related and flip edges operations) and + * the set of verts that were added by the split operation only. */ - void split_edge_adaptivemesh(const EdgeIndex &edge_index, bool sewing_enabled) + std::tuple, blender::Vector> split_edge_adaptivemesh( + const EdgeIndex &edge_index, bool sewing_enabled) { auto &edge = this->get_checked_edge(edge_index); auto mesh_diff = this->split_edge_triangulate(edge.get_self_index(), true); @@ -705,6 +710,10 @@ class AdaptiveMesh : public Mesh, VertData, EdgeData, internal::Em this->compute_info_adaptivemesh(mesh_diff); + /* Store the verts added by the split edge operation to return + * from the function */ + const auto added_verts = mesh_diff.get_added_verts(); + if (sewing_enabled) { BLI_assert(mesh_diff.get_added_nodes().size() == 1); std::cout << "mesh_diff.get_added_verts().size(): " << mesh_diff.get_added_verts().size() @@ -715,7 +724,12 @@ class AdaptiveMesh : public Mesh, VertData, EdgeData, internal::Em /* Flip edges of those faces that were created during the * split edge operation */ auto added_faces = mesh_diff.get_added_faces(); - this->flip_edges(added_faces); + const auto flip_edges_mesh_diff = this->flip_edges(added_faces); + + mesh_diff.append(flip_edges_mesh_diff); + mesh_diff.remove_non_existing_elements(*this); + + return {mesh_diff, added_verts}; } /** -- cgit v1.2.3