[Bf-blender-cvs] [bb31b5bca02] soc-2021-adaptive-cloth: adaptive_cloth: Mesh: get vert indices of edge aligned with n1
ishbosamiya
noreply at git.blender.org
Sun Aug 22 17:23:38 CEST 2021
Commit: bb31b5bca028d919b65aeee4b2cacb92e45ed9f9
Author: ishbosamiya
Date: Wed Aug 11 11:50:18 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBbb31b5bca028d919b65aeee4b2cacb92e45ed9f9
adaptive_cloth: Mesh: get vert indices of edge aligned with n1
A set of "3D edges" don't always have n1 and n2 (through the verts of
the edge) in the same order, useful to get it in the same order.
===================================================================
M source/blender/blenkernel/BKE_cloth_remesh.hh
M source/blender/blenkernel/intern/cloth_remesh.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh
index ab661ac484e..2dc5a7f43af 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -1826,22 +1826,11 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
* multiple v2 as of right now, so if we find such a case tell
* user that edge is not collapseable */
{
- auto get_v1_v2_indices = [this, &n1_index, &verts_swapped](const Edge<EED> &e) {
- const auto [v1, v2] = this->get_checked_verts_of_edge(e, verts_swapped);
- auto v1_index = v1.self_index;
- auto v2_index = v2.self_index;
- /* Need to swap the verts if v1 does not point to n1 */
- if (v1.node.value() != n1_index) {
- std::swap(v1_index, v2_index);
- }
- BLI_assert(this->get_checked_vert(v1_index).node.value() == n1_index);
- return std::make_tuple(v1_index, v2_index);
- };
-
blender::Vector<VertIndex> v1_list;
for (const auto &edge_index : edge_indices) {
const auto &e = this->get_checked_edge(edge_index);
- const auto [v1_index, v2_index] = get_v1_v2_indices(e);
+ const auto [v1_index, v2_index] = this->get_checked_vert_indices_of_edge_aligned_with_n1(
+ e, n1_index);
if (v1_list.contains(v1_index)) {
return false;
@@ -1923,21 +1912,10 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
edge_indices = this->get_connecting_edge_indices(n1_a, n2_a);
}
- auto get_v1_v2_indices = [this, &n1_index, &verts_swapped](const Edge<EED> &e) {
- auto [v1, v2] = this->get_checked_verts_of_edge(e, verts_swapped);
- auto v1_index = v1.self_index;
- auto v2_index = v2.self_index;
- /* Need to swap the verts if v1 does not point to n1 */
- if (v1.node.value() != n1_index) {
- std::swap(v1_index, v2_index);
- }
- BLI_assert(this->get_checked_vert(v1_index).node.value() == n1_index);
- return std::make_tuple(v1_index, v2_index);
- };
-
for (const auto &edge_index : edge_indices) {
auto &e = this->get_checked_edge(edge_index);
- auto [v1_index, v2_index] = get_v1_v2_indices(e);
+ auto [v1_index, v2_index] = this->get_checked_vert_indices_of_edge_aligned_with_n1(e,
+ n1_index);
auto v1_face_indices = this->get_checked_face_indices_of_vert(v1_index);
@@ -2008,7 +1986,8 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
for (const auto &edge_index : edge_indices) {
const auto &e = this->get_checked_edge(edge_index);
- const auto [v1_index, v2_index] = get_v1_v2_indices(e);
+ const auto [v1_index, v2_index] = this->get_checked_vert_indices_of_edge_aligned_with_n1(
+ e, n1_index);
auto v1_face_indices = this->get_checked_face_indices_of_vert(v1_index);
@@ -2639,6 +2618,26 @@ template<typename END, typename EVD, typename EED, typename EFD> class Mesh {
return face_indices;
}
+ /**
+ * Gets the vert indices of the edge where v1.node is n1_index.
+ *
+ * Caller must ensure at least of one the verts of the edge must have
+ * a reference to n1_index.
+ */
+ inline std::tuple<VertIndex, VertIndex> get_checked_vert_indices_of_edge_aligned_with_n1(
+ const Edge<EED> &edge, const NodeIndex &n1_index) const
+ {
+ const auto [v1, v2] = this->get_checked_verts_of_edge(edge, false);
+ auto v1_index = v1.get_self_index();
+ auto v2_index = v2.get_self_index();
+ /* Need to swap the verts if v1 does not point to n1 */
+ if (v1.get_node().value() != n1_index) {
+ std::swap(v1_index, v2_index);
+ }
+ BLI_assert(this->get_checked_vert(v1_index).get_node().value() == n1_index);
+ return {v1_index, v2_index};
+ }
+
inline std::tuple<Vert<EVD> &, Vert<EVD> &> get_checked_verts_of_edge(const Edge<EED> &edge,
bool verts_swapped)
{
diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc
index dd2296923de..79158bd6eef 100644
--- a/source/blender/blenkernel/intern/cloth_remesh.cc
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -839,17 +839,6 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
const auto &n1_a = this->get_checked_node_of_vert(v1_a);
const auto &n2_a = this->get_checked_node_of_vert(v2_a);
const auto n1_index = n1_a.get_self_index();
- auto get_v1_v2_indices = [this, &n1_index, &verts_swapped](const AdaptiveEdge &e) {
- auto [v1, v2] = this->get_checked_verts_of_edge(e, verts_swapped);
- auto v1_index = v1.get_self_index();
- auto v2_index = v2.get_self_index();
- /* Need to swap the verts if v1 does not point to n1 */
- if (v1.get_node().value() != n1_index) {
- std::swap(v1_index, v2_index);
- }
- BLI_assert(this->get_checked_vert(v1_index).get_node().value() == n1_index);
- return std::make_tuple(v1_index, v2_index);
- };
/* Get all 3D edges */
const auto edge_indices = this->get_connecting_edge_indices(n1_a, n2_a);
@@ -857,7 +846,7 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
for (const auto &edge_index : edge_indices) {
/* Get v1 of the 3D edge in correct order */
const auto &e = this->get_checked_edge(edge_index);
- const auto [v1_index, v2_index] = get_v1_v2_indices(e);
+ const auto [v1_index, v2_index] = this->get_checked_vert_indices_of_edge_aligned_with_n1(e, n1_index);
const auto &v1 = this->get_checked_vert(v1_index);
const auto &v2 = this->get_checked_vert(v2_index);
More information about the Bf-blender-cvs
mailing list