[vec.c] Linear interpolation properly implemented

This commit is contained in:
KikooDX 2020-09-16 11:20:48 +02:00
parent 58cb48fa75
commit 62d637969d
1 changed files with 6 additions and 2 deletions

View File

@ -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);
}