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:
authorCampbell Barton <ideasman42@gmail.com>2015-07-14 15:09:14 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-07-14 15:29:31 +0300
commit2cffd6649b0e9b646bc090e4bba90e9873fb2982 (patch)
treea09d92b8b332ec417a826937bf298c283a5dc3d4
parent655f498ca7acc94df01200452d70507dc5027096 (diff)
Match face tessellation order in edimode
add a negated version of axis_dominant_v3_to_m3
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c4
-rw-r--r--source/blender/blenlib/BLI_math_geom.h1
-rw-r--r--source/blender/blenlib/intern/math_geom.c19
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c12
4 files changed, 28 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 00a82727e59..40a299ef343 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -2420,7 +2420,7 @@ int BKE_mesh_recalc_tessellation(
co_prev = mvert[ml[mp_totloop - 1].v].co;
for (j = 0; j < mp_totloop; j++, ml++) {
co_curr = mvert[ml->v].co;
- add_newell_cross_v3_v3v3(normal, co_curr, co_prev);
+ add_newell_cross_v3_v3v3(normal, co_prev, co_curr);
co_prev = co_curr;
}
if (UNLIKELY(normalize_v3(normal) == 0.0f)) {
@@ -2428,7 +2428,7 @@ int BKE_mesh_recalc_tessellation(
}
/* project verts to 2d */
- axis_dominant_v3_to_m3(axis_mat, normal);
+ axis_dominant_v3_to_m3_negate(axis_mat, normal);
ml = mloop + mp_loopstart;
for (j = 0; j < mp_totloop; j++, ml++) {
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 2c91aca27ef..359e2a97d9f 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -351,6 +351,7 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
float form_factor_hemi_poly(float p[3], float n[3],
float v1[3], float v2[3], float v3[3], float v4[3]);
+void axis_dominant_v3_to_m3_negate(float r_mat[3][3], const float normal[3]);
void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3]);
MINLINE void axis_dominant_v3(int *r_axis_a, int *r_axis_b, const float axis[3]);
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 7329a1177a8..f40f1cc3f97 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -2402,6 +2402,25 @@ void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3])
BLI_assert((fabsf(dot_m3_v3_row_z(r_mat, normal) - 1.0f) < BLI_ASSERT_UNIT_EPSILON) || is_zero_v3(normal));
}
+/**
+ * Same as axis_dominant_v3_to_m3, but flips the normal
+ */
+void axis_dominant_v3_to_m3_negate(float r_mat[3][3], const float normal[3])
+{
+ BLI_ASSERT_UNIT_V3(normal);
+
+ negate_v3_v3(r_mat[2], normal);
+ ortho_basis_v3v3_v3(r_mat[0], r_mat[1], r_mat[2]);
+
+ BLI_ASSERT_UNIT_V3(r_mat[0]);
+ BLI_ASSERT_UNIT_V3(r_mat[1]);
+
+ transpose_m3(r_mat);
+
+ BLI_assert(!is_negative_m3(r_mat));
+ BLI_assert((dot_m3_v3_row_z(r_mat, normal) < BLI_ASSERT_UNIT_EPSILON) || is_zero_v3(normal));
+}
+
/****************************** Interpolation ********************************/
static float tri_signed_area(const float v1[3], const float v2[3], const float v3[3], const int i, const int j)
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index d2d31d6a562..1318ad0f7fa 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -856,14 +856,14 @@ void BM_face_triangulate(
const int last_tri = f->len - 3;
int i;
- axis_dominant_v3_to_m3(axis_mat, f->no);
+ axis_dominant_v3_to_m3_negate(axis_mat, f->no);
for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f); i < f->len; i++, l_iter = l_iter->next) {
loops[i] = l_iter;
mul_v2_m3v3(projverts[i], axis_mat, l_iter->v->co);
}
- BLI_polyfill_calc_arena((const float (*)[2])projverts, f->len, -1, tris,
+ BLI_polyfill_calc_arena((const float (*)[2])projverts, f->len, 1, tris,
pf_arena);
if (use_beauty) {
@@ -1259,7 +1259,7 @@ void BM_bmesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptr
l_arr = BLI_memarena_alloc(arena, sizeof(*l_arr) * efa->len);
projverts = BLI_memarena_alloc(arena, sizeof(*projverts) * efa->len);
- axis_dominant_v3_to_m3(axis_mat, efa->no);
+ axis_dominant_v3_to_m3_negate(axis_mat, efa->no);
j = 0;
l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
@@ -1269,15 +1269,15 @@ void BM_bmesh_calc_tessellation(BMesh *bm, BMLoop *(*looptris)[3], int *r_looptr
j++;
} while ((l_iter = l_iter->next) != l_first);
- BLI_polyfill_calc_arena((const float (*)[2])projverts, efa->len, -1, tris, arena);
+ BLI_polyfill_calc_arena((const float (*)[2])projverts, efa->len, 1, tris, arena);
for (j = 0; j < totfilltri; j++) {
BMLoop **l_ptr = looptris[i++];
unsigned int *tri = tris[j];
- l_ptr[0] = l_arr[tri[2]];
+ l_ptr[0] = l_arr[tri[0]];
l_ptr[1] = l_arr[tri[1]];
- l_ptr[2] = l_arr[tri[0]];
+ l_ptr[2] = l_arr[tri[2]];
}
BLI_memarena_clear(arena);