Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/graphene-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@

#endif /* __GNUC__ */

#if defined(_M_X64) && ! defined(isnanf)
# define graphene_isnan(x) _isnanf(x)
#elif defined(HAVE_ISNANF)
# define graphene_isnan(x) isnanf(x)
#else
# define graphene_isnan(x) isnan(x)
#endif

static inline bool
graphene_approx_val (float a, float b)
{
Expand Down
27 changes: 4 additions & 23 deletions src/graphene-ray.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
#include <math.h>
#include <float.h>

#if defined(_M_X64) && ! defined(isnanf)
# define isnanf(x) _isnanf(x)
# define HAVE_ISNANF
#endif

/**
* graphene_ray_alloc: (constructor)
*
Expand Down Expand Up @@ -555,17 +550,10 @@ graphene_ray_intersect_box (const graphene_ray_t *r,
/* These lines also handle the case where tx_min or tx_max is NaN
* (result of 0 * INFINITY): NaN != NaN
*/
#ifdef HAVE_ISNANF
if (ty_min > tx_min || isnanf (tx_min))
tx_min = ty_min;
if (ty_max < tx_max || isnanf (tx_max))
tx_max = ty_max;
#else
if (ty_min > tx_min || fpclassify (tx_min) == FP_NAN)
if (ty_min > tx_min || graphene_isnan (tx_min))
tx_min = ty_min;
if (ty_max > tx_max || fpclassify (tx_max) == FP_NAN)
if (ty_max < tx_max || graphene_isnan (tx_max))
tx_max = ty_max;
#endif

float tz_min, tz_max;
if (graphene_vec3_get_z (&inv_dir) >= 0.f)
Expand All @@ -582,17 +570,10 @@ graphene_ray_intersect_box (const graphene_ray_t *r,
if ((tx_min > tz_max) || (tz_min > tx_max))
return GRAPHENE_RAY_INTERSECTION_KIND_NONE;

#ifdef HAVE_ISNANF
if (tz_min > tx_min || isnanf (tx_min))
tx_min = tz_min;
if (tz_max < tx_max || isnanf (tx_max))
tx_max = tz_max;
#else
if (tz_min > tx_min || fpclassify (tx_min) == FP_NAN)
if (tz_min > tx_min || graphene_isnan (tx_min))
tx_min = tz_min;
if (tz_max < tx_max || fpclassify (tx_max) == FP_NAN)
if (tz_max < tx_max || graphene_isnan (tx_max))
tx_max = tz_max;
#endif

/* return the point closest to the ray (positive side) */
if (tx_max < 0)
Expand Down