Skip to content

Commit

Permalink
Fixed lerp() duplicate when compiling for C++20 (#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
niansa authored Mar 6, 2023
1 parent 140e5a1 commit 78798d4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions VM/src/lmathlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 78798d4

Please sign in to comment.