mirror of
https://github.com/love2d/megasource.git
synced 2026-08-19 12:14:41 +02:00
Update OpenAL-soft to 1.21.1
This commit is contained in:
@@ -1,65 +1,26 @@
|
||||
#ifndef AL_MATH_DEFS_H
|
||||
#define AL_MATH_DEFS_H
|
||||
|
||||
#include <math.h>
|
||||
#ifdef HAVE_FLOAT_H
|
||||
#include <float.h>
|
||||
#endif
|
||||
constexpr float Deg2Rad(float x) noexcept { return x * 1.74532925199432955e-02f/*pi/180*/; }
|
||||
constexpr float Rad2Deg(float x) noexcept { return x * 5.72957795130823229e+01f/*180/pi*/; }
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI (3.14159265358979323846)
|
||||
#endif
|
||||
namespace al {
|
||||
|
||||
#define F_PI (3.14159265358979323846f)
|
||||
#define F_PI_2 (1.57079632679489661923f)
|
||||
#define F_TAU (6.28318530717958647692f)
|
||||
template<typename Real>
|
||||
struct MathDefs { };
|
||||
|
||||
#ifndef FLT_EPSILON
|
||||
#define FLT_EPSILON (1.19209290e-07f)
|
||||
#endif
|
||||
template<>
|
||||
struct MathDefs<float> {
|
||||
static constexpr float Pi() noexcept { return 3.14159265358979323846e+00f; }
|
||||
static constexpr float Tau() noexcept { return 6.28318530717958647692e+00f; }
|
||||
};
|
||||
|
||||
#define SQRT_2 1.41421356237309504880
|
||||
#define SQRT_3 1.73205080756887719318
|
||||
template<>
|
||||
struct MathDefs<double> {
|
||||
static constexpr double Pi() noexcept { return 3.14159265358979323846e+00; }
|
||||
static constexpr double Tau() noexcept { return 6.28318530717958647692e+00; }
|
||||
};
|
||||
|
||||
#define SQRTF_2 1.41421356237309504880f
|
||||
#define SQRTF_3 1.73205080756887719318f
|
||||
|
||||
#ifndef HUGE_VALF
|
||||
static const union msvc_inf_hack {
|
||||
unsigned char b[4];
|
||||
float f;
|
||||
} msvc_inf_union = {{ 0x00, 0x00, 0x80, 0x7F }};
|
||||
#define HUGE_VALF (msvc_inf_union.f)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LOG2F
|
||||
static inline float log2f(float f)
|
||||
{
|
||||
return logf(f) / logf(2.0f);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CBRTF
|
||||
static inline float cbrtf(float f)
|
||||
{
|
||||
return powf(f, 1.0f/3.0f);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_COPYSIGNF
|
||||
static inline float copysignf(float x, float y)
|
||||
{
|
||||
union {
|
||||
float f;
|
||||
unsigned int u;
|
||||
} ux = { x }, uy = { y };
|
||||
ux.u &= 0x7fffffffu;
|
||||
ux.u |= (uy.u&0x80000000u);
|
||||
return ux.f;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define DEG2RAD(x) ((float)(x) * (float)(M_PI/180.0))
|
||||
#define RAD2DEG(x) ((float)(x) * (float)(180.0/M_PI))
|
||||
} // namespace al
|
||||
|
||||
#endif /* AL_MATH_DEFS_H */
|
||||
|
||||
Reference in New Issue
Block a user