Fixed lerp() duplicate when compiling for C++20 (#851)

This commit is contained in:
niansa/tuxifan 2023-03-06 13:42:59 +01:00 committed by GitHub
parent 140e5a1495
commit 78798d4641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -300,7 +300,7 @@ static float fade(float t)
return t * t * t * (t * (t * 6 - 15) + 10);
}
static float lerp(float t, float a, float b)
static float math_lerp(float t, float a, float b)
{
return a + t * (b - a);
}
@ -342,10 +342,10 @@ static float perlin(float x, float y, float z)
int ba = p[b] + zi;
int bb = p[b + 1] + zi;
return lerp(w,
lerp(v, lerp(u, grad(p[aa], xf, yf, zf), grad(p[ba], xf - 1, yf, zf)), lerp(u, grad(p[ab], xf, yf - 1, zf), grad(p[bb], xf - 1, yf - 1, zf))),
lerp(v, lerp(u, grad(p[aa + 1], xf, yf, zf - 1), grad(p[ba + 1], xf - 1, yf, zf - 1)),
lerp(u, grad(p[ab + 1], xf, yf - 1, zf - 1), grad(p[bb + 1], xf - 1, yf - 1, zf - 1))));
return math_lerp(w,
math_lerp(v, math_lerp(u, grad(p[aa], xf, yf, zf), grad(p[ba], xf - 1, yf, zf)), math_lerp(u, grad(p[ab], xf, yf - 1, zf), grad(p[bb], xf - 1, yf - 1, zf))),
math_lerp(v, math_lerp(u, grad(p[aa + 1], xf, yf, zf - 1), grad(p[ba + 1], xf - 1, yf, zf - 1)),
math_lerp(u, grad(p[ab + 1], xf, yf - 1, zf - 1), grad(p[bb + 1], xf - 1, yf - 1, zf - 1))));
}
static int math_noise(lua_State* L)