From f889fa0522553def726bc8258bb3b556a4f0bdb3 Mon Sep 17 00:00:00 2001 From: jaburns Date: Sun, 18 Oct 2020 16:56:35 -0600 Subject: [PATCH] Add missing functions --- src/engine/math_util.c | 34 ++++++++++++++++++++++++++++++++ src/engine/math_util.h | 6 ++++++ src/game/platform_displacement.c | 2 ++ 3 files changed, 42 insertions(+) diff --git a/src/engine/math_util.c b/src/engine/math_util.c index 0ef1283..1f56801 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -2313,3 +2313,37 @@ s32 anim_spline_poll(Vec3f result) { return hasEnded; } + + + +// From object_helpers.c + +/** + * Multiply a vector by a matrix of the form + * | ? ? ? 0 | + * | ? ? ? 0 | + * | ? ? ? 0 | + * | 0 0 0 1 | + * i.e. a matrix representing a linear transformation over 3 space. + */ +void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v) { + s32 i; + for (i = 0; i < 3; i++) { + dst[i] = m[0][i] * v[0] + m[1][i] * v[1] + m[2][i] * v[2]; + } +} + +/** + * Multiply a vector by the transpose of a matrix of the form + * | ? ? ? 0 | + * | ? ? ? 0 | + * | ? ? ? 0 | + * | 0 0 0 1 | + * i.e. a matrix representing a linear transformation over 3 space. + */ +void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v) { + s32 i; + for (i = 0; i < 3; i++) { + dst[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2]; + } +} diff --git a/src/engine/math_util.h b/src/engine/math_util.h index f65a8cb..5f089e5 100644 --- a/src/engine/math_util.h +++ b/src/engine/math_util.h @@ -73,4 +73,10 @@ void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c); void anim_spline_init(Vec4s *keyFrames); s32 anim_spline_poll(Vec3f result); + +// From object_helpers.c +void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); +void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v); + + #endif // MATH_UTIL_H diff --git a/src/game/platform_displacement.c b/src/game/platform_displacement.c index ff6adb5..c9b3f12 100644 --- a/src/game/platform_displacement.c +++ b/src/game/platform_displacement.c @@ -1,3 +1,5 @@ +#include + #include "../engine/math_util.h" #include "../engine/surface_collision.h" #include "level_update.h"