From: Rudolf Polzer Date: Sat, 1 Mar 2014 11:32:37 +0000 (+0100) Subject: For convenience, provide bezier curve functions globally. X-Git-Tag: xonotic-v0.8.0~227 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3183071eda8d27f485ed9d2395d353b3b58fbad1;p=xonotic%2Fxonotic-data.pk3dir.git For convenience, provide bezier curve functions globally. --- 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);