From 62d637969d1e63c99200ad43b756bf8f2d3b0852 Mon Sep 17 00:00:00 2001 From: KikooDX Date: Wed, 16 Sep 2020 11:20:48 +0200 Subject: [PATCH] [vec.c] Linear interpolation properly implemented --- src/vec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vec.c b/src/vec.c index a5a555c..1134c37 100644 --- a/src/vec.c +++ b/src/vec.c @@ -32,9 +32,13 @@ void vec_div(Vec *vector, float scale) void vec_lerp(Vec *from, Vec to, float scale) { - Vec temp = {}; + /* from * (1 - scale) + temp * scale */ + Vec temp; vec_cpy(&temp, to); - vec_sub(&temp, *from); + /* from * (1 - scale) */ + vec_mul(from, 1 - scale); + /* temp * scale */ vec_mul(&temp, scale); + /* add */ vec_add(from, temp); }