Support object scale for mesh display options. (currently only uniform scale for...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 17 Apr 2013 23:30:19 +0000 (23:30 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 17 Apr 2013 23:30:19 +0000 (23:30 +0000)
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenlib/BLI_math_matrix.h
source/blender/blenlib/intern/math_matrix.c

index 6435e6e98a7aa430b0358f2dbd02d246336b3740..1f6c99bfaaaa155624a18d0b084efad4fa1e8814 100644 (file)
@@ -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;
+               }
        }
 }
index 9c5d3c5b93c6ebff9718084fb37a58477d8c5237..ada2d43b81fbefefd8b6f09d13ec300de2e8e9a5 100644 (file)
@@ -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);
index 1ec63f11c3d79f6b7cc86fa4896c43de5d4fe954..d9063b80f13fe22e6927cd13d3e1301fa029c1fe 100644 (file)
@@ -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;