Polyfill M_PI;

It technically isn't part of C, which is causing problems on some systems.
This commit is contained in:
bjorn 2019-06-20 21:43:40 -07:00
parent 807c519397
commit 879c789a08
5 changed files with 9 additions and 3 deletions

View File

@ -865,8 +865,8 @@ static int l_lovrGraphicsArc(lua_State* L) {
float transform[16];
index = luax_readmat4(L, index, transform, 1);
float r1 = luax_optfloat(L, index++, 0.f);
float r2 = luax_optfloat(L, index++, 2.f * M_PI);
int segments = luaL_optinteger(L, index, 64) * (MIN(fabsf(r2 - r1), 2 * M_PI) / (2 * M_PI));
float r2 = luax_optfloat(L, index++, 2.f * (float) M_PI);
int segments = luaL_optinteger(L, index, 64) * (MIN(fabsf(r2 - r1), 2.f * (float) M_PI) / (2.f * (float) M_PI));
lovrGraphicsArc(style, mode, material, transform, r1, r2, segments);
return 0;
}

View File

@ -23,6 +23,10 @@
#define LOVR_INLINE inline
#endif
#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define CLAMP(x, min, max) MAX(min, MIN(max, x))

View File

@ -9,6 +9,7 @@
#include "math/math.h"
#include "core/maf.h"
#include "core/ref.h"
#include "core/util.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>

View File

@ -1,6 +1,7 @@
#include "headset/headset.h"
#include "graphics/graphics.h"
#include "core/maf.h"
#include "core/util.h"
#include "platform.h"
#include <math.h>
#include <stdint.h>

View File

@ -83,7 +83,7 @@ double lovrRandomGeneratorRandomNormal(RandomGenerator* generator) {
double a = lovrRandomGeneratorRandom(generator);
double b = lovrRandomGeneratorRandom(generator);
double r = sqrt(-2. * log(1. - a));
double phi = 2 * M_PI * (1. - b);
double phi = 2. * M_PI * (1. - b);
generator->lastRandomNormal = r * cos(phi);
return r * sin(phi);
}