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>2013-09-04 02:22:45 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-09-04 02:22:45 +0400
commit4ee18eaf12e0430c267054ff04952586fa461153 (patch)
tree485e060e3adf235c850d104842ad5b6cdb9ce4a4 /source/blender/blenkernel/intern/DerivedMesh.c
parent15fc16a49b7e11a45332851ba3357f7b04bc5439 (diff)
simplify length checks in DM_calc_auto_bump_scale
Diffstat (limited to 'source/blender/blenkernel/intern/DerivedMesh.c')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 7e069c20c24..c4c7cafb7e6 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -2741,11 +2741,9 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
int offs = 0; /* initial triangulation is 0,1,2 and 0, 2, 3 */
if (nr_verts == 4) {
float pos_len_diag0, pos_len_diag1;
- float vtmp[3];
- sub_v3_v3v3(vtmp, verts[2], verts[0]);
- pos_len_diag0 = dot_v3v3(vtmp, vtmp);
- sub_v3_v3v3(vtmp, verts[3], verts[1]);
- pos_len_diag1 = dot_v3v3(vtmp, vtmp);
+
+ pos_len_diag0 = len_squared_v3v3(verts[2], verts[0]);
+ pos_len_diag1 = len_squared_v3v3(verts[3], verts[1]);
if (pos_len_diag1 < pos_len_diag0) {
offs = 1; // alter split
@@ -2753,10 +2751,8 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
else if (pos_len_diag0 == pos_len_diag1) { /* do UV check instead */
float tex_len_diag0, tex_len_diag1;
- sub_v2_v2v2(vtmp, tex_coords[2], tex_coords[0]);
- tex_len_diag0 = dot_v2v2(vtmp, vtmp);
- sub_v2_v2v2(vtmp, tex_coords[3], tex_coords[1]);
- tex_len_diag1 = dot_v2v2(vtmp, vtmp);
+ tex_len_diag0 = len_squared_v2v2(tex_coords[2], tex_coords[0]);
+ tex_len_diag1 = len_squared_v2v2(tex_coords[3], tex_coords[1]);
if (tex_len_diag1 < tex_len_diag0) {
offs = 1; /* alter split */
@@ -2765,7 +2761,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
}
nr_tris_to_pile = nr_verts - 2;
if (nr_tris_to_pile == 1 || nr_tris_to_pile == 2) {
- const int indices[] = {offs + 0, offs + 1, offs + 2, offs + 0, offs + 2, (offs + 3) & 0x3 };
+ const int indices[6] = {offs + 0, offs + 1, offs + 2, offs + 0, offs + 2, (offs + 3) & 0x3 };
int t;
for (t = 0; t < nr_tris_to_pile; t++) {
float f2x_area_uv;
@@ -2785,7 +2781,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm)
cross_v3_v3v3(norm, v0, v1);
f2x_surf_area = len_v3(norm);
- fsurf_ratio = f2x_surf_area / f2x_area_uv; // tri area divided by texture area
+ fsurf_ratio = f2x_surf_area / f2x_area_uv; /* tri area divided by texture area */
nr_accumulated++;
dsum += (double)(fsurf_ratio);