forked from kdx/jtmm2-old
Better vec_clamp
This commit is contained in:
parent
c9548c1a67
commit
5bc5ee8b22
14
src/vec.c
14
src/vec.c
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue