From e03b1668e0106019eed6097678cdaf7df3885638 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 1 Aug 2013 17:15:11 +0000 Subject: code cleanup: remove unused functions - IsectLLPt2Df - isect_point_quad_uv_v2 - isect_point_face_uv_v2 These are obsoleted by resolve_tri_uv, resolve_quad_uv also add attributes for unused function results for some math functions. --- source/blender/blenlib/BLI_math_geom.h | 12 +- source/blender/blenlib/BLI_math_vector.h | 91 +++++----- source/blender/blenlib/intern/math_geom.c | 271 ++--------------------------- source/blender/modifiers/intern/MOD_skin.c | 2 +- 4 files changed, 69 insertions(+), 307 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index f9671f57acd..6cb7103be9b 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -147,10 +147,6 @@ int isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2], int isect_point_tri_v2_cw(const float pt[2], const float v1[2], const float v2[2], const float v3[2]); int isect_point_tri_v2_int(const int x1, const int y1, const int x2, const int y2, const int a, const int b); bool isect_point_tri_prism_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3]); -void isect_point_quad_uv_v2(const float v0[2], const float v1[2], const float v2[2], const float v3[2], - const float pt[2], float r_uv[2]); -void isect_point_face_uv_v2(const int isquad, const float v0[2], const float v1[2], const float v2[2], - const float v3[2], const float pt[2], float r_uv[2]); /* axis-aligned bounding box */ bool isect_aabb_aabb_v3(const float min1[3], const float max1[3], const float min2[3], const float max2[3]); @@ -198,7 +194,7 @@ void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3 void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const float v3[2], const float v4[2], const float co[2], float w[4]); -int barycentric_coords_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3]); +bool barycentric_coords_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3]); int barycentric_inside_triangle_v2(const float w[3]); void resolve_tri_uv(float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2]); @@ -273,9 +269,9 @@ MINLINE void madd_sh_shfl(float r[9], const float sh[3], const float f); float form_factor_quad(const float p[3], const float n[3], const float q0[3], const float q1[3], const float q2[3], const float q3[3]); -int form_factor_visible_quad(const float p[3], const float n[3], - const float v0[3], const float v1[3], const float v2[3], - float q0[3], float q1[3], float q2[3], float q3[3]); +bool form_factor_visible_quad(const float p[3], const float n[3], + const float v0[3], const float v1[3], const float v2[3], + float q0[3], float q1[3], float q2[3], float q3[3]); float form_factor_hemi_poly(float p[3], float n[3], float v1[3], float v2[3], float v3[3], float v4[3]); diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 38b377c640e..e05783004c7 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -47,6 +47,12 @@ extern "C" { # pragma GCC diagnostic ignored "-Wredundant-decls" #endif +#ifdef __GNUC__ +# define UNUSED_RESULT_ATTR __attribute__((warn_unused_result)) +#else +# define UNUSED_RESULT_ATTR +#endif + MINLINE void zero_v2(float r[2]); MINLINE void zero_v3(float r[3]); MINLINE void zero_v4(float r[4]); @@ -115,10 +121,10 @@ MINLINE void mul_v3_v3(float r[3], const float a[3]); MINLINE void mul_v3_v3v3(float r[3], const float a[3], const float b[3]); MINLINE void mul_v4_fl(float r[4], float f); MINLINE void mul_v4_v4fl(float r[3], const float a[3], float f); -MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3]); -MINLINE float dot_m3_v3_row_x(float M[3][3], const float a[3]); -MINLINE float dot_m3_v3_row_y(float M[3][3], const float a[3]); -MINLINE float dot_m3_v3_row_z(float M[3][3], const float a[3]); +MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3]) UNUSED_RESULT_ATTR; +MINLINE float dot_m3_v3_row_x(float M[3][3], const float a[3]) UNUSED_RESULT_ATTR; +MINLINE float dot_m3_v3_row_y(float M[3][3], const float a[3]) UNUSED_RESULT_ATTR; +MINLINE float dot_m3_v3_row_z(float M[3][3], const float a[3]) UNUSED_RESULT_ATTR; MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f); MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]); @@ -137,10 +143,10 @@ MINLINE void negate_v4_v4(float r[4], const float a[3]); MINLINE void negate_v3_short(short r[3]); -MINLINE float dot_v2v2(const float a[2], const float b[2]); -MINLINE float dot_v3v3(const float a[3], const float b[3]); +MINLINE float dot_v2v2(const float a[2], const float b[2]) UNUSED_RESULT_ATTR; +MINLINE float dot_v3v3(const float a[3], const float b[3]) UNUSED_RESULT_ATTR; -MINLINE float cross_v2v2(const float a[2], const float b[2]); +MINLINE float cross_v2v2(const float a[2], const float b[2]) UNUSED_RESULT_ATTR; MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]); MINLINE void add_newell_cross_v3_v3v3(float n[3], const float v_prev[3], const float v_curr[3]); @@ -149,20 +155,20 @@ MINLINE void star_m3_v3(float rmat[3][3], float a[3]); /*********************************** Length **********************************/ -MINLINE float len_squared_v2(const float v[2]); -MINLINE float len_squared_v3(const float v[3]); -MINLINE float len_manhattan_v2(const float v[2]); -MINLINE int len_manhattan_v2_int(const int v[2]); -MINLINE float len_manhattan_v3(const float v[3]); -MINLINE float len_v2(const float a[2]); -MINLINE float len_v2v2(const float a[2], const float b[2]); -MINLINE float len_squared_v2v2(const float a[2], const float b[2]); -MINLINE float len_squared_v3v3(const float a[3], const float b[3]); -MINLINE float len_manhattan_v2v2(const float a[2], const float b[2]); -MINLINE int len_manhattan_v2v2_int(const int a[2], const int b[2]); -MINLINE float len_manhattan_v3v3(const float a[3], const float b[3]); -MINLINE float len_v3(const float a[3]); -MINLINE float len_v3v3(const float a[3], const float b[3]); +MINLINE float len_squared_v2(const float v[2]) UNUSED_RESULT_ATTR; +MINLINE float len_squared_v3(const float v[3]) UNUSED_RESULT_ATTR; +MINLINE float len_manhattan_v2(const float v[2]) UNUSED_RESULT_ATTR; +MINLINE int len_manhattan_v2_int(const int v[2]) UNUSED_RESULT_ATTR; +MINLINE float len_manhattan_v3(const float v[3]) UNUSED_RESULT_ATTR; +MINLINE float len_v2(const float a[2]) UNUSED_RESULT_ATTR; +MINLINE float len_v2v2(const float a[2], const float b[2]) UNUSED_RESULT_ATTR; +MINLINE float len_squared_v2v2(const float a[2], const float b[2]) UNUSED_RESULT_ATTR; +MINLINE float len_squared_v3v3(const float a[3], const float b[3]) UNUSED_RESULT_ATTR; +MINLINE float len_manhattan_v2v2(const float a[2], const float b[2]) UNUSED_RESULT_ATTR; +MINLINE int len_manhattan_v2v2_int(const int a[2], const int b[2]) UNUSED_RESULT_ATTR; +MINLINE float len_manhattan_v3v3(const float a[3], const float b[3]) UNUSED_RESULT_ATTR; +MINLINE float len_v3(const float a[3]) UNUSED_RESULT_ATTR; +MINLINE float len_v3v3(const float a[3], const float b[3]) UNUSED_RESULT_ATTR; MINLINE float normalize_v2(float r[2]); MINLINE float normalize_v2_v2(float r[2], const float a[2]); @@ -194,35 +200,35 @@ void flip_v2_v2v2(float v[2], const float v1[2], const float v2[2]); /********************************* Comparison ********************************/ -MINLINE int is_zero_v3(const float a[3]); -MINLINE int is_zero_v4(const float a[4]); -MINLINE int is_one_v3(const float a[3]); +MINLINE int is_zero_v3(const float a[3]) UNUSED_RESULT_ATTR; +MINLINE int is_zero_v4(const float a[4]) UNUSED_RESULT_ATTR; +MINLINE int is_one_v3(const float a[3]) UNUSED_RESULT_ATTR; -MINLINE int equals_v2v2(const float v1[2], const float v2[2]); -MINLINE int equals_v3v3(const float a[3], const float b[3]); -MINLINE int compare_v2v2(const float a[2], const float b[2], const float limit); -MINLINE int compare_v3v3(const float a[3], const float b[3], const float limit); -MINLINE int compare_len_v3v3(const float a[3], const float b[3], const float limit); +MINLINE int equals_v2v2(const float v1[2], const float v2[2]) UNUSED_RESULT_ATTR; +MINLINE int equals_v3v3(const float a[3], const float b[3]) UNUSED_RESULT_ATTR; +MINLINE int compare_v2v2(const float a[2], const float b[2], const float limit) UNUSED_RESULT_ATTR; +MINLINE int compare_v3v3(const float a[3], const float b[3], const float limit) UNUSED_RESULT_ATTR; +MINLINE int compare_len_v3v3(const float a[3], const float b[3], const float limit) UNUSED_RESULT_ATTR; -MINLINE int compare_v4v4(const float a[4], const float b[4], const float limit); -MINLINE int equals_v4v4(const float a[4], const float b[4]); +MINLINE int compare_v4v4(const float a[4], const float b[4], const float limit) UNUSED_RESULT_ATTR; +MINLINE int equals_v4v4(const float a[4], const float b[4]) UNUSED_RESULT_ATTR; -MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]); +MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]) UNUSED_RESULT_ATTR; /********************************** Angles ***********************************/ /* - angle with 2 arguments is angle between vector */ /* - angle with 3 arguments is angle between 3 points at the middle point */ /* - angle_normalized_* is faster equivalent if vectors are normalized */ -float angle_v2v2(const float a[2], const float b[2]); -float angle_signed_v2v2(const float v1[2], const float v2[2]); -float angle_v2v2v2(const float a[2], const float b[2], const float c[2]); -float angle_normalized_v2v2(const float a[2], const float b[2]); -float angle_v3v3(const float a[3], const float b[3]); -float angle_v3v3v3(const float a[3], const float b[3], const float c[3]); -float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3]); -float angle_normalized_v3v3(const float v1[3], const float v2[3]); -float angle_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3]); +float angle_v2v2(const float a[2], const float b[2]) UNUSED_RESULT_ATTR; +float angle_signed_v2v2(const float v1[2], const float v2[2]) UNUSED_RESULT_ATTR; +float angle_v2v2v2(const float a[2], const float b[2], const float c[2]) UNUSED_RESULT_ATTR; +float angle_normalized_v2v2(const float a[2], const float b[2]) UNUSED_RESULT_ATTR; +float angle_v3v3(const float a[3], const float b[3]) UNUSED_RESULT_ATTR; +float angle_v3v3v3(const float a[3], const float b[3], const float c[3]) UNUSED_RESULT_ATTR; +float cos_v3v3v3(const float p1[3], const float p2[3], const float p3[3]) UNUSED_RESULT_ATTR; +float angle_normalized_v3v3(const float v1[3], const float v2[3]) UNUSED_RESULT_ATTR; +float angle_on_axis_v3v3v3_v3(const float v1[3], const float v2[3], const float v3[3], const float axis[3]) UNUSED_RESULT_ATTR; void angle_tri_v3(float angles[3], const float v1[3], const float v2[3], const float v3[3]); void angle_quad_v3(float angles[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3]); void angle_poly_v3(float *angles, const float *verts[3], int len); @@ -258,7 +264,7 @@ void axis_sort_v3(const float axis_values[3], int r_axis_order[3]); /***************************** Array Functions *******************************/ /* attempted to follow fixed length vertex functions. names could be improved*/ -double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size); +double dot_vn_vn(const float *array_src_a, const float *array_src_b, const int size) UNUSED_RESULT_ATTR; float normalize_vn_vn(float *array_tar, const float *array_src, const int size); float normalize_vn(float *array_tar, const int size); void range_vn_i(int *array_tar, const int size, const int start); @@ -283,6 +289,7 @@ void fill_vn_fl(float *array_tar, const int size, const float val); #ifdef BLI_MATH_GCC_WARN_PRAGMA # pragma GCC diagnostic pop #endif +#undef UNUSED_RESULT_ATTR #ifdef __cplusplus } diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 0e7ff521ce8..9b8fd0ad85b 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -695,60 +695,6 @@ int isect_line_sphere_v2(const float l1[2], const float l2[2], } } -/** - * \return - * -1: collinear - * 1: intersection - */ -static short IsectLLPt2Df(const float x0, const float y0, const float x1, const float y1, - const float x2, const float y2, const float x3, const float y3, float *xi, float *yi) - -{ - /* - * this function computes the intersection of the sent lines - * and returns the intersection point, note that the function assumes - * the lines intersect. the function can handle vertical as well - * as horizontal lines. note the function isn't very clever, it simply - * applies the math, but we don't need speed since this is a - * pre-processing step - */ - float c1, c2; /* constants of linear equations */ - float det_inv; /* the inverse of the determinant of the coefficient */ - float m1, m2; /* the slopes of each line */ - /* - * compute slopes, note the cludge for infinity, however, this will - * be close enough - */ - if (fabsf(x1 - x0) > 0.000001f) - m1 = (y1 - y0) / (x1 - x0); - else - return -1; /*m1 = (float)1e+10;*/ /* close enough to infinity */ - - if (fabsf(x3 - x2) > 0.000001f) - m2 = (y3 - y2) / (x3 - x2); - else - return -1; /*m2 = (float)1e+10;*/ /* close enough to infinity */ - - if (fabsf(m1 - m2) < 0.000001f) - return -1; /* parallel lines */ - - /* compute constants */ - - c1 = (y0 - m1 * x0); - c2 = (y2 - m2 * x2); - - /* compute the inverse of the determinate */ - - det_inv = 1.0f / (-m1 + m2); - - /* use Kramers rule to compute xi and yi */ - - *xi = ((-c2 + c1) * det_inv); - *yi = ((m2 * c1 - m1 * c2) * det_inv); - - return 1; -} - /* point in polygon (keep float and int versions in sync) */ bool isect_point_poly_v2(const float pt[2], const float verts[][2], const int nr) { @@ -1718,193 +1664,6 @@ void limit_dist_v3(float v1[3], float v2[3], const float dist) } } -/* Similar to LineIntersectsTriangleUV, except it operates on a quad and in 2d, assumes point is in quad */ -void isect_point_quad_uv_v2(const float v0[2], const float v1[2], const float v2[2], const float v3[2], - const float pt[2], float r_uv[2]) -{ - float x0, y0, x1, y1, wtot, v2d[2], w1, w2; - - /* used for parallel lines */ - float pt3d[3], l1[3], l2[3], pt_on_line[3]; - - /* compute 2 edges of the quad intersection point */ - if (IsectLLPt2Df(v0[0], v0[1], v1[0], v1[1], v2[0], v2[1], v3[0], v3[1], &x0, &y0) == 1) { - /* the intersection point between the quad-edge intersection and the point in the quad we want the uv's for */ - /* should never be paralle !! */ - /*printf("\tnot parallel 1\n");*/ - IsectLLPt2Df(pt[0], pt[1], x0, y0, v0[0], v0[1], v3[0], v3[1], &x1, &y1); - - /* Get the weights from the new intersection point, to each edge */ - v2d[0] = x1 - v0[0]; - v2d[1] = y1 - v0[1]; - w1 = len_v2(v2d); - - v2d[0] = x1 - v3[0]; /* some but for the other vert */ - v2d[1] = y1 - v3[1]; - w2 = len_v2(v2d); - wtot = w1 + w2; - /*w1 = w1/wtot;*/ - /*w2 = w2/wtot;*/ - r_uv[0] = w1 / wtot; - } - else { - /* lines are parallel, lambda_cp_line_ex is 3d grrr */ - /*printf("\tparallel1\n");*/ - pt3d[0] = pt[0]; - pt3d[1] = pt[1]; - pt3d[2] = l1[2] = l2[2] = 0.0f; - - l1[0] = v0[0]; - l1[1] = v0[1]; - l2[0] = v1[0]; - l2[1] = v1[1]; - closest_to_line_v3(pt_on_line, pt3d, l1, l2); - v2d[0] = pt[0] - pt_on_line[0]; /* same, for the other vert */ - v2d[1] = pt[1] - pt_on_line[1]; - w1 = len_v2(v2d); - - l1[0] = v2[0]; - l1[1] = v2[1]; - l2[0] = v3[0]; - l2[1] = v3[1]; - closest_to_line_v3(pt_on_line, pt3d, l1, l2); - v2d[0] = pt[0] - pt_on_line[0]; /* same, for the other vert */ - v2d[1] = pt[1] - pt_on_line[1]; - w2 = len_v2(v2d); - wtot = w1 + w2; - r_uv[0] = w1 / wtot; - } - - /* Same as above to calc the uv[1] value, alternate calculation */ - - if (IsectLLPt2Df(v0[0], v0[1], v3[0], v3[1], v1[0], v1[1], v2[0], v2[1], &x0, &y0) == 1) { /* was v0,v1 v2,v3 now v0,v3 v1,v2*/ - /* never paralle if above was not */ - /*printf("\tnot parallel2\n");*/ - IsectLLPt2Df(pt[0], pt[1], x0, y0, v0[0], v0[1], v1[0], v1[1], &x1, &y1); /* was v0,v3 now v0,v1*/ - - v2d[0] = x1 - v0[0]; - v2d[1] = y1 - v0[1]; - w1 = len_v2(v2d); - - v2d[0] = x1 - v1[0]; - v2d[1] = y1 - v1[1]; - w2 = len_v2(v2d); - wtot = w1 + w2; - r_uv[1] = w1 / wtot; - } - else { - /* lines are parallel, lambda_cp_line_ex is 3d grrr */ - /*printf("\tparallel2\n");*/ - pt3d[0] = pt[0]; - pt3d[1] = pt[1]; - pt3d[2] = l1[2] = l2[2] = 0.0f; - - - l1[0] = v0[0]; - l1[1] = v0[1]; - l2[0] = v3[0]; - l2[1] = v3[1]; - closest_to_line_v3(pt_on_line, pt3d, l1, l2); - v2d[0] = pt[0] - pt_on_line[0]; /* some but for the other vert */ - v2d[1] = pt[1] - pt_on_line[1]; - w1 = len_v2(v2d); - - l1[0] = v1[0]; - l1[1] = v1[1]; - l2[0] = v2[0]; - l2[1] = v2[1]; - closest_to_line_v3(pt_on_line, pt3d, l1, l2); - v2d[0] = pt[0] - pt_on_line[0]; /* some but for the other vert */ - v2d[1] = pt[1] - pt_on_line[1]; - w2 = len_v2(v2d); - wtot = w1 + w2; - r_uv[1] = w1 / wtot; - } - /* may need to flip UV's here */ -} - -/* same as above but does tri's and quads, tri's are a bit of a hack */ -void isect_point_face_uv_v2(const int isquad, - const float v0[2], const float v1[2], const float v2[2], const float v3[2], - const float pt[2], float r_uv[2]) -{ - if (isquad) { - isect_point_quad_uv_v2(v0, v1, v2, v3, pt, r_uv); - } - else { - /* not for quads, use for our abuse of LineIntersectsTriangleUV */ - float p1_3d[3], p2_3d[3], v0_3d[3], v1_3d[3], v2_3d[3], lambda; - - p1_3d[0] = p2_3d[0] = r_uv[0]; - p1_3d[1] = p2_3d[1] = r_uv[1]; - p1_3d[2] = 1.0f; - p2_3d[2] = -1.0f; - v0_3d[2] = v1_3d[2] = v2_3d[2] = 0.0; - - /* generate a new fuv, (this is possibly a non optimal solution, - * since we only need 2d calculation but use 3d func's) - * - * this method makes an imaginary triangle in 2d space using the UV's from the derived mesh face - * Then find new uv coords using the fuv and this face with LineIntersectsTriangleUV. - * This means the new values will be correct in relation to the derived meshes face. - */ - copy_v2_v2(v0_3d, v0); - copy_v2_v2(v1_3d, v1); - copy_v2_v2(v2_3d, v2); - - /* Doing this in 3D is not nice */ - isect_line_tri_v3(p1_3d, p2_3d, v0_3d, v1_3d, v2_3d, &lambda, r_uv); - } -} - -#if 0 /* XXX this version used to be used in isect_point_tri_v2_int() and was called IsPointInTri2D */ - -int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2]) -{ - float inp1, inp2, inp3; - - inp1 = (v2[0] - v1[0]) * (v1[1] - pt[1]) + (v1[1] - v2[1]) * (v1[0] - pt[0]); - inp2 = (v3[0] - v2[0]) * (v2[1] - pt[1]) + (v2[1] - v3[1]) * (v2[0] - pt[0]); - inp3 = (v1[0] - v3[0]) * (v3[1] - pt[1]) + (v3[1] - v1[1]) * (v3[0] - pt[0]); - - if (inp1 <= 0.0f && inp2 <= 0.0f && inp3 <= 0.0f) return 1; - if (inp1 >= 0.0f && inp2 >= 0.0f && inp3 >= 0.0f) return 1; - - return 0; -} -#endif - -#if 0 - -int isect_point_tri_v2(float v0[2], float v1[2], float v2[2], float pt[2]) -{ - /* not for quads, use for our abuse of LineIntersectsTriangleUV */ - float p1_3d[3], p2_3d[3], v0_3d[3], v1_3d[3], v2_3d[3]; - /* not used */ - float lambda, uv[3]; - - p1_3d[0] = p2_3d[0] = uv[0] = pt[0]; - p1_3d[1] = p2_3d[1] = uv[1] = uv[2] = pt[1]; - p1_3d[2] = 1.0f; - p2_3d[2] = -1.0f; - v0_3d[2] = v1_3d[2] = v2_3d[2] = 0.0; - - /* generate a new fuv, (this is possibly a non optimal solution, - * since we only need 2d calculation but use 3d func's) - * - * this method makes an imaginary triangle in 2d space using the UV's from the derived mesh face - * Then find new uv coords using the fuv and this face with LineIntersectsTriangleUV. - * This means the new values will be correct in relation to the derived meshes face. - */ - copy_v2_v2(v0_3d, v0); - copy_v2_v2(v1_3d, v1); - copy_v2_v2(v2_3d, v2); - - /* Doing this in 3D is not nice */ - return isect_line_tri_v3(p1_3d, p2_3d, v0_3d, v1_3d, v2_3d, &lambda, uv); -} -#endif - /* * x1,y2 * | \ @@ -2326,7 +2085,7 @@ int barycentric_inside_triangle_v2(const float w[3]) } /* returns 0 for degenerated triangles */ -int barycentric_coords_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3]) +bool barycentric_coords_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3]) { float x = co[0], y = co[1]; float x1 = v1[0], y1 = v1[1]; @@ -2339,10 +2098,10 @@ int barycentric_coords_v2(const float v1[2], const float v2[2], const float v3[2 w[1] = ((y3 - y1) * (x - x3) + (x1 - x3) * (y - y3)) / det; w[2] = 1.0f - w[0] - w[1]; - return 1; + return true; } - return 0; + return false; } /* used by projection painting @@ -3384,9 +3143,9 @@ static void vec_add_dir(float r[3], const float v1[3], const float v2[3], const r[2] = v1[2] + fac * (v2[2] - v1[2]); } -int form_factor_visible_quad(const float p[3], const float n[3], - const float v0[3], const float v1[3], const float v2[3], - float q0[3], float q1[3], float q2[3], float q3[3]) +bool form_factor_visible_quad(const float p[3], const float n[3], + const float v0[3], const float v1[3], const float v2[3], + float q0[3], float q1[3], float q2[3], float q3[3]) { static const float epsilon = 1e-6f; float c, sd[3]; @@ -3507,11 +3266,11 @@ int form_factor_visible_quad(const float p[3], const float n[3], } else if (sd[2] < 0) { /* --- */ - return 0; + return false; } else { /* --0 */ - return 0; + return false; } } else { @@ -3524,11 +3283,11 @@ int form_factor_visible_quad(const float p[3], const float n[3], } else if (sd[2] < 0) { /* -0- */ - return 0; + return false; } else { /* -00 */ - return 0; + return false; } } } @@ -3566,11 +3325,11 @@ int form_factor_visible_quad(const float p[3], const float n[3], } else if (sd[2] < 0) { /* 0-- */ - return 0; + return false; } else { /* 0-0 */ - return 0; + return false; } } else { @@ -3583,16 +3342,16 @@ int form_factor_visible_quad(const float p[3], const float n[3], } else if (sd[2] < 0) { /* 00- */ - return 0; + return false; } else { /* 000 */ - return 0; + return false; } } } - return 1; + return true; } /* altivec optimization, this works, but is unused */ diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 91dcf721e4b..df0a0266154 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -1039,7 +1039,7 @@ static int isect_ray_poly(const float ray_start[3], v_first = v; else if (v_prev != v_first) { float dist; - int curhit; + bool curhit; curhit = isect_ray_tri_v3(ray_start, ray_dir, v_first->co, v_prev->co, v->co, -- cgit v1.2.3