summaryrefslogtreecommitdiff
path: root/src/animation.c
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-04-06 11:51:33 +1100
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-04-06 11:51:33 +1100
commitef264da91e1e7efc209bd49320fc5907f62312a7 (patch)
tree58bf2c9a31ef73b631643afa6bc1de154146a061 /src/animation.c
parente5495790aeba905505152ad3b6690f459a44df03 (diff)
add a skinned model example from gltf sample models.
Diffstat (limited to 'src/animation.c')
-rw-r--r--src/animation.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/animation.c b/src/animation.c
index f6741e8..de7e9a2 100644
--- a/src/animation.c
+++ b/src/animation.c
@@ -1,6 +1,6 @@
#include "animation.h"
-#include "maths.h"
#include "log.h"
+#include "maths.h"
keyframe animation_sample(animation_sampler *sampler, f32 t) {
size_t previous_index = 0;
@@ -15,7 +15,6 @@ keyframe animation_sample(animation_sampler *sampler, f32 t) {
}
previous_time = current_time;
previous_index = i;
-
}
size_t next_index = (previous_index + 1) % sampler->animation.n_timestamps;
@@ -26,13 +25,14 @@ keyframe animation_sample(animation_sampler *sampler, f32 t) {
keyframe next_value = sampler->animation.values.values[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 - sampler->animation.timestamps[next_index]) / time_diff;
- quat interpolated_rot = quat_slerp(sampler->animation.values.values[previous_index].rotation,
- sampler->animation.values.values[next_index].rotation, percent);
+ f32 time_diff =
+ sampler->animation.timestamps[next_index] - sampler->animation.timestamps[previous_index];
+ f32 percent = (t - sampler->animation.timestamps[next_index]) / time_diff;
+
+ 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 };
+ return (keyframe){ .rotation = interpolated_rot };
} \ No newline at end of file