diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-04-18 03:30:19 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-04-18 03:30:19 +0400 |
commit | 4a7feafa496b27d21b93d7ff459e580edb00d148 (patch) | |
tree | 732e84c0da36c170c64b64f3aa06219434981310 /source | |
parent | ed1a08382f2b9f9d11661d2f4c68c496c49f274a (diff) |
Support object scale for mesh display options. (currently only uniform scale for thickness test)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/editderivedmesh.c | 18 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_math_matrix.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 12 |
3 files changed, 28 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c index 6435e6e98a7..1f6c99bfaaa 100644 --- a/source/blender/blenkernel/intern/editderivedmesh.c +++ b/source/blender/blenkernel/intern/editderivedmesh.c @@ -1576,6 +1576,11 @@ static void statvis_calc_overhang( axis_from_enum_v3(dir, axis); + if (LIKELY(em->ob)) { + mul_transposed_mat3_m4_v3(em->ob->obmat, dir); + normalize_v3(dir); + } + /* now convert into global space */ BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, index) { float fac = angle_normalized_v3v3(polyNos ? polyNos[index] : f->no, dir) / (float)M_PI; @@ -1667,7 +1672,7 @@ static void statvis_calc_thickness( if (vertexCos) { cos[0] = vertexCos[BM_elem_index_get(ltri[0]->v)]; cos[1] = vertexCos[BM_elem_index_get(ltri[1]->v)]; - cos[3] = vertexCos[BM_elem_index_get(ltri[2]->v)]; + cos[2] = vertexCos[BM_elem_index_get(ltri[2]->v)]; } else { cos[0] = ltri[0]->v->co; @@ -1805,6 +1810,7 @@ void BKE_editmesh_statvis_calc(BMEditMesh *em, DerivedMesh *dm, switch (statvis->type) { case SCE_STATVIS_OVERHANG: + { statvis_calc_overhang( em, bmdm ? bmdm->polyNos : NULL, statvis->overhang_min / (float)M_PI, @@ -1812,18 +1818,24 @@ void BKE_editmesh_statvis_calc(BMEditMesh *em, DerivedMesh *dm, statvis->overhang_axis, r_face_colors); break; + } case SCE_STATVIS_THICKNESS: + { + const float scale = 1.0f / mat4_to_scale(em->ob->obmat); statvis_calc_thickness( em, bmdm ? bmdm->vertexCos : NULL, - statvis->thickness_min, - statvis->thickness_max, + statvis->thickness_min * scale, + statvis->thickness_max * scale, statvis->thickness_samples, r_face_colors); break; + } case SCE_STATVIS_INTERSECT: + { statvis_calc_intersect( em, bmdm ? bmdm->vertexCos : NULL, r_face_colors); break; + } } } diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 9c5d3c5b93c..ada2d43b81f 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -98,6 +98,7 @@ void mul_m3_v3(float M[3][3], float r[3]); void mul_v3_m3v3(float r[3], float M[3][3], const float a[3]); void mul_v2_m3v3(float r[2], float M[3][3], const float a[3]); void mul_transposed_m3_v3(float M[3][3], float r[3]); +void mul_transposed_mat3_m4_v3(float M[4][4], float r[3]); void mul_m3_v3_double(float M[3][3], double r[3]); void mul_m3_fl(float R[3][3], float f); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 1ec63f11c3d..d9063b80f13 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -445,6 +445,18 @@ void mul_transposed_m3_v3(float mat[3][3], float vec[3]) vec[2] = x * mat[2][0] + y * mat[2][1] + mat[2][2] * vec[2]; } +void mul_transposed_mat3_m4_v3(float mat[4][4], float vec[3]) +{ + float x, y; + + x = vec[0]; + y = vec[1]; + vec[0] = x * mat[0][0] + y * mat[0][1] + mat[0][2] * vec[2]; + vec[1] = x * mat[1][0] + y * mat[1][1] + mat[1][2] * vec[2]; + vec[2] = x * mat[2][0] + y * mat[2][1] + mat[2][2] * vec[2]; +} + + void mul_m3_fl(float m[3][3], float f) { int i, j; |