mirror of
https://github.com/recastnavigation/recastnavigation.git
synced 2026-08-16 16:19:55 +00:00
Fast math is not required, but it speeds up some calculations at the expense of accuracy. There are some functions like dtMathIsfinite that use floating point functions that become undefined behavior when compiled with fast-math, so we need to conditionally short-circuit these functions when compiled with that flag. -Wnan-infinity-disabled is complaining about the isfinite call in dtMathIsfinite. This also sets the linux runner explicitly to Ubuntu 24.04, since ubuntu-latest defaults to 22.04 for some reason. This also updates gcc and clang to the latest versions in apt and logs their version to the run output. We need at least clang18 to disable the -Wnan-infinity-disabled warning for Catch. Finally, this also removes some unused code that was throwing a warning (and thus an error) on newer compiler versions.
31 lines
754 B
C
31 lines
754 B
C
/**
|
|
@defgroup detour Detour
|
|
|
|
Members in this module are wrappers around the standard math library
|
|
*/
|
|
|
|
#ifndef DETOURMATH_H
|
|
#define DETOURMATH_H
|
|
|
|
#include <math.h>
|
|
|
|
inline float dtMathFabsf(float x) { return fabsf(x); }
|
|
inline float dtMathSqrtf(float x) { return sqrtf(x); }
|
|
inline float dtMathFloorf(float x) { return floorf(x); }
|
|
inline float dtMathCeilf(float x) { return ceilf(x); }
|
|
inline float dtMathCosf(float x) { return cosf(x); }
|
|
inline float dtMathSinf(float x) { return sinf(x); }
|
|
inline float dtMathAtan2f(float y, float x) { return atan2f(y, x); }
|
|
inline bool dtMathIsfinite(float x)
|
|
{
|
|
#ifndef RC_FAST_MATH
|
|
return isfinite(x);
|
|
#else
|
|
// Infinity and NaN are disabled when compiling with -ffast-math
|
|
(void)x;
|
|
return true;
|
|
#endif
|
|
}
|
|
|
|
#endif
|