common_tasks: add vec3 and vec4 versions of common_easing_animate

This commit is contained in:
Andrei Alexeyev 2021-10-20 23:49:09 +03:00
parent 845df89431
commit a6caa9cf7c
No known key found for this signature in database
GPG key ID: 72D26128040B9690
2 changed files with 58 additions and 1 deletions

View file

@ -325,3 +325,40 @@ DEFINE_EXTERN_TASK(common_easing_animate) {
}
}
DEFINE_EXTERN_TASK(common_easing_animate_vec3) {
vec3 from;
glm_vec3_copy(*ARGS.value, from);
vec3 scale;
glm_vec3_sub(ARGS.to, from, scale);
float ftime = ARGS.duration;
for(int t = 1; t <= ARGS.duration; t++) {
YIELD;
float f = ARGS.ease(t / ftime);
vec3 d;
glm_vec3_scale(scale, f, d);
glm_vec3_add(from, d, *ARGS.value);
}
}
DEFINE_EXTERN_TASK(common_easing_animate_vec4) {
vec4 from;
glm_vec4_copy(*ARGS.value, from);
vec4 scale;
glm_vec4_sub((float*)ARGS.to, from, scale);
float ftime = ARGS.duration;
for(int t = 1; t <= ARGS.duration; t++) {
YIELD;
float f = ARGS.ease(t / ftime);
vec3 d;
glm_vec4_scale(scale, f, d);
glm_vec4_add(from, d, *ARGS.value);
}
}

View file

@ -116,10 +116,30 @@ DECLARE_EXTERN_TASK(
DECLARE_EXTERN_TASK(
common_easing_animate,
{
{
float *value;
float to;
int duration;
glm_ease_t ease;
}
);
DECLARE_EXTERN_TASK(
common_easing_animate_vec3,
{
vec3 *value;
vec3 to;
int duration;
glm_ease_t ease;
}
);
DECLARE_EXTERN_TASK(
common_easing_animate_vec4,
{
vec4 *value;
vec4 to;
int duration;
glm_ease_t ease;
}
);