Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorishbosamiya <ishbosamiya@gmail.com>2019-07-30 22:48:15 +0300
committerishbosamiya <ishbosamiya@gmail.com>2019-07-30 22:48:31 +0300
commitfd08bbb95d6593e3ea65d8ca7e048c7975011513 (patch)
treef6262725de36b0d5fcf581e898624a159ca457bb
parent5c9c25a99fba9bd1c9add6a4bea1dd9218f3bef6 (diff)
Cloth: fix bug in invert_m2_m2()
-rw-r--r--source/blender/blenkernel/intern/cloth_remeshing.cpp19
-rw-r--r--source/blender/blenlib/intern/math_matrix.c2
2 files changed, 18 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp
index 13a9c98db20..bc65e25f398 100644
--- a/source/blender/blenkernel/intern/cloth_remeshing.cpp
+++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp
@@ -84,6 +84,9 @@ typedef map<BMVert *, ClothVertex> ClothVertMap;
#define FACE_SIZING_DEBUG 0
#define FACE_SIZING_DEBUG_COMP 0
#define FACE_SIZING_DEBUG_OBS 1
+#define FACE_SIZING_DEBUG_SIZE 0
+
+#define INVERT_EPSILON 0.00001f
#define NEXT(x) ((x) < 2 ? (x) + 1 : (x)-2)
#define PREV(x) ((x) > 0 ? (x)-1 : (x) + 2)
@@ -652,7 +655,9 @@ static void cloth_remeshing_find_bad_edges(BMesh *bm, ClothVertMap &cvm, vector<
BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
float size = cloth_remeshing_edge_size(bm, e, cvm);
#if FACE_SIZING_DEBUG
+# if FACE_SIZING_DEBUG_SIZE
printf("size: %f in %s\n", size, __func__);
+# endif
#endif
if (size > 1.0f) {
edge_pairs.push_back(make_pair(size, e));
@@ -1928,12 +1933,22 @@ static void cloth_remeshing_derivative(
float face_dm[2][2];
float face_dm_inv[2][2];
cloth_remeshing_face_data(bm, f, face_dm);
- if (invert_m2_m2(face_dm_inv, face_dm, 0.001f) == false) {
+ if (invert_m2_m2(face_dm_inv, face_dm, INVERT_EPSILON) == false) {
zero_m2(face_dm_inv);
}
transpose_m2(face_dm_inv);
mul_v2_m2v2(r_vec, face_dm_inv, temp_vec);
+#if FACE_SIZING_DEBUG_OBS
+ printf("face_dm: ");
+ print_m2(face_dm);
+ printf("face_dm_inv: ");
+ print_m2(face_dm_inv);
+ printf("temp_vec: ");
+ print_v2(temp_vec);
+ printf("r_vec: ");
+ print_v2(r_vec);
+#endif
}
static void cloth_remeshing_derivative(
@@ -1948,7 +1963,7 @@ static void cloth_remeshing_derivative(
float face_dm[2][2];
float face_dm_inv[2][2];
cloth_remeshing_face_data(bm, f, face_dm);
- if (invert_m2_m2(face_dm_inv, face_dm, 0.001f) == false) {
+ if (invert_m2_m2(face_dm_inv, face_dm, INVERT_EPSILON) == false) {
zero_m2(face_dm_inv);
}
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index ded86e184be..7b52495b216 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -974,7 +974,7 @@ float determinant_m4_mat3_array(const float m[4][4])
bool invert_m2_m2(float r[2][2], float m[2][2], float epsilon)
{
float det = determinant_m2(m[0][0], m[0][1], m[1][0], m[1][1]);
- if (fabsf(det) > epsilon) {
+ if (fabsf(det) < epsilon) {
return false;
}
r[0][0] = m[1][1];