diff --git a/VM/src/lmathlib.cpp b/VM/src/lmathlib.cpp index 0693b846f..12b834cc3 100644 --- a/VM/src/lmathlib.cpp +++ b/VM/src/lmathlib.cpp @@ -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)