Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce bezier polyfill #2920

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading