From 25bbf99a79b0a1fa324dcd8d49bf80807b2d9672 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Oct 2010 05:18:45 +0000 Subject: replace SIDE_OF_LINE macro with line_point_side_v2() inline function. made a number of files build without unused warnings. --- source/blender/blenlib/BLI_math_vector.h | 2 ++ source/blender/blenlib/BLI_scanfill.h | 2 +- source/blender/blenlib/intern/math_geom.c | 27 +++++++++++----------- source/blender/blenlib/intern/math_vector_inline.c | 6 +++++ source/blender/blenlib/intern/scanfill.c | 2 +- 5 files changed, 23 insertions(+), 16 deletions(-) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index b160097a33d..5c17ac6b639 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -129,6 +129,8 @@ MINLINE int compare_len_v3v3(float a[3], float b[3], float limit); MINLINE int compare_v4v4(float a[4], float b[4], float limit); MINLINE int equals_v4v4(float a[4], float b[4]); +MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]); + /********************************** Angles ***********************************/ /* - angle with 2 arguments is angle between vector */ /* - angle with 3 arguments is angle between 3 points at the middle point */ diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h index 0ae40c0b83d..bae5375f757 100644 --- a/source/blender/blenlib/BLI_scanfill.h +++ b/source/blender/blenlib/BLI_scanfill.h @@ -50,7 +50,7 @@ extern "C" { /* scanfill.c: used in displist only... */ struct EditVert *BLI_addfillvert(float *vec); struct EditEdge *BLI_addfilledge(struct EditVert *v1, struct EditVert *v2); -int BLI_edgefill(int mode, int mat_nr); +int BLI_edgefill(int mat_nr); void BLI_end_edgefill(void); /* These callbacks are needed to make the lib finction properly */ diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 2aec707b4ea..c2e765388c8 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -336,20 +336,19 @@ static short IsectLLPt2Df(float x0,float y0,float x1,float y1, return 1; } // end Intersect_Lines -#define SIDE_OF_LINE(pa,pb,pp) ((pa[0]-pp[0])*(pb[1]-pp[1]))-((pb[0]-pp[0])*(pa[1]-pp[1])) /* point in tri */ -// XXX was called IsectPT2Df + int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2]) { - if (SIDE_OF_LINE(v1,v2,pt)>=0.0) { - if (SIDE_OF_LINE(v2,v3,pt)>=0.0) { - if (SIDE_OF_LINE(v3,v1,pt)>=0.0) { + if (line_point_side_v2(v1,v2,pt)>=0.0) { + if (line_point_side_v2(v2,v3,pt)>=0.0) { + if (line_point_side_v2(v3,v1,pt)>=0.0) { return 1; } } } else { - if (! (SIDE_OF_LINE(v2,v3,pt)>=0.0)) { - if (! (SIDE_OF_LINE(v3,v1,pt)>=0.0)) { + if (! (line_point_side_v2(v2,v3,pt)>=0.0)) { + if (! (line_point_side_v2(v3,v1,pt)>=0.0)) { return -1; } } @@ -360,18 +359,18 @@ int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2]) /* point in quad - only convex quads */ int isect_point_quad_v2(float pt[2], float v1[2], float v2[2], float v3[2], float v4[2]) { - if (SIDE_OF_LINE(v1,v2,pt)>=0.0) { - if (SIDE_OF_LINE(v2,v3,pt)>=0.0) { - if (SIDE_OF_LINE(v3,v4,pt)>=0.0) { - if (SIDE_OF_LINE(v4,v1,pt)>=0.0) { + if (line_point_side_v2(v1,v2,pt)>=0.0) { + if (line_point_side_v2(v2,v3,pt)>=0.0) { + if (line_point_side_v2(v3,v4,pt)>=0.0) { + if (line_point_side_v2(v4,v1,pt)>=0.0) { return 1; } } } } else { - if (! (SIDE_OF_LINE(v2,v3,pt)>=0.0)) { - if (! (SIDE_OF_LINE(v3,v4,pt)>=0.0)) { - if (! (SIDE_OF_LINE(v4,v1,pt)>=0.0)) { + if (! (line_point_side_v2(v2,v3,pt)>=0.0)) { + if (! (line_point_side_v2(v3,v4,pt)>=0.0)) { + if (! (line_point_side_v2(v4,v1,pt)>=0.0)) { return -1; } } diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 2f75fcead79..a45356f0bde 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -454,5 +454,11 @@ MINLINE int compare_v4v4(float *v1, float *v2, float limit) return 0; } +MINLINE float line_point_side_v2(const float *l1, const float *l2, const float *pt) +{ + return ((l1[0]-pt[0]) * (l2[1]-pt[1])) - + ((l2[0]-pt[0]) * (l1[1]-pt[1])); +} + #endif /* BLI_MATH_VECTOR_INLINE */ diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 7896ebdd263..85af307be16 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -747,7 +747,7 @@ static void scanfill(PolyFill *pf, int mat_nr) -int BLI_edgefill(int mode, int mat_nr) +int BLI_edgefill(int mat_nr) { /* - fill works with its own lists, so create that first (no faces!) -- cgit v1.2.3