[Bf-blender-cvs] [3e4a201eaea] soc-2021-adaptive-cloth: adaptive_cloth: Face: add has_vert_index(), has_edge()
ishbosamiya
noreply at git.blender.org
Mon Jul 12 08:23:47 CEST 2021
Commit: 3e4a201eaea22dc1163ebbb20dcd9ad516fb83d9
Author: ishbosamiya
Date: Wed Jul 7 17:52:15 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB3e4a201eaea22dc1163ebbb20dcd9ad516fb83d9
adaptive_cloth: Face: add has_vert_index(), has_edge()
===================================================================
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 569b75b636a..3587659fd36 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -363,6 +363,47 @@ template<typename T> class Face {
return this->verts;
}
+ bool has_vert_index(const VertIndex &vert_index) const
+ {
+ return verts.contains(vert_index);
+ }
+
+ template<typename EED> bool has_edge(const Edge<EED> &edge) const
+ {
+ BLI_assert(edge.get_verts());
+ auto &[edge_vert_1, edge_vert_2] = edge.get_verts().value();
+
+ BLI_assert(this->has_vert_index(edge_vert_1));
+ BLI_assert(this->has_vert_index(edge_vert_2));
+
+ auto vi1 = this->verts.first_index_of(edge_vert_1);
+ auto vi2 = this->verts.first_index_of(edge_vert_2);
+
+ if (std::abs(vi1 - vi2) == 1) {
+ return true;
+ }
+
+ /* TODO(ish): there probably a nicer way to check for this
+ * special case, this is way too verbose */
+ /* Need to have loop around as well, so if the face has 5 verts,
+ * verts at [0, 1, 2, 3, 4]. Then an edge (0, 4) or (4, 0) can
+ * exist. Thus an extra check is necessary */
+ if (vi1 == 0) {
+ if (vi2 == this->verts.size() - 1) {
+ return true;
+ }
+ return false;
+ }
+ if (vi2 == 0) {
+ if (vi1 == this->verts.size() - 1) {
+ return true;
+ }
+ return false;
+ }
+
+ return false;
+ }
+
friend std::ostream &operator<<(std::ostream &stream, const Face &face)
{
stream << "(self_index: " << face.self_index << ", verts: " << face.verts
More information about the Bf-blender-cvs
mailing list