From 3183071eda8d27f485ed9d2395d353b3b58fbad1 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 1 Mar 2014 12:32:37 +0100 Subject: [PATCH] For convenience, provide bezier curve functions globally. --- qcsrc/common/util.qc | 15 +++++++++++++++ qcsrc/common/util.qh | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index bdf80e5d1..c50a3ba53 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -2789,3 +2789,18 @@ float Mod_Q1BSP_NativeContentsFromSuperContents(float supercontents) return CONTENT_EMPTY; } #endif + +vector bezier_quadratic_getpoint(vector a, vector b, vector c, float t) +{ + return + (c - 2 * b + a) * (t * t) + + (b - a) * (2 * t) + + a; +} + +vector bezier_quadratic_getderivative(vector a, vector b, vector c, float t) +{ + return + (c - 2 * b + a) * (2 * t) + + (b - a) * 2; +} diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index 820f4f5db..503aa2d2a 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -441,3 +441,7 @@ float Announcer_PickNumber(float type, float num); float Mod_Q1BSP_SuperContentsFromNativeContents(float nativecontents); float Mod_Q1BSP_NativeContentsFromSuperContents(float supercontents); #endif + +// Quadratic splines (bezier) +vector bezier_quadratic_getpoint(vector a, vector p, vector b, float t); +vector bezier_quadratic_getderivative(vector a, vector p, vector b, float t); -- 2.39.2