[Bf-blender-cvs] [84562e2eac6] soc-2021-adaptive-cloth: adaptive_cloth: fix: AdaptiveMesh: anisotropic flip check

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


Commit: 84562e2eac6e62515b13d7491ddd382e5fc0fbb2
Author: ishbosamiya
Date:   Thu Aug 5 12:38:43 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB84562e2eac6e62515b13d7491ddd382e5fc0fbb2

adaptive_cloth: fix: AdaptiveMesh: anisotropic flip check

Based on the next paper by the same authors, "Folding and Crumpling
Adaptive Sheets". The edge flip criterion is different. So using this
now.

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

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 b2c36698dd2..ff41883a14e 100644
--- a/source/blender/blenkernel/BKE_cloth_remesh.hh
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -23,7 +23,7 @@
  * \ingroup bke
  */
 
-/**********************************************************************
+/*********************************************************************************
  * references
  *
  * [1] "Adaptive Anisotropic Remeshing for Cloth Simulation" by Rahul
@@ -34,7 +34,13 @@
  * efficient and fast management of multiresolution meshes" by
  * Frutuoso G. M. Silva and Abel J. P. Gomes (GRAPHITE '03)
  * https://doi.org/10.1145/604471.604503
- * ********************************************************************/
+ *
+ * [3] "Folding and Crumpling Adaptive Sheets" by Rahul Narain, Tobias
+ * Pfaff, James F.O'Brien (SIGGRAPH 2013).
+ * https://dl.acm.org/doi/10.1145/2461912.2462010
+ * http://graphics.berkeley.edu/papers/Narain-FCA-2013-07/Narain-FCA-2013-07.pdf
+ *
+ * *****************************************************************************/
 
 #include "BKE_mesh.h"
 #include "BLI_assert.h"
diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc
index 6cebc346095..e79e5b058b9 100644
--- a/source/blender/blenkernel/intern/cloth_remesh.cc
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -478,10 +478,16 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
    * Note: this is not the same as `Mesh::is_edge_flippable`, this is
    * specific to `AdaptiveMesh`.
    *
-   * Reference [1]
+   * Reference [1] and [3]
+   *
+   * In this case considering [3] to be higher priority since both are
+   * contradicting each other.
    */
   bool is_edge_flippable_anisotropic_aware(const AdaptiveEdge &edge) const
   {
+    /* TODO(ish): expose alpha to the user */
+    auto alpha = 0.1;
+
     if (this->is_edge_loose_or_on_seam_or_boundary(edge)) {
       return false;
     }
@@ -516,9 +522,18 @@ class AdaptiveMesh : public Mesh<NodeData<END>, VertData, EdgeData, internal::Em
 
     const auto m_avg = (m_i + m_j + m_k + m_l) * 0.25;
 
-    return cross_2d(u_jk, u_ik) * float2::dot(u_il, m_avg * u_jl) +
-               float2::dot(u_jk, m_avg * u_ik) * cross_2d(u_il, u_jl) <
-           0.0;
+    const auto lhs = cross_2d(u_jk, u_ik) * float2::dot(u_il, m_avg * u_jl) +
+                     float2::dot(u_jk, m_avg * u_ik) * cross_2d(u_il, u_jl);
+
+    /* Based on [1], should be flippable if res < 0.
+     *
+     * Based on [3], should be flippable if res >= 0 but then there is
+     * another part that mentions that flippable if res falls some
+     * calculated value. So taking that route as of now.
+     */
+    const auto rhs = -alpha * (cross_2d(u_jk, u_ik) + cross_2d(u_il, u_jl));
+
+    return lhs < rhs;
   }
 
   /**



More information about the Bf-blender-cvs mailing list