diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-05-16 01:48:02 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-05-17 22:39:16 +0300 |
commit | 21fddf7d1c0653881773e44cea6e9d0804a08b31 (patch) | |
tree | cf3179fce0393c9cc2577d546db790d5f7705694 /source/blender | |
parent | 2b73402547a7c765f302a0d4218f96b5a710e96f (diff) |
C99/C++11: replace deprecated finite() by isfinite().
Diffstat (limited to 'source/blender')
19 files changed, 35 insertions, 45 deletions
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 49dd0b104ab..ba890b005d8 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -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; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 098700495a0..7dce237c737 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -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); diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index 20b76354f58..e97a250cd24 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -37,10 +37,6 @@ #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 diff --git a/source/blender/blenlib/intern/math_base.c b/source/blender/blenlib/intern/math_base.c index 0a1e9e8a8a1..14eba3e61a4 100644 --- a/source/blender/blenlib/intern/math_base.c +++ b/source/blender/blenlib/intern/math_base.c @@ -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 { diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 3e464327b2e..46e25fc3f4f 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -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; diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 17e2da3f1cb..76f2af34723 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -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]) diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index c7a7828f3b2..9e71e646b1a 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -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; } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 90676d2b951..1b2d4b7c130 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -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; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index be421d779eb..4111f67553a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -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; diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index cbabc8e56de..797d97586c7 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -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); } diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index beeba7cf10f..13cc0c22778 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -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; } } } diff --git a/source/blender/freestyle/intern/system/PseudoNoise.cpp b/source/blender/freestyle/intern/system/PseudoNoise.cpp index 4949cb8c430..638eb6ca16a 100644 --- a/source/blender/freestyle/intern/system/PseudoNoise.cpp +++ b/source/blender/freestyle/intern/system/PseudoNoise.cpp @@ -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); diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index a90a51e9ddc..e77cc655c16 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -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; } diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index dd32c913f78..7f13a7a4d94 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -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 { diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 9cd6fe3da91..9b477e384db 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -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 { diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index ee827c06e14..2b8ad6ccb90 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -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 +} diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index ea5732966b2..71b3cf8ddac 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -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; } } diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp index 00c1129fa85..02a49fc3c8f 100644 --- a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp +++ b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp @@ -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 */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 40b6f90f6f3..4f9d48450f6 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -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; |