[Bf-blender-cvs] [bf0438bd463] soc-2021-adaptive-cloth: adaptive_cloth: Mesh: get other vert when given edge and face indices

ishbosamiya noreply at git.blender.org
Mon Jul 12 08:23:46 CEST 2021


Commit: bf0438bd463440961c3b88c347d64328e211e671
Author: ishbosamiya
Date:   Mon Jul 5 21:21:54 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBbf0438bd463440961c3b88c347d64328e211e671

adaptive_cloth: Mesh: get other vert when given edge and face indices

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

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 efcf73a7009..1e17e6ba2f6 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -66,6 +66,7 @@ Mesh *BKE_cloth_remesh(struct Object *ob, struct ClothModifierData *clmd, struct
 #  include <iostream>
 #  include <istream>
 #  include <limits>
+#  include <optional>
 #  include <sstream>
 #  include <string>
 #  include <tuple>
@@ -908,6 +909,37 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
     return std::nullopt;
   }
 
+  /**
+   * Gives first vert index of face that is not part of edge.
+   * This should be called only when the face has 3 verts, will return
+   * `std::nullopt` otherwise.
+   **/
+  inline std::optional<VertIndex> get_other_vert_index(EdgeIndex edge_index, FaceIndex face_index)
+  {
+
+    auto op_face = this->faces.get(face_index);
+    BLI_assert(op_face);
+    auto &face = op_face.value().get();
+
+    if (face.verts.size() != 3) {
+      return std::nullopt;
+    }
+
+    auto [vert_1_index, vert_2_index, vert_3_index] = face.verts;
+
+    auto op_edge = this->edges.get(edge_index);
+    BLI_assert(op_edge);
+    auto &edge = op_edge.value().get();
+
+    if (edge.has_vert(vert_1_index) == false) {
+      return vert_1_index;
+    }
+    if (edge.has_vert(vert_2_index) == false) {
+      return vert_2_index;
+    }
+    return vert_3_index;
+  }
+
   void read(const MeshIO &reader)
   {
     const auto &positions = reader.get_positions();



More information about the Bf-blender-cvs mailing list