summaryrefslogtreecommitdiff
path: root/src/port/interpolation/FrameInterpolation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/port/interpolation/FrameInterpolation.cpp')
-rw-r--r--src/port/interpolation/FrameInterpolation.cpp65
1 files changed, 61 insertions, 4 deletions
diff --git a/src/port/interpolation/FrameInterpolation.cpp b/src/port/interpolation/FrameInterpolation.cpp
index 836e6c70c..438c10c0a 100644
--- a/src/port/interpolation/FrameInterpolation.cpp
+++ b/src/port/interpolation/FrameInterpolation.cpp
@@ -7,6 +7,7 @@
#include "port/Engine.h"
#include "FrameInterpolation.h"
#include "matrix.h"
+#include "engine/Matrix.h"
extern "C" {
#include "math_util.h"
@@ -81,7 +82,9 @@ enum class Op {
SkinMatrixMtxFToMtx,
SetTransformMatrix,
SetMatrixTransformation,
- SetTranslateRotate
+ SetTranslateRotate,
+ SetTextMatrix,
+ SetMatrixPosRotScaleXY,
};
typedef pair<const void*, uintptr_t> label;
@@ -140,12 +143,21 @@ union Data {
} matrix_mult_4x4;
struct {
+ Mat4* matrix;
Vec3fInterp pos;
Vec3sInterp orientation;
} matrix_pos_rot_xyz;
struct {
Mat4* matrix;
+ s32 x;
+ s32 y;
+ u16 angle;
+ f32 scale;
+ } matrix_pos_rot_scale_xy;
+
+ struct {
+ Mat4* matrix;
Vec3f translation;
Vec3s rotation;
} matrix_translate_rotate_zyx;
@@ -209,6 +221,14 @@ union Data {
} set_orientation_matrix_data;
struct {
+ Mat4* matrix;
+ f32 x;
+ f32 y;
+ f32 arg3;
+ f32 arg4;
+ } matrix_text;
+
+ struct {
label key;
size_t idx;
} open_child;
@@ -254,6 +274,7 @@ struct InterpolateCtx {
Mat3 tmp_mat3;
Vec3f tmp_vec3f, tmp_vec3f2;
Vec3s tmp_vec3s;
+ int32_t tmp32[2];
MtxF actor_mtx;
MtxF* new_replacement(Mtx* addr) {
@@ -276,6 +297,10 @@ struct InterpolateCtx {
return w * o + step * n;
}
+ s32 lerp_s32(s32 o, s32 n) {
+ return w * o + step * n;
+ }
+
void lerp_vec3s(Vec3s* res, Vec3s o, Vec3s n) {
*res[0] = lerp_s16(o[0], n[0]);
*res[1] = lerp_s16(o[1], n[1]);
@@ -400,7 +425,6 @@ struct InterpolateCtx {
break;
case Op::MatrixTranslate:
-
Vec3f temp;
temp[0] = lerp(old_op.matrix_translate.b.x, new_op.matrix_translate.b.x);
@@ -533,6 +557,27 @@ struct InterpolateCtx {
mtxf_translate_rotate(*gInterpolationMatrix, tmp_vec3f, tmp_vec3s);
break;
}
+ case Op::SetTextMatrix: {
+
+ tmp_vec3f[0] = lerp(old_op.matrix_text.x, new_op.matrix_text.x);
+ tmp_vec3f[1] = lerp(old_op.matrix_text.y, new_op.matrix_text.y);
+ tmp_vec3f[2] = lerp(old_op.matrix_text.arg3, new_op.matrix_text.arg3);
+ tmp_vec3f2[0] = lerp(old_op.matrix_text.arg4, new_op.matrix_text.arg4);
+
+ SetTextMatrix(*gInterpolationMatrix, tmp_vec3f[0], tmp_vec3f[1], tmp_vec3f[2], tmp_vec3f2[0]);
+ break;
+ }
+ case Op::SetMatrixPosRotScaleXY: {
+ tmp32[0] = lerp_s32(old_op.matrix_pos_rot_scale_xy.x, new_op.matrix_pos_rot_scale_xy.x);
+ tmp32[1] = lerp_s32(old_op.matrix_pos_rot_scale_xy.y, new_op.matrix_pos_rot_scale_xy.y);
+
+ tmp_vec3s[0] = lerp_s16(old_op.matrix_pos_rot_scale_xy.angle, new_op.matrix_pos_rot_scale_xy.angle);
+
+ tmp_vec3f[0] = lerp(old_op.matrix_pos_rot_scale_xy.scale, new_op.matrix_pos_rot_scale_xy.scale);
+
+ mtxf_translation_x_y_rotate_z_scale_x_y(*gInterpolationMatrix, tmp32[0], tmp32[1], tmp_vec3s[0], tmp_vec3f[0]);
+ break;
+ }
}
}
}
@@ -605,6 +650,12 @@ int FrameInterpolation_GetCameraEpoch(void) {
return (int) camera_epoch;
}
+void FrameInterpolation_Record_SetTextMatrix(Mat4* matrix, f32 x, f32 y, f32 arg3, f32 arg4) {
+ if (!is_recording)
+ return;
+ append(Op::SetTextMatrix).matrix_text = {matrix, x, y, arg3, arg4};
+}
+
void FrameInterpolation_RecordActorPosRotMatrix(void) {
if (!is_recording)
return;
@@ -689,10 +740,16 @@ void FrameInterpolation_RecordCalculateOrientationMatrix(Mat3* dest, f32 x, f32
// Make a template for deref
-void FrameInterpolation_RecordMatrixPosRotXYZ(Mat4 out, Vec3f pos, Vec3s orientation) {
+void FrameInterpolation_RecordMatrixPosRotXYZ(Mat4* out, Vec3f pos, Vec3s orientation) {
+ if (!is_recording)
+ return;
+ append(Op::MatrixPosRotXYZ).matrix_pos_rot_xyz = { out, *((Vec3fInterp*) &pos), *((Vec3sInterp*) &orientation) };
+}
+
+void FrameInterpolation_RecordMatrixPosRotScaleXY(Mat4* matrix, s32 x, s32 y, u16 angle, f32 scale) {
if (!is_recording)
return;
- append(Op::MatrixPosRotXYZ).matrix_pos_rot_xyz = { *((Vec3fInterp*) &pos), *((Vec3sInterp*) &orientation) };
+ append(Op::SetMatrixPosRotScaleXY).matrix_pos_rot_scale_xy = { matrix, x, y, angle, scale };
}
void FrameInterpolation_RecordMatrixMultVec3f(Mat4* matrix, Vec3f src, Vec3f dest) {