C99/C++11: replace deprecated finite() by isfinite().
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 15 May 2016 22:48:02 +0000 (00:48 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 17 May 2016 19:39:16 +0000 (21:39 +0200)
19 files changed:
source/blender/blenkernel/intern/mesh_validate.c
source/blender/blenkernel/intern/particle.c
source/blender/blenlib/BLI_math_base.h
source/blender/blenlib/intern/math_base.c
source/blender/blenlib/intern/math_vector.c
source/blender/blenlib/intern/math_vector_inline.c
source/blender/editors/mesh/editmesh_rip.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_view3d/view3d_project.c
source/blender/editors/transform/transform_constraints.c
source/blender/freestyle/intern/system/PseudoNoise.cpp
source/blender/modifiers/intern/MOD_ocean.c
source/blender/python/generic/py_capi_utils.c
source/blender/python/intern/bpy_driver.c
source/blender/python/intern/bpy_util.c
source/blender/python/mathutils/mathutils_Quaternion.c
source/blender/render/intern/raytrace/rayobject_rtbuild.cpp
source/blender/windowmanager/intern/wm_event_system.c

index 49dd0b104ab28bc633fe8c66a9f0fbd0601c6edd..ba890b005d84ca9e3bd781708a0c9796b9e8d826 100644 (file)
@@ -284,7 +284,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
                bool fix_normal = true;
 
                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);
 
                                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++) {
                                /* 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);
                                        if (do_fixes) {
                                                dw->weight = 0.0f;
index 098700495a0fb54763955b859a62add5009b3215..7dce237c737004b3ecb2aec3f1a6aedfa2f7784b 100644 (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
         * since this becomes geometry, nan's and inf's crash raytrace code.
         * better not allow this. */
-       if ((!finite(bb->vec[0])) || (!finite(bb->vec[1])) || (!finite(bb->vec[2])) ||
-           (!finite(bb->vel[0])) || (!finite(bb->vel[1])) || (!finite(bb->vel[2])) )
+       if ((!isfinite(bb->vec[0])) || (!isfinite(bb->vec[1])) || (!isfinite(bb->vec[2])) ||
+           (!isfinite(bb->vel[0])) || (!isfinite(bb->vel[1])) || (!isfinite(bb->vel[2])) )
        {
                zero_v3(bb->vec);
                zero_v3(bb->vel);
index 20b76354f58783fee7a102dee3ad1bce96a8b604..e97a250cd240f0e150a8e296f52dd46f99dea4bb 100644 (file)
 #include <math.h>
 #include "BLI_math_inline.h"
 
-#ifdef __sun__
-#include <ieeefp.h> /* for finite() */
-#endif
-
 #ifndef M_PI
 #define M_PI        3.14159265358979323846  /* pi */
 #endif
@@ -146,12 +142,6 @@ static const int NAN_INT = 0x7FC00000;
 
 #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
 #include "intern/math_base_inline.c"
 #endif
index 0a1e9e8a8a174e018b8e589a38381d7488456e90..14eba3e61a40e10dbb87789eb4d514464c7a8d93 100644 (file)
@@ -56,7 +56,7 @@ double double_round(double x, int ndigits)
                pow2 = 1.0;
                y = (x * pow1) * pow2;
                /* if y overflows, then rounded value is exactly x */
-               if (!finite(y))
+               if (!isfinite(y))
                        return x;
        }
        else {
index 3e464327b2ec25634ccb50914505632459c9da00..46e25fc3f4f52fb82284a9c276aa69ec1aa76ee5 100644 (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) {
                const float d = 1.0f / sqrtf(f);
 
-               BLI_assert(finite(d));
+               BLI_assert(isfinite(d));
 
                r_n1[0] =  n[1] * d;
                r_n1[1] = -n[0] * d;
index 17e2da3f1cbf1ebb81f2395930f1a70990e95b3b..76f2af347237d4a9a9e2ba400142e6ee9b5a8ef1 100644 (file)
@@ -954,17 +954,17 @@ MINLINE bool is_zero_v4(const float v[4])
 
 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])
 {
-       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])
 {
-       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])
index c7a7828f3b20ba917056860a3969739c7fde815b..9e71e646b1a4387d5056367642f1cf83692863b6 100644 (file)
@@ -77,14 +77,14 @@ static float edbm_rip_edgedist_squared(
                const float dist_2d = len_v2v2(vec1, vec2);
                if (dist_2d > FLT_EPSILON) {
                        const float dist = inset / dist_2d;
-                       BLI_assert(finite(dist));
+                       BLI_assert(isfinite(dist));
                        interp_v2_v2v2(vec1, vec1, vec2, dist);
                        interp_v2_v2v2(vec2, vec2, vec1, dist);
                }
        }
 
        dist_sq = dist_squared_to_line_segment_v2(mvalf, vec1, vec2);
-       BLI_assert(finite(dist_sq));
+       BLI_assert(isfinite(dist_sq));
 
        return dist_sq;
 }
index 90676d2b951ddf153cc212e286b9fd8ddf9fb152..1b2d4b7c130140c1f1ccafd8eef4040e58e3fc4f 100644 (file)
@@ -811,9 +811,9 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c
        int i;
        
        /* ignore nan verts */
-       if ((finite(co[0]) == false) ||
-           (finite(co[1]) == false) ||
-           (finite(co[2]) == false))
+       if ((isfinite(co[0]) == false) ||
+           (isfinite(co[1]) == false) ||
+           (isfinite(co[2]) == false))
        {
                return NULL;
        }
@@ -902,8 +902,8 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float
        float cent[2];
 
        /* ignore nan verts */
-       if (isnan(uv[0]) || !finite(uv[0]) ||
-           isnan(uv[1]) || !finite(uv[1])
+       if (isnan(uv[0]) || !isfinite(uv[0]) ||
+           isnan(uv[1]) || !isfinite(uv[1])
            )
        {
                return NULL;
index be421d779eb545fb60f033086037dde1b5aad5e4..4111f67553a2e77fccb3da79a8c84a196340e179 100644 (file)
@@ -3467,7 +3467,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
                
                if ((scene->audio.flag & AUDIO_SYNC) &&
                    (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;
 
index cbabc8e56deac6623ddce37de55a8d40e4e03390..797d97586c741a3e96f9ec97e0af2325a13201b0 100644 (file)
@@ -217,8 +217,8 @@ eV3DProjStatus ED_view3d_project_float_ex(const ARegion *ar, float perspmat[4][4
        float tvec[2];
        eV3DProjStatus ret = ed_view3d_project__internal(ar, perspmat, is_local, co, tvec, flag);
        if (ret == V3D_PROJ_RET_OK) {
-               if (finite(tvec[0]) &&
-                   finite(tvec[1]))
+               if (isfinite(tvec[0]) &&
+                   isfinite(tvec[1]))
                {
                        copy_v2_v2(r_co, tvec);
                }
index beeba7cf10f228d21115094f70f7cae106748810..13cc0c227788bbc5420b839ae911af03fe7c8b9a 100644 (file)
@@ -267,9 +267,9 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3],
 
                        /* possible some values become nan when
                         * viewpoint and object are both zero */
-                       if (!finite(out[0])) out[0] = 0.0f;
-                       if (!finite(out[1])) out[1] = 0.0f;
-                       if (!finite(out[2])) out[2] = 0.0f;
+                       if (!isfinite(out[0])) out[0] = 0.0f;
+                       if (!isfinite(out[1])) out[1] = 0.0f;
+                       if (!isfinite(out[2])) out[2] = 0.0f;
                }
        }
 }
index 4949cb8c430cbeec6ea265817fc4b04e80c12edd..638eb6ca16a085e1abbcba3fed57031e65d269b5 100644 (file)
@@ -33,7 +33,7 @@
 
 static int modf_to_index(Freestyle::real x, unsigned int range)
 {
-       if (finite(x)) {
+       if (isfinite(x)) {
                Freestyle::real tmp;
                int i = abs((int)(modf(x, &tmp) * range));
                BLI_assert(i >= 0 && i < range);
index a90a51e9ddc341ed4811e74e0a75ed8e16bca792..e77cc655c16996a8833d2d41e0606141b6c9de19 100644 (file)
@@ -435,7 +435,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob,
        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 */
-       if (!finite(size_co_inv)) {
+       if (!isfinite(size_co_inv)) {
                return derivedData;
        }
 
index dd32c913f7854805f43417fa914227bcf05a0f9f..7f13a7a4d94827888ac1825a36ed917d37c16814 100644 (file)
@@ -45,7 +45,7 @@
 
 #ifdef _WIN32
 #include "BLI_path_util.h"  /* BLI_setenv() */
-#include "BLI_math_base.h"  /* finite() */
+#include "BLI_math_base.h"  /* isfinite() */
 #endif
 
 /* array utility function */
@@ -1026,7 +1026,7 @@ bool PyC_RunString_AsNumber(const char *expr, double *value, const char *filenam
                if (val == -1 && PyErr_Occurred()) {
                        ok = false;
                }
-               else if (!finite(val)) {
+               else if (!isfinite(val)) {
                        *value = 0.0;
                }
                else {
index 9cd6fe3da91edd05e14e1a96fd24fb2b629d57c9..9b477e384dbf467810a846e52a51343605cbc589 100644 (file)
@@ -347,7 +347,7 @@ float BPY_driver_exec(ChannelDriver *driver, const float evaltime)
        if (use_gil)
                PyGILState_Release(gilstate);
 
-       if (finite(result)) {
+       if (isfinite(result)) {
                return (float)result;
        }
        else {
index ee827c06e14f9262f33e2c4e970d2d08368d16af..2b8ad6ccb90aae9f509d80ba736ff685f42fffed 100644 (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)
 {
        return BPy_errors_to_report_ex(reports, true, true);
-}
\ No newline at end of file
+}
index ea5732966b2218f375c46c0a33d9b996b7eaf479..71b3cf8ddac354fa12f27913b59ed2d9728cda09 100644 (file)
@@ -1165,9 +1165,9 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle)
 {
        if (axis) {
                if (is_zero_v3(axis) ||
-                   !finite(axis[0]) ||
-                   !finite(axis[1]) ||
-                   !finite(axis[2]))
+                   !isfinite(axis[0]) ||
+                   !isfinite(axis[1]) ||
+                   !isfinite(axis[2]))
                {
                        axis[0] = 1.0f;
                        axis[1] = 0.0f;
@@ -1182,7 +1182,7 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle)
        }
 
        if (angle) {
-               if (!finite(*angle)) {
+               if (!isfinite(*angle)) {
                        *angle = 0.0f;
                }
        }
index 00c1129fa851ed56643b25ef11adcaabfe9e8f72..02a49fc3c8f626a65c16bf2ac4d30f78f1a6f472 100644 (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])
                return;
        /* 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;
-       if (!finite(bb[3]) || !finite(bb[4]) || !finite(bb[5]))
+       if (!isfinite(bb[3]) || !isfinite(bb[4]) || !isfinite(bb[5]))
                return;
        /* skip objects with zero bounding box, they are of no use, and
         * will give problems in rtbuild_heuristic_object_split later */
index 40b6f90f6f39f48768c958a09b7951e28ea84605..4f9d48450f6f5e7813c06eb136faa39cc50557b6 100644 (file)
@@ -2359,7 +2359,7 @@ void wm_event_do_handlers(bContext *C)
                                        
                                        if (is_playing_sound == 0) {
                                                const float time = BKE_sound_sync_scene(scene);
-                                               if (finite(time)) {
+                                               if (isfinite(time)) {
                                                        int ncfra = time * (float)FPS + 0.5f;
                                                        if (ncfra != scene->r.cfra) {
                                                                scene->r.cfra = ncfra;