Better vec_clamp

This commit is contained in:
KikooDX 2021-01-14 13:28:16 +01:00
parent c9548c1a67
commit 5bc5ee8b22
1 changed files with 3 additions and 11 deletions

View File

@ -47,17 +47,9 @@ void vec_divf(Vec *vector, float scale) {
void vec_lerp(Vec *from, Vec to, float scale) {
/* A linear interpolation function, can be used for camera and
* animations. 'scale' is the transformation speed, 1 being
* instant.
*/
/* from * (1 - scale) + temp * scale */
Vec temp;
vec_cpy(&temp, to);
/* from * (1 - scale) */
vec_mulf(from, 1 - scale);
/* temp * scale */
vec_mulf(&temp, scale);
/* add */
vec_add(from, temp);
* instant. */
from->x = from->x * (1 - scale) + to.x * scale;
from->y = from->y * (1 - scale) + to.y * scale;
}
void vec_clamp(Vec *to_limit, Vec min, Vec max) {