From f74cf52946f4e569a26bc81105537b40be95c2c7 Mon Sep 17 00:00:00 2001 From: omnisci3nce Date: Fri, 12 Jul 2024 12:47:07 +1000 Subject: wip: big makeover --- src/animation.c | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'src/animation.c') diff --git a/src/animation.c b/src/animation.c index 7a79529..1c5d893 100644 --- a/src/animation.c +++ b/src/animation.c @@ -2,37 +2,37 @@ #include "log.h" #include "maths.h" -keyframe animation_sample(animation_sampler *sampler, f32 t) { - size_t previous_index = 0; - f32 previous_time = 0.0; - // look forwards - // DEBUG("%d\n", sampler->animation.values.kind); - TRACE("Total timestamps %d", sampler->animation.n_timestamps); - for (u32 i = 0; i < sampler->animation.n_timestamps; i++) { - f32 current_time = sampler->animation.timestamps[i]; - if (current_time > t) { - break; - } - previous_time = sampler->animation.timestamps[i]; - previous_index = i; - } +// keyframe animation_sample(animation_sampler *sampler, f32 t) { +// size_t previous_index = 0; +// f32 previous_time = 0.0; +// // look forwards +// // DEBUG("%d\n", sampler->animation.values.kind); +// TRACE("Total timestamps %d", sampler->animation.n_timestamps); +// for (u32 i = 0; i < sampler->animation.n_timestamps; i++) { +// f32 current_time = sampler->animation.timestamps[i]; +// if (current_time > t) { +// break; +// } +// previous_time = sampler->animation.timestamps[i]; +// previous_index = i; +// } - size_t next_index = (previous_index + 1) % sampler->animation.n_timestamps; - f32 next_time = sampler->animation.timestamps[next_index]; - printf("%d %f %d %f\n", previous_index, previous_time, next_index, next_time); +// size_t next_index = (previous_index + 1) % sampler->animation.n_timestamps; +// f32 next_time = sampler->animation.timestamps[next_index]; +// printf("%d %f %d %f\n", previous_index, previous_time, next_index, next_time); - keyframe prev_value = sampler->animation.values.values[previous_index]; - keyframe next_value = sampler->animation.values.values[next_index]; +// keyframe prev_value = sampler->animation.values.values[previous_index]; +// keyframe next_value = sampler->animation.values.values[next_index]; - printf("%d %d\n", previous_index, next_index); +// printf("%d %d\n", previous_index, next_index); - f32 time_diff = - sampler->animation.timestamps[next_index] - sampler->animation.timestamps[previous_index]; - f32 percent = (t - previous_time) / time_diff; +// f32 time_diff = +// sampler->animation.timestamps[next_index] - sampler->animation.timestamps[previous_index]; +// f32 percent = (t - previous_time) / time_diff; - quat interpolated_rot = - quat_slerp(sampler->animation.values.values[previous_index].rotation, - sampler->animation.values.values[next_index].rotation, percent); +// quat interpolated_rot = +// quat_slerp(sampler->animation.values.values[previous_index].rotation, +// sampler->animation.values.values[next_index].rotation, percent); - return (keyframe){ .rotation = interpolated_rot }; -} \ No newline at end of file +// return (keyframe){ .rotation = interpolated_rot }; +// } -- cgit v1.2.3-70-g09d2