C99/C++11: replace deprecated finite() by isfinite().

This commit is contained in:
2016-05-16 00:48:02 +02:00
parent 2b73402547
commit 21fddf7d1c
19 changed files with 35 additions and 45 deletions

View File

@@ -284,7 +284,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
bool fix_normal = true; bool fix_normal = true;
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
if (!finite(mv->co[j])) { if (!isfinite(mv->co[j])) {
PRINT_ERR("\tVertex %u: has invalid coordinate\n", i); PRINT_ERR("\tVertex %u: has invalid coordinate\n", i);
if (do_fixes) { if (do_fixes) {
@@ -765,7 +765,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
for (j = 0, dw = dv->dw; j < dv->totweight; j++, dw++) { for (j = 0, dw = dv->dw; j < dv->totweight; j++, dw++) {
/* note, greater than max defgroups is accounted for in our code, but not < 0 */ /* note, greater than max defgroups is accounted for in our code, but not < 0 */
if (!finite(dw->weight)) { if (!isfinite(dw->weight)) {
PRINT_ERR("\tVertex deform %u, group %d has weight: %f\n", i, dw->def_nr, dw->weight); PRINT_ERR("\tVertex deform %u, group %d has weight: %f\n", i, dw->def_nr, dw->weight);
if (do_fixes) { if (do_fixes) {
dw->weight = 0.0f; dw->weight = 0.0f;

View File

@@ -4225,8 +4225,8 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3]
/* can happen with bad pointcache or physics calculation /* can happen with bad pointcache or physics calculation
* since this becomes geometry, nan's and inf's crash raytrace code. * since this becomes geometry, nan's and inf's crash raytrace code.
* better not allow this. */ * better not allow this. */
if ((!finite(bb->vec[0])) || (!finite(bb->vec[1])) || (!finite(bb->vec[2])) || if ((!isfinite(bb->vec[0])) || (!isfinite(bb->vec[1])) || (!isfinite(bb->vec[2])) ||
(!finite(bb->vel[0])) || (!finite(bb->vel[1])) || (!finite(bb->vel[2])) ) (!isfinite(bb->vel[0])) || (!isfinite(bb->vel[1])) || (!isfinite(bb->vel[2])) )
{ {
zero_v3(bb->vec); zero_v3(bb->vec);
zero_v3(bb->vel); zero_v3(bb->vel);

View File

@@ -37,10 +37,6 @@
#include <math.h> #include <math.h>
#include "BLI_math_inline.h" #include "BLI_math_inline.h"
#ifdef __sun__
#include <ieeefp.h> /* for finite() */
#endif
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */ #define M_PI 3.14159265358979323846 /* pi */
#endif #endif
@@ -146,12 +142,6 @@ static const int NAN_INT = 0x7FC00000;
#endif /* C99, POSIX.1-2001 or MSVC12 (partial C99) */ #endif /* C99, POSIX.1-2001 or MSVC12 (partial C99) */
#ifdef WIN32
# if defined(_MSC_VER)
# define finite(n) _finite(n)
# endif
#endif
#if BLI_MATH_DO_INLINE #if BLI_MATH_DO_INLINE
#include "intern/math_base_inline.c" #include "intern/math_base_inline.c"
#endif #endif

View File

@@ -56,7 +56,7 @@ double double_round(double x, int ndigits)
pow2 = 1.0; pow2 = 1.0;
y = (x * pow1) * pow2; y = (x * pow1) * pow2;
/* if y overflows, then rounded value is exactly x */ /* if y overflows, then rounded value is exactly x */
if (!finite(y)) if (!isfinite(y))
return x; return x;
} }
else { else {

View File

@@ -669,7 +669,7 @@ void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
if (f > eps) { if (f > eps) {
const float d = 1.0f / sqrtf(f); const float d = 1.0f / sqrtf(f);
BLI_assert(finite(d)); BLI_assert(isfinite(d));
r_n1[0] = n[1] * d; r_n1[0] = n[1] * d;
r_n1[1] = -n[0] * d; r_n1[1] = -n[0] * d;

View File

@@ -954,17 +954,17 @@ MINLINE bool is_zero_v4(const float v[4])
MINLINE bool is_finite_v2(const float v[2]) MINLINE bool is_finite_v2(const float v[2])
{ {
return (finite(v[0]) && finite(v[1])); return (isfinite(v[0]) && isfinite(v[1]));
} }
MINLINE bool is_finite_v3(const float v[3]) MINLINE bool is_finite_v3(const float v[3])
{ {
return (finite(v[0]) && finite(v[1]) && finite(v[2])); return (isfinite(v[0]) && isfinite(v[1]) && isfinite(v[2]));
} }
MINLINE bool is_finite_v4(const float v[4]) MINLINE bool is_finite_v4(const float v[4])
{ {
return (finite(v[0]) && finite(v[1]) && finite(v[2]) && finite(v[3])); return (isfinite(v[0]) && isfinite(v[1]) && isfinite(v[2]) && isfinite(v[3]));
} }
MINLINE bool is_one_v3(const float v[3]) MINLINE bool is_one_v3(const float v[3])

View File

@@ -77,14 +77,14 @@ static float edbm_rip_edgedist_squared(
const float dist_2d = len_v2v2(vec1, vec2); const float dist_2d = len_v2v2(vec1, vec2);
if (dist_2d > FLT_EPSILON) { if (dist_2d > FLT_EPSILON) {
const float dist = inset / dist_2d; const float dist = inset / dist_2d;
BLI_assert(finite(dist)); BLI_assert(isfinite(dist));
interp_v2_v2v2(vec1, vec1, vec2, dist); interp_v2_v2v2(vec1, vec1, vec2, dist);
interp_v2_v2v2(vec2, vec2, vec1, dist); interp_v2_v2v2(vec2, vec2, vec1, dist);
} }
} }
dist_sq = dist_squared_to_line_segment_v2(mvalf, vec1, vec2); dist_sq = dist_squared_to_line_segment_v2(mvalf, vec1, vec2);
BLI_assert(finite(dist_sq)); BLI_assert(isfinite(dist_sq));
return dist_sq; return dist_sq;
} }

View File

@@ -811,9 +811,9 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c
int i; int i;
/* ignore nan verts */ /* ignore nan verts */
if ((finite(co[0]) == false) || if ((isfinite(co[0]) == false) ||
(finite(co[1]) == false) || (isfinite(co[1]) == false) ||
(finite(co[2]) == false)) (isfinite(co[2]) == false))
{ {
return NULL; return NULL;
} }
@@ -902,8 +902,8 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float
float cent[2]; float cent[2];
/* ignore nan verts */ /* ignore nan verts */
if (isnan(uv[0]) || !finite(uv[0]) || if (isnan(uv[0]) || !isfinite(uv[0]) ||
isnan(uv[1]) || !finite(uv[1]) isnan(uv[1]) || !isfinite(uv[1])
) )
{ {
return NULL; return NULL;

View File

@@ -3467,7 +3467,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
if ((scene->audio.flag & AUDIO_SYNC) && if ((scene->audio.flag & AUDIO_SYNC) &&
(sad->flag & ANIMPLAY_FLAG_REVERSE) == false && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false &&
finite(time = BKE_sound_sync_scene(scene))) isfinite(time = BKE_sound_sync_scene(scene)))
{ {
double newfra = (double)time * FPS; double newfra = (double)time * FPS;

View File

@@ -217,8 +217,8 @@ eV3DProjStatus ED_view3d_project_float_ex(const ARegion *ar, float perspmat[4][4
float tvec[2]; float tvec[2];
eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag); eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag);
if (ret == V3D_PROJ_RET_OK) { if (ret == V3D_PROJ_RET_OK) {
if (finite(tvec[0]) && if (isfinite(tvec[0]) &&
finite(tvec[1])) isfinite(tvec[1]))
{ {
copy_v2_v2(r_co, tvec); copy_v2_v2(r_co, tvec);
} }

View File

@@ -267,9 +267,9 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3],
/* possible some values become nan when /* possible some values become nan when
* viewpoint and object are both zero */ * viewpoint and object are both zero */
if (!finite(out[0])) out[0] = 0.0f; if (!isfinite(out[0])) out[0] = 0.0f;
if (!finite(out[1])) out[1] = 0.0f; if (!isfinite(out[1])) out[1] = 0.0f;
if (!finite(out[2])) out[2] = 0.0f; if (!isfinite(out[2])) out[2] = 0.0f;
} }
} }
} }

View File

@@ -33,7 +33,7 @@
static int modf_to_index(Freestyle::real x, unsigned int range) static int modf_to_index(Freestyle::real x, unsigned int range)
{ {
if (finite(x)) { if (isfinite(x)) {
Freestyle::real tmp; Freestyle::real tmp;
int i = abs((int)(modf(x, &tmp) * range)); int i = abs((int)(modf(x, &tmp) * range));
BLI_assert(i >= 0 && i < range); BLI_assert(i >= 0 && i < range);

View File

@@ -435,7 +435,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob,
const float size_co_inv = 1.0f / (omd->size * omd->spatial_size); const float size_co_inv = 1.0f / (omd->size * omd->spatial_size);
/* can happen in when size is small, avoid bad array lookups later and quit now */ /* can happen in when size is small, avoid bad array lookups later and quit now */
if (!finite(size_co_inv)) { if (!isfinite(size_co_inv)) {
return derivedData; return derivedData;
} }

View File

@@ -45,7 +45,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include "BLI_path_util.h" /* BLI_setenv() */ #include "BLI_path_util.h" /* BLI_setenv() */
#include "BLI_math_base.h" /* finite() */ #include "BLI_math_base.h" /* isfinite() */
#endif #endif
/* array utility function */ /* array utility function */
@@ -1026,7 +1026,7 @@ bool PyC_RunString_AsNumber(const char *expr, double *value, const char *filenam
if (val == -1 && PyErr_Occurred()) { if (val == -1 && PyErr_Occurred()) {
ok = false; ok = false;
} }
else if (!finite(val)) { else if (!isfinite(val)) {
*value = 0.0; *value = 0.0;
} }
else { else {

View File

@@ -347,7 +347,7 @@ float BPY_driver_exec(ChannelDriver *driver, const float evaltime)
if (use_gil) if (use_gil)
PyGILState_Release(gilstate); PyGILState_Release(gilstate);
if (finite(result)) { if (isfinite(result)) {
return (float)result; return (float)result;
} }
else { else {

View File

@@ -148,4 +148,4 @@ bool BPy_errors_to_report_ex(ReportList *reports, const bool use_full, const boo
bool BPy_errors_to_report(ReportList *reports) bool BPy_errors_to_report(ReportList *reports)
{ {
return BPy_errors_to_report_ex(reports, true, true); return BPy_errors_to_report_ex(reports, true, true);
} }

View File

@@ -1165,9 +1165,9 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle)
{ {
if (axis) { if (axis) {
if (is_zero_v3(axis) || if (is_zero_v3(axis) ||
!finite(axis[0]) || !isfinite(axis[0]) ||
!finite(axis[1]) || !isfinite(axis[1]) ||
!finite(axis[2])) !isfinite(axis[2]))
{ {
axis[0] = 1.0f; axis[0] = 1.0f;
axis[1] = 0.0f; axis[1] = 0.0f;
@@ -1182,7 +1182,7 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle)
} }
if (angle) { if (angle) {
if (!finite(*angle)) { if (!isfinite(*angle)) {
*angle = 0.0f; *angle = 0.0f;
} }
} }

View File

@@ -109,9 +109,9 @@ void rtbuild_add(RTBuilder *b, RayObject *o)
if (bb[0] > bb[3] || bb[1] > bb[4] || bb[2] > bb[5]) if (bb[0] > bb[3] || bb[1] > bb[4] || bb[2] > bb[5])
return; return;
/* skip objects with inf bounding boxes */ /* skip objects with inf bounding boxes */
if (!finite(bb[0]) || !finite(bb[1]) || !finite(bb[2])) if (!isfinite(bb[0]) || !isfinite(bb[1]) || !isfinite(bb[2]))
return; return;
if (!finite(bb[3]) || !finite(bb[4]) || !finite(bb[5])) if (!isfinite(bb[3]) || !isfinite(bb[4]) || !isfinite(bb[5]))
return; return;
/* skip objects with zero bounding box, they are of no use, and /* skip objects with zero bounding box, they are of no use, and
* will give problems in rtbuild_heuristic_object_split later */ * will give problems in rtbuild_heuristic_object_split later */

View File

@@ -2359,7 +2359,7 @@ void wm_event_do_handlers(bContext *C)
if (is_playing_sound == 0) { if (is_playing_sound == 0) {
const float time = BKE_sound_sync_scene(scene); const float time = BKE_sound_sync_scene(scene);
if (finite(time)) { if (isfinite(time)) {
int ncfra = time * (float)FPS + 0.5f; int ncfra = time * (float)FPS + 0.5f;
if (ncfra != scene->r.cfra) { if (ncfra != scene->r.cfra) {
scene->r.cfra = ncfra; scene->r.cfra = ncfra;