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:
authorBastien Montagne <montagne29@wanadoo.fr>2014-07-30 13:00:59 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-07-30 14:19:41 +0400
commit74758576fc9c1220563c86ce47a17c51d08a6d4f (patch)
tree2291df8ac132913345f87322a473d19f650ce25c /source/blender/blenlib/intern/math_geom.c
parenteea7521e21f9aed1c996dde5b248c5c8d5926440 (diff)
Cleanup: general cleanup in BLI_math code (mostly, use 'const' where possible, true/false for booleans, format for float litterals).
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r--source/blender/blenlib/intern/math_geom.c230
1 files changed, 114 insertions, 116 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 2cd32b3dca9..54e3545a3f1 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -568,7 +568,7 @@ int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[
{
float a1, a2, b1, b2, c1, c2, d;
float u, v;
- const float eps = 0.000001f;
+ const float eps = 1e-6f;
const float eps_sq = eps * eps;
a1 = v2[0] - v1[0];
@@ -1278,13 +1278,13 @@ bool isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3],
static bool getLowestRoot(const float a, const float b, const float c, const float maxR, float *root)
{
/* Check if a solution exists */
- float determinant = b * b - 4.0f * a * c;
+ const float determinant = b * b - 4.0f * a * c;
/* If determinant is negative it means no solutions. */
if (determinant >= 0.0f) {
/* calculate the two roots: (if determinant == 0 then
* x1==x2 but lets disregard that slight optimization) */
- float sqrtD = sqrtf(determinant);
+ const float sqrtD = sqrtf(determinant);
float r1 = (-b - sqrtD) / (2.0f * a);
float r2 = (-b + sqrtD) / (2.0f * a);
@@ -1295,18 +1295,18 @@ static bool getLowestRoot(const float a, const float b, const float c, const flo
/* Get lowest root: */
if (r1 > 0.0f && r1 < maxR) {
*root = r1;
- return 1;
+ return true;
}
/* It is possible that we want x2 - this can happen */
/* if x1 < 0 */
if (r2 > 0.0f && r2 < maxR) {
*root = r2;
- return 1;
+ return true;
}
}
/* No (valid) solutions */
- return 0;
+ return false;
}
bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const float radius,
@@ -1335,7 +1335,7 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const fl
if (fabsf(nordotv) < 0.000001f) {
if (fabsf(a) >= radius) {
- return 0;
+ return false;
}
}
else {
@@ -1377,7 +1377,7 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const fl
//(((unsigned int)z)& ~(((unsigned int)x)|((unsigned int)y))) & 0x80000000) {
*r_lambda = t0;
copy_v3_v3(ipoint, point);
- return 1;
+ return true;
}
}
@@ -1394,7 +1394,7 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const fl
if (getLowestRoot(a, b, c, *r_lambda, r_lambda)) {
copy_v3_v3(ipoint, v0);
- found_by_sweep = 1;
+ found_by_sweep = true;
}
/*v1*/
@@ -1404,7 +1404,7 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const fl
if (getLowestRoot(a, b, c, *r_lambda, r_lambda)) {
copy_v3_v3(ipoint, v1);
- found_by_sweep = 1;
+ found_by_sweep = true;
}
/*v2*/
@@ -1414,7 +1414,7 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const fl
if (getLowestRoot(a, b, c, *r_lambda, r_lambda)) {
copy_v3_v3(ipoint, v2);
- found_by_sweep = 1;
+ found_by_sweep = true;
}
/*---test edges---*/
@@ -1440,7 +1440,7 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const fl
copy_v3_v3(ipoint, e1);
mul_v3_fl(ipoint, e);
add_v3_v3(ipoint, v0);
- found_by_sweep = 1;
+ found_by_sweep = true;
}
}
@@ -1462,7 +1462,7 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const fl
copy_v3_v3(ipoint, e2);
mul_v3_fl(ipoint, e);
add_v3_v3(ipoint, v0);
- found_by_sweep = 1;
+ found_by_sweep = true;
}
}
@@ -1489,7 +1489,7 @@ bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const fl
copy_v3_v3(ipoint, e3);
mul_v3_fl(ipoint, e);
add_v3_v3(ipoint, v1);
- found_by_sweep = 1;
+ found_by_sweep = true;
}
}
@@ -1508,10 +1508,10 @@ bool isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3
return isect_line_tri_v3(p1, p2, v0, v1, v2, lambda);
/* first a simple bounding box test */
- if (min_fff(v0[a1], v1[a1], v2[a1]) > p1[a1]) return 0;
- if (min_fff(v0[a2], v1[a2], v2[a2]) > p1[a2]) return 0;
- if (max_fff(v0[a1], v1[a1], v2[a1]) < p1[a1]) return 0;
- if (max_fff(v0[a2], v1[a2], v2[a2]) < p1[a2]) return 0;
+ if (min_fff(v0[a1], v1[a1], v2[a1]) > p1[a1]) return false;
+ if (min_fff(v0[a2], v1[a2], v2[a2]) > p1[a2]) return false;
+ if (max_fff(v0[a1], v1[a1], v2[a1]) < p1[a1]) return false;
+ if (max_fff(v0[a2], v1[a2], v2[a2]) < p1[a2]) return false;
/* then a full intersection test */
#endif
@@ -1521,7 +1521,7 @@ bool isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3
sub_v3_v3v3(p, v0, p1);
f = (e2[a1] * e1[a2] - e2[a2] * e1[a1]);
- if ((f > -0.000001f) && (f < 0.000001f)) return 0;
+ if ((f > -0.000001f) && (f < 0.000001f)) return false;
v = (p[a2] * e1[a1] - p[a1] * e1[a2]) / f;
if ((v < 0.0f) || (v > 1.0f)) return 0;
@@ -1529,7 +1529,7 @@ bool isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3
f = e1[a1];
if ((f > -0.000001f) && (f < 0.000001f)) {
f = e1[a2];
- if ((f > -0.000001f) && (f < 0.000001f)) return 0;
+ if ((f > -0.000001f) && (f < 0.000001f)) return false;
u = (-p[a2] - v * e2[a2]) / f;
}
else
@@ -1539,9 +1539,9 @@ bool isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3
*r_lambda = (p[a0] + u * e1[a0] + v * e2[a0]) / (p2[a0] - p1[a0]);
- if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) return 0;
+ if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) return false;
- return 1;
+ return true;
}
/**
@@ -1616,9 +1616,9 @@ int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3],
}
}
-/* Intersection point strictly between the two lines
- * 0 when no intersection is found
- * */
+/** Intersection point strictly between the two lines
+ * \return false when no intersection is found
+ */
bool isect_line_line_strict_v3(const float v1[3], const float v2[3],
const float v3[3], const float v4[3],
float vi[3], float *r_lambda)
@@ -1635,7 +1635,7 @@ bool isect_line_line_strict_v3(const float v1[3], const float v2[3],
d = dot_v3v3(dir1, dir2);
if (d == 1.0f || d == -1.0f || d == 0) {
/* colinear or one vector is zero-length*/
- return 0;
+ return false;
}
cross_v3_v3v3(ab, a, b);
@@ -1644,7 +1644,7 @@ bool isect_line_line_strict_v3(const float v1[3], const float v2[3],
/* test zero length line */
if (UNLIKELY(div == 0.0f)) {
- return 0;
+ return false;
}
/* test if the two lines are coplanar */
else if (d > -0.000001f && d < 0.000001f) {
@@ -1663,14 +1663,14 @@ bool isect_line_line_strict_v3(const float v1[3], const float v2[3],
if (r_lambda) *r_lambda = f1;
- return 1; /* intersection found */
+ return true; /* intersection found */
}
else {
- return 0;
+ return false;
}
}
else {
- return 0;
+ return false;
}
}
@@ -1688,9 +1688,9 @@ void isect_ray_aabb_initialize(IsectRayAABBData *data, const float ray_start[3],
data->ray_inv_dir[1] = 1.0f / ray_direction[1];
data->ray_inv_dir[2] = 1.0f / ray_direction[2];
- data->sign[0] = data->ray_inv_dir[0] < 0;
- data->sign[1] = data->ray_inv_dir[1] < 0;
- data->sign[2] = data->ray_inv_dir[2] < 0;
+ data->sign[0] = data->ray_inv_dir[0] < 0.0f;
+ data->sign[1] = data->ray_inv_dir[1] < 0.0f;
+ data->sign[2] = data->ray_inv_dir[2] < 0.0f;
}
/* Adapted from http://www.gamedev.net/community/forums/topic.asp?topic_id=459973 */
@@ -1808,8 +1808,9 @@ float line_plane_factor_v3(const float plane_co[3], const float plane_no[3],
return (dot != 0.0f) ? -dot_v3v3(plane_no, h) / dot : 0.0f;
}
-/* ensure the distance between these points is no greater then 'dist'
- * if it is, scale then both into the center */
+/** Ensure the distance between these points is no greater then 'dist'.
+ * If it is, scale then both into the center.
+ */
void limit_dist_v3(float v1[3], float v2[3], const float dist)
{
const float dist_old = len_v3v3(v1, v2);
@@ -1874,8 +1875,7 @@ static bool point_in_slice(const float p[3], const float v1[3], const float l1[3
sub_v3_v3v3(rp, p, v1);
h = dot_v3v3(q, rp) / dot_v3v3(q, q);
- if (h < 0.0f || h > 1.0f) return 0;
- return 1;
+ return (h < 0.0f || h > 1.0f) ? false : true;
}
#if 0
@@ -1904,10 +1904,10 @@ static int point_in_slice_m(float p[3], float origin[3], float normal[3], float
bool isect_point_tri_prism_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3])
{
- if (!point_in_slice(p, v1, v2, v3)) return 0;
- if (!point_in_slice(p, v2, v3, v1)) return 0;
- if (!point_in_slice(p, v3, v1, v2)) return 0;
- return 1;
+ if (!point_in_slice(p, v1, v2, v3)) return false;
+ if (!point_in_slice(p, v2, v3, v1)) return false;
+ if (!point_in_slice(p, v3, v1, v2)) return false;
+ return true;
}
/**
@@ -1951,7 +1951,7 @@ bool clip_segment_v3_plane(float p1[3], float p2[3], const float plane[4])
div = dot_v3v3(dp, plane);
if (div == 0.0f) /* parallel */
- return 1;
+ return true;
t = -plane_point_side_v3(plane, p1) / div;
@@ -1960,34 +1960,34 @@ bool clip_segment_v3_plane(float p1[3], float p2[3], const float plane[4])
if (t >= 1.0f) {
zero_v3(p1);
zero_v3(p2);
- return 0;
+ return false;
}
/* intersect plane */
if (t > 0.0f) {
madd_v3_v3v3fl(pc, p1, dp, t);
copy_v3_v3(p1, pc);
- return 1;
+ return true;
}
- return 1;
+ return true;
}
else {
/* behind plane, completely clipped */
if (t <= 0.0f) {
zero_v3(p1);
zero_v3(p2);
- return 0;
+ return false;
}
/* intersect plane */
if (t < 1.0f) {
madd_v3_v3v3fl(pc, p1, dp, t);
copy_v3_v3(p2, pc);
- return 1;
+ return true;
}
- return 1;
+ return true;
}
}
@@ -2216,12 +2216,12 @@ static bool barycentric_weights(const float v1[3], const float v2[3], const floa
if (fabsf(wtot) > FLT_EPSILON) {
mul_v3_fl(w, 1.0f / wtot);
- return 0;
+ return false;
}
else {
/* zero area triangle */
copy_v3_fl(w, 1.0f / 3.0f);
- return 1;
+ return true;
}
}
@@ -2272,8 +2272,9 @@ void interp_weights_face_v3(float w[4], const float v1[3], const float v2[3], co
}
}
}
- else
+ else {
barycentric_weights(v1, v2, v3, co, n, w);
+ }
}
}
@@ -2299,11 +2300,11 @@ int barycentric_inside_triangle_v2(const float w[3])
/* returns 0 for degenerated triangles */
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];
- float x2 = v2[0], y2 = v2[1];
- float x3 = v3[0], y3 = v3[1];
- float det = (y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3);
+ const float x = co[0], y = co[1];
+ const float x1 = v1[0], y1 = v1[1];
+ const float x2 = v2[0], y2 = v2[1];
+ const float x3 = v3[0], y3 = v3[1];
+ const float det = (y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3);
if (fabsf(det) > FLT_EPSILON) {
w[0] = ((y2 - y3) * (x - x3) + (x3 - x2) * (y - y3)) / det;
@@ -2352,8 +2353,9 @@ void barycentric_weights_v2_persp(const float v1[4], const float v2[4], const fl
if (wtot != 0.0f) {
mul_v3_fl(w, 1.0f / wtot);
}
- else /* dummy values for zero area face */
+ else { /* dummy values for zero area face */
w[0] = w[1] = w[2] = 1.0f / 3.0f;
+ }
}
/* same as #barycentric_weights_v2 but works with a quad,
@@ -2388,8 +2390,7 @@ void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const flo
if (UNLIKELY(lens[0] < FLT_EPSILON)) { w[0] = 1.0f; w[1] = w[2] = w[3] = 0.0f; }
else if (UNLIKELY(lens[1] < FLT_EPSILON)) { w[1] = 1.0f; w[0] = w[2] = w[3] = 0.0f; }
else if (UNLIKELY(lens[2] < FLT_EPSILON)) { w[2] = 1.0f; w[0] = w[1] = w[3] = 0.0f; }
- else if (UNLIKELY(lens[3] < FLT_EPSILON)) { w[3] = 1.0f; w[0] = w[1] = w[2] = 0.0f;
- }
+ else if (UNLIKELY(lens[3] < FLT_EPSILON)) { w[3] = 1.0f; w[0] = w[1] = w[2] = 0.0f; }
else {
float wtot, area;
@@ -2596,7 +2597,7 @@ static float mean_value_half_tan_v2(const float v1[2], const float v2[2], const
void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[3])
{
- const float eps = 0.00001f; /* take care, low values cause [#36105] */
+ const float eps = 1e-5f; /* take care, low values cause [#36105] */
const float eps_sq = eps * eps;
const float *v_curr, *v_next;
float ht_prev, ht; /* half tangents */
@@ -2665,7 +2666,7 @@ void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[
void interp_weights_poly_v2(float *w, float v[][2], const int n, const float co[2])
{
- const float eps = 0.00001f; /* take care, low values cause [#36105] */
+ const float eps = 1e-5f; /* take care, low values cause [#36105] */
const float eps_sq = eps * eps;
const float *v_curr, *v_next;
float ht_prev, ht; /* half tangents */
@@ -2735,8 +2736,8 @@ void interp_weights_poly_v2(float *w, float v[][2], const int n, const float co[
void interp_cubic_v3(float x[3], float v[3], const float x1[3], const float v1[3], const float x2[3], const float v2[3], const float t)
{
float a[3], b[3];
- float t2 = t * t;
- float t3 = t2 * t;
+ const float t2 = t * t;
+ const float t3 = t2 * t;
/* cubic interpolation */
a[0] = v1[0] + v2[0] + 2 * (x1[0] - x2[0]);
@@ -2961,11 +2962,9 @@ void orthographic_m4(float matrix[4][4], const float left, const float right, co
void perspective_m4(float mat[4][4], const float left, const float right, const float bottom, const float top,
const float nearClip, const float farClip)
{
- float Xdelta, Ydelta, Zdelta;
-
- Xdelta = right - left;
- Ydelta = top - bottom;
- Zdelta = farClip - nearClip;
+ const float Xdelta = right - left;
+ const float Ydelta = top - bottom;
+ const float Zdelta = farClip - nearClip;
if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) {
return;
@@ -2979,7 +2978,7 @@ void perspective_m4(float mat[4][4], const float left, const float right, const
mat[3][2] = (-2.0f * nearClip * farClip) / Zdelta;
mat[0][1] = mat[0][2] = mat[0][3] =
mat[1][0] = mat[1][2] = mat[1][3] =
- mat[3][0] = mat[3][1] = mat[3][3] = 0.0;
+ mat[3][0] = mat[3][1] = mat[3][3] = 0.0f;
}
@@ -3028,7 +3027,6 @@ static void i_multmatrix(float icand[4][4], float Vm[4][4])
void polarview_m4(float Vm[4][4], float dist, float azimuth, float incidence, float twist)
{
-
unit_m4(Vm);
translate_m4(Vm, 0.0, 0.0, -dist);
@@ -3050,16 +3048,16 @@ void lookat_m4(float mat[4][4], float vx, float vy, float vz, float px, float py
dx = px - vx;
dy = py - vy;
dz = pz - vz;
- hyp = dx * dx + dz * dz; /* hyp squared */
+ hyp = dx * dx + dz * dz; /* hyp squared */
hyp1 = sqrtf(dy * dy + hyp);
- hyp = sqrtf(hyp); /* the real hyp */
+ hyp = sqrtf(hyp); /* the real hyp */
- if (hyp1 != 0.0f) { /* rotate X */
+ if (hyp1 != 0.0f) { /* rotate X */
sine = -dy / hyp1;
cosine = hyp / hyp1;
}
else {
- sine = 0;
+ sine = 0.0f;
cosine = 1.0f;
}
mat1[1][1] = cosine;
@@ -3069,16 +3067,16 @@ void lookat_m4(float mat[4][4], float vx, float vy, float vz, float px, float py
i_multmatrix(mat1, mat);
- mat1[1][1] = mat1[2][2] = 1.0f; /* be careful here to reinit */
- mat1[1][2] = mat1[2][1] = 0.0; /* those modified by the last */
+ mat1[1][1] = mat1[2][2] = 1.0f; /* be careful here to reinit */
+ mat1[1][2] = mat1[2][1] = 0.0f; /* those modified by the last */
- /* paragraph */
- if (hyp != 0.0f) { /* rotate Y */
+ /* paragraph */
+ if (hyp != 0.0f) { /* rotate Y */
sine = dx / hyp;
cosine = -dz / hyp;
}
else {
- sine = 0;
+ sine = 0.0f;
cosine = 1.0f;
}
mat1[0][0] = cosine;
@@ -3259,10 +3257,10 @@ void accumulate_vertex_normals_poly(float **vertnos, const float polyno[3],
void tangent_from_uv(float uv1[2], float uv2[2], float uv3[3], float co1[3], float co2[3], float co3[3], float n[3], float tang[3])
{
- float s1 = uv2[0] - uv1[0];
- float s2 = uv3[0] - uv1[0];
- float t1 = uv2[1] - uv1[1];
- float t2 = uv3[1] - uv1[1];
+ const float s1 = uv2[0] - uv1[0];
+ const float s2 = uv3[0] - uv1[0];
+ const float t1 = uv2[1] - uv1[1];
+ const float t2 = uv3[1] - uv1[1];
float det = (s1 * t2 - s2 * t1);
if (det != 0.0f) { /* otherwise 'tang' becomes nan */
@@ -3287,7 +3285,7 @@ void tangent_from_uv(float uv1[2], float uv2[2], float uv3[3], float co1[3], flo
}
}
else {
- tang[0] = tang[1] = tang[2] = 0.0;
+ tang[0] = tang[1] = tang[2] = 0.0f;
}
}
@@ -3320,7 +3318,8 @@ void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight, fl
float lloc[3], float rloc[3], float lrot[3][3], float lscale[3][3])
{
float accu_com[3] = {0.0f, 0.0f, 0.0f}, accu_rcom[3] = {0.0f, 0.0f, 0.0f};
- float accu_weight = 0.0f, accu_rweight = 0.0f, eps = 0.000001f;
+ float accu_weight = 0.0f, accu_rweight = 0.0f;
+ const float eps = 1e-6f;
int a;
/* first set up a nice default response */
@@ -3414,7 +3413,7 @@ void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight, fl
/* this is pretty much Polardecompose 'inline' the algo based on Higham's thesis */
/* without the far case ... but seems to work here pretty neat */
- odet = 0.f;
+ odet = 0.0f;
ndet = determinant_m3_array(q);
while ((odet - ndet) * (odet - ndet) > eps && i < imax) {
invert_m3_m3(qi, q);
@@ -3455,9 +3454,8 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
float q0[3], float q1[3], float q2[3], float q3[3])
{
static const float epsilon = 1e-6f;
- float c, sd[3];
-
- c = dot_v3v3(n, p);
+ float sd[3];
+ const float c = dot_v3v3(n, p);
/* signed distances from the vertices to the plane. */
sd[0] = dot_v3v3(n, v0) - c;
@@ -3468,16 +3466,16 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
if (fabsf(sd[1]) < epsilon) sd[1] = 0.0f;
if (fabsf(sd[2]) < epsilon) sd[2] = 0.0f;
- if (sd[0] > 0) {
- if (sd[1] > 0) {
- if (sd[2] > 0) {
+ if (sd[0] > 0.0f) {
+ if (sd[1] > 0.0f) {
+ if (sd[2] > 0.0f) {
/* +++ */
copy_v3_v3(q0, v0);
copy_v3_v3(q1, v1);
copy_v3_v3(q2, v2);
copy_v3_v3(q3, q2);
}
- else if (sd[2] < 0) {
+ else if (sd[2] < 0.0f) {
/* ++- */
copy_v3_v3(q0, v0);
copy_v3_v3(q1, v1);
@@ -3492,15 +3490,15 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
copy_v3_v3(q3, q2);
}
}
- else if (sd[1] < 0) {
- if (sd[2] > 0) {
+ else if (sd[1] < 0.0f) {
+ if (sd[2] > 0.0f) {
/* +-+ */
copy_v3_v3(q0, v0);
vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1])));
vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2])));
copy_v3_v3(q3, v2);
}
- else if (sd[2] < 0) {
+ else if (sd[2] < 0.0f) {
/* +-- */
copy_v3_v3(q0, v0);
vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1])));
@@ -3516,14 +3514,14 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
}
}
else {
- if (sd[2] > 0) {
+ if (sd[2] > 0.0f) {
/* +0+ */
copy_v3_v3(q0, v0);
copy_v3_v3(q1, v1);
copy_v3_v3(q2, v2);
copy_v3_v3(q3, q2);
}
- else if (sd[2] < 0) {
+ else if (sd[2] < 0.0f) {
/* +0- */
copy_v3_v3(q0, v0);
copy_v3_v3(q1, v1);
@@ -3539,16 +3537,16 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
}
}
}
- else if (sd[0] < 0) {
- if (sd[1] > 0) {
- if (sd[2] > 0) {
+ else if (sd[0] < 0.0f) {
+ if (sd[1] > 0.0f) {
+ if (sd[2] > 0.0f) {
/* -++ */
vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1])));
copy_v3_v3(q1, v1);
copy_v3_v3(q2, v2);
vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2])));
}
- else if (sd[2] < 0) {
+ else if (sd[2] < 0.0f) {
/* -+- */
vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1])));
copy_v3_v3(q1, v1);
@@ -3563,15 +3561,15 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
copy_v3_v3(q3, q2);
}
}
- else if (sd[1] < 0) {
- if (sd[2] > 0) {
+ else if (sd[1] < 0.0f) {
+ if (sd[2] > 0.0f) {
/* --+ */
vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2])));
vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2])));
copy_v3_v3(q2, v2);
copy_v3_v3(q3, q2);
}
- else if (sd[2] < 0) {
+ else if (sd[2] < 0.0f) {
/* --- */
return false;
}
@@ -3581,14 +3579,14 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
}
}
else {
- if (sd[2] > 0) {
+ if (sd[2] > 0.0f) {
/* -0+ */
vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2])));
copy_v3_v3(q1, v1);
copy_v3_v3(q2, v2);
copy_v3_v3(q3, q2);
}
- else if (sd[2] < 0) {
+ else if (sd[2] < 0.0f) {
/* -0- */
return false;
}
@@ -3599,15 +3597,15 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
}
}
else {
- if (sd[1] > 0) {
- if (sd[2] > 0) {
+ if (sd[1] > 0.0f) {
+ if (sd[2] > 0.0f) {
/* 0++ */
copy_v3_v3(q0, v0);
copy_v3_v3(q1, v1);
copy_v3_v3(q2, v2);
copy_v3_v3(q3, q2);
}
- else if (sd[2] < 0) {
+ else if (sd[2] < 0.0f) {
/* 0+- */
copy_v3_v3(q0, v0);
copy_v3_v3(q1, v1);
@@ -3622,15 +3620,15 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
copy_v3_v3(q3, q2);
}
}
- else if (sd[1] < 0) {
- if (sd[2] > 0) {
+ else if (sd[1] < 0.0f) {
+ if (sd[2] > 0.0f) {
/* 0-+ */
copy_v3_v3(q0, v0);
vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2])));
copy_v3_v3(q2, v2);
copy_v3_v3(q3, q2);
}
- else if (sd[2] < 0) {
+ else if (sd[2] < 0.0f) {
/* 0-- */
return false;
}
@@ -3640,14 +3638,14 @@ bool form_factor_visible_quad(const float p[3], const float n[3],
}
}
else {
- if (sd[2] > 0) {
+ if (sd[2] > 0.0f) {
/* 00+ */
copy_v3_v3(q0, v0);
copy_v3_v3(q1, v1);
copy_v3_v3(q2, v2);
copy_v3_v3(q3, q2);
}
- else if (sd[2] < 0) {
+ else if (sd[2] < 0.0f) {
/* 00- */
return false;
}
@@ -3802,7 +3800,7 @@ static void ff_normalize(float n[3])
d = dot_v3v3(n, n);
- if (d > 1.0e-35F) {
+ if (d > 1.0e-35f) {
d = 1.0f / sqrtf(d);
n[0] *= d;