Skip to content

Commit

Permalink
Reintroduce bezier polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
Denneisk authored Dec 1, 2023
1 parent d562d60 commit 1690362
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lua/entities/gmod_wire_expression2/core/vector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1690362

Please sign in to comment.