From 20a4e338379581e4ca8c96f3fc1d8bad76e8ee36 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 27 Mar 2014 07:31:21 +1100 Subject: [PATCH] Code cleanup: use consistent arg order for math api poly funcs --- source/blender/blenkernel/intern/mesh_evaluate.c | 2 +- source/blender/blenlib/BLI_math_geom.h | 6 +++--- source/blender/blenlib/intern/math_geom.c | 15 ++++++++------- source/blender/blenlib/intern/polyfill2d.c | 2 +- source/blender/bmesh/intern/bmesh_polygon.c | 7 ++++++- source/blender/editors/uvedit/uvedit_draw.c | 4 ++-- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c index 01e3b7bd3d3..5d10c12b8e0 100644 --- a/source/blender/blenkernel/intern/mesh_evaluate.c +++ b/source/blender/blenkernel/intern/mesh_evaluate.c @@ -904,7 +904,7 @@ float BKE_mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart, } /* finally calculate the area */ - area = area_poly_v3(mpoly->totloop, vertexcos, no); + area = area_poly_v3((const float (*)[3])vertexcos, (unsigned int)mpoly->totloop, no); return area; } diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index db32701c3ed..db71eeb8770 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -55,11 +55,11 @@ MINLINE float area_tri_signed_v2(const float v1[2], const float v2[2], const flo float area_tri_v3(const float a[3], const float b[3], const float c[3]); float area_tri_signed_v3(const float v1[3], const float v2[3], const float v3[3], const float normal[3]); float area_quad_v3(const float a[3], const float b[3], const float c[3], const float d[3]); -float area_poly_v3(int nr, float verts[][3], const float normal[3]); -float area_poly_v2(int nr, float verts[][2]); +float area_poly_v3(const float verts[][3], unsigned int nr, const float normal[3]); +float area_poly_v2(const float verts[][2], unsigned int nr); MINLINE float cross_tri_v2(const float v1[2], const float v2[2], const float v3[2]); -float cross_poly_v2(int nr, float verts[][2]); +float cross_poly_v2(const float verts[][2], unsigned int nr); /********************************* Planes **********************************/ diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 72b8f1ce024..6a812814afe 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -134,12 +134,13 @@ float area_tri_signed_v3(const float v1[3], const float v2[3], const float v3[3] return area; } -float area_poly_v3(int nr, float verts[][3], const float normal[3]) +float area_poly_v3(const float verts[][3], unsigned int nr, const float normal[3]) { - int a, px, py; + unsigned int a; + int px, py; const float max = axis_dominant_v3_max(&px, &py, normal); float area; - float *co_curr, *co_prev; + const float *co_curr, *co_prev; /* The Trapezium Area Rule */ co_prev = verts[nr - 1]; @@ -154,9 +155,9 @@ float area_poly_v3(int nr, float verts[][3], const float normal[3]) return fabsf(0.5f * area / max); } -float cross_poly_v2(int nr, float verts[][2]) +float cross_poly_v2(const float verts[][2], unsigned int nr) { - int a; + unsigned int a; float cross; const float *co_curr, *co_prev; @@ -173,9 +174,9 @@ float cross_poly_v2(int nr, float verts[][2]) return cross; } -float area_poly_v2(int nr, float verts[][2]) +float area_poly_v2(const float verts[][2], unsigned int nr) { - return fabsf(0.5f * cross_poly_v2(nr, verts)); + return fabsf(0.5f * cross_poly_v2(verts, nr)); } /********************************* Planes **********************************/ diff --git a/source/blender/blenlib/intern/polyfill2d.c b/source/blender/blenlib/intern/polyfill2d.c index 0b1b461ff73..6dff597c530 100644 --- a/source/blender/blenlib/intern/polyfill2d.c +++ b/source/blender/blenlib/intern/polyfill2d.c @@ -400,7 +400,7 @@ void BLI_polyfill_calc_ex( pf.tris_tot = 0; if ((coords_tot < 3) || - cross_poly_v2((int)coords_tot, (float(*)[2])coords) > 0.0f) + cross_poly_v2(coords, coords_tot) > 0.0f) { for (i = 0; i < coords_tot; i++) { indices[i] = i; diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 75f595dfedd..3093cba663f 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -248,7 +248,7 @@ float BM_face_calc_area(BMFace *f) else { float normal[3]; calc_poly_normal(normal, verts, f->len); - area = area_poly_v3(f->len, verts, normal); + area = area_poly_v3((const float (*)[3])verts, f->len, normal); } return area; @@ -1061,7 +1061,12 @@ void BM_face_legal_splits(BMFace *f, BMLoop *(*loops)[2], int len) for (i = 0, l = BM_FACE_FIRST_LOOP(f); i < f->len; i++, l = l->next) { BM_elem_index_set(l, i); /* set_loop */ mul_v2_m3v3(projverts[i], axis_mat, l->v->co); + } + /* first test for completely convex face */ + + + for (i = 0, l = BM_FACE_FIRST_LOOP(f); i < f->len; i++, l = l->next) { out[0] = max_ff(out[0], projverts[i][0]); out[1] = max_ff(out[1], projverts[i][1]); } diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 9be3f395fbd..62a3b138632 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -205,7 +205,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe uv_poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa->len); totarea += BM_face_calc_area(efa); - totuvarea += area_poly_v2(efa->len, tf_uv); + totuvarea += area_poly_v2((const float (*)[2])tf_uv, efa->len); if (uvedit_face_visible_test(scene, ima, efa, tf)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); @@ -248,7 +248,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe uv_poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa->len); - uvarea = area_poly_v2(efa->len, tf_uv) / totuvarea; + uvarea = area_poly_v2((const float (*)[2])tf_uv, efa->len) / totuvarea; if (area < FLT_EPSILON || uvarea < FLT_EPSILON) areadiff = 1.0f;