From 169036215af538de6cc5ad10fb51dc5dd14aeb60 Mon Sep 17 00:00:00 2001 From: Denneisk <20892685+Denneisk@users.noreply.github.com> Date: Fri, 1 Dec 2023 20:52:57 +0000 Subject: [PATCH] Reintroduce bezier polyfill --- .../gmod_wire_expression2/core/vector.lua | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lua/entities/gmod_wire_expression2/core/vector.lua b/lua/entities/gmod_wire_expression2/core/vector.lua index 06a05f2e56..2241677d2d 100644 --- a/lua/entities/gmod_wire_expression2/core/vector.lua +++ b/lua/entities/gmod_wire_expression2/core/vector.lua @@ -14,6 +14,27 @@ local rad2deg = 180 / pi local deg2rad = pi / 180 local LerpVector = LerpVector + +-- Remove this when a later, mandatory update is made. +-- These were added in the August (08) 9 (09) 2023 (23) update +if VERSION < 230809 then + function math.CubicBezier(frac, p0, p1, p2, p3) + local frac2 = frac * frac + local inv = 1 - frac + local inv2 = inv * inv + + return inv2 * inv * p0 + 3 * inv2 * frac * p1 + 3 * inv * frac2 * p2 + frac2 * frac * p3 + end + + function math.QuadraticBezier(frac, p0, p1, p2) + local frac2 = frac * frac + local inv = 1 - frac + local inv2 = inv * inv + + return inv2 * p0 + 2 * inv * frac * p1 + frac2 * p2 + end +end + local quadraticBezier = math.QuadraticBezier local cubicBezier = math.CubicBezier