[Bf-blender-cvs] [29c73ddd2ec] soc-2021-adaptive-cloth: adaptive_cloth: mesh: face edge linkage checks improvement

ishbosamiya noreply at git.blender.org
Mon Aug 9 11:13:25 CEST 2021


Commit: 29c73ddd2ec63175e87b40c0f83d6e17a5213580
Author: ishbosamiya
Date:   Wed Aug 4 10:16:41 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB29c73ddd2ec63175e87b40c0f83d6e17a5213580

adaptive_cloth: mesh: face edge linkage checks improvement

It is not necessary for the face to have it's verts available, because
delete_edge() can remove the verts from the face. So this check
ensures that there is no out of bounds access.

===================================================================

M	source/blender/blenkernel/BKE_cloth_remesh.hh

===================================================================

diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh
index 416fcb5d4eb..921ed6d5688 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -2859,6 +2859,11 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
 
   bool is_face_edges_linked(const Face<EFD> &face) const
   {
+    if (face.verts.size() == 0) {
+      /* No verts available, so no links possible */
+      return false;
+    }
+
     auto vert_1_index = face.verts[0];
     auto vert_2_index = face.verts[0];
     for (auto i = 1; i <= face.verts.size(); i++) {
@@ -2900,6 +2905,13 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
   {
     auto &face = this->get_checked_face(face_index);
 
+    /* An earlier call to delete_edge and now this call can lead to
+     * problems, so early exit if the verts were already removed from
+     * the face. */
+    if (face.verts.size() == 0) {
+      return;
+    }
+
     /* Would want to use `get_edges_of_face()` but that can lead to 2
      * loops, so duplicating that code here. (note: this needs to be
      * benchmarked to see if this duplication is necessary) */



More information about the Bf-blender-cvs mailing list