[Bf-blender-cvs] [82cc21d5e4b] master: Fix T77261: Multires creates spikes when subdividing ngons

Sergey Sharybin noreply at git.blender.org
Tue Nov 24 12:42:46 CET 2020


Commit: 82cc21d5e4b62aa191726c4d9d89d5f53a2197f7
Author: Sergey Sharybin
Date:   Tue Nov 24 12:40:42 2020 +0100
Branches: master
https://developer.blender.org/rB82cc21d5e4b62aa191726c4d9d89d5f53a2197f7

Fix T77261: Multires creates spikes when subdividing ngons

The spikes were caused by non-initialized tangent matrix used during
smoothing process. The reason tangent matrix was not initialized was
because wrong usage of API: n-gons should pass corner of 0 to the
matrix construction function.

Corrected usage of the API and added assert() to help catching such
kind of non-initialized issues easier.

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

M	source/blender/blenkernel/intern/multires_inline.h
M	source/blender/blenkernel/intern/multires_reshape_smooth.c

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

diff --git a/source/blender/blenkernel/intern/multires_inline.h b/source/blender/blenkernel/intern/multires_inline.h
index 49329698b3a..e85aa12781e 100644
--- a/source/blender/blenkernel/intern/multires_inline.h
+++ b/source/blender/blenkernel/intern/multires_inline.h
@@ -25,6 +25,7 @@
 
 #include "BKE_multires.h"
 #include "BLI_math_vector.h"
+#include "BLI_utildefines.h"
 
 BLI_INLINE void BKE_multires_construct_tangent_matrix(float tangent_matrix[3][3],
                                                       const float dPdu[3],
@@ -51,6 +52,9 @@ BLI_INLINE void BKE_multires_construct_tangent_matrix(float tangent_matrix[3][3]
     copy_v3_v3(tangent_matrix[1], dPdv);
     mul_v3_fl(tangent_matrix[0], -1.0f);
   }
+  else {
+    BLI_assert(!"Unhandled corner index");
+  }
   cross_v3_v3v3(tangent_matrix[2], dPdu, dPdv);
   normalize_v3(tangent_matrix[0]);
   normalize_v3(tangent_matrix[1]);
diff --git a/source/blender/blenkernel/intern/multires_reshape_smooth.c b/source/blender/blenkernel/intern/multires_reshape_smooth.c
index e12e692ea23..f10aae18142 100644
--- a/source/blender/blenkernel/intern/multires_reshape_smooth.c
+++ b/source/blender/blenkernel/intern/multires_reshape_smooth.c
@@ -1154,8 +1154,11 @@ static void reshape_subdiv_evaluate_limit_at_grid(
                                               dPdu,
                                               dPdv);
 
+  const int face_index = multires_reshape_grid_to_face_index(reshape_context,
+                                                             grid_coord->grid_index);
   const int corner = multires_reshape_grid_to_corner(reshape_context, grid_coord->grid_index);
-  BKE_multires_construct_tangent_matrix(r_tangent_matrix, dPdu, dPdv, corner);
+  multires_reshape_tangent_matrix_for_corner(
+      reshape_context, face_index, corner, dPdu, dPdv, r_tangent_matrix);
 }
 
 /** \} */



More information about the Bf-blender-cvs mailing list