Add more interps

This commit is contained in:
MegaMech
2025-05-17 18:15:50 -06:00
parent 08ec787e79
commit aaa232238d
4 changed files with 33 additions and 11 deletions
+21 -5
View File
@@ -11,6 +11,7 @@
extern "C" {
#include "math_util.h"
#include "math_util_2.h"
#include "render_player.h"
}
/*
Frame interpolation.
@@ -72,7 +73,7 @@ enum class Op {
SkinMatrixMtxFToMtx,
SetTransformMatrix,
SetMatrixTransformation,
CalculateOrientationMatrix
SetTranslateRotate
};
typedef pair<const void*, int> label;
@@ -185,6 +186,12 @@ union Data {
f32 scale;
} set_matrix_transformation_data;
struct {
Mat4* dest;
Vec3f location;
Vec3s rotation;
} set_translate_rotate_data;
struct {
Mat3* dest;
f32 arg1;
@@ -384,7 +391,7 @@ struct InterpolateCtx {
// break;
case Op::MatrixMult:
interpolate_mtxf(&tmp_mtxf, &old_op.matrix_mult.mf, &new_op.matrix_mult.mf);
//interpolate_mtxf(&tmp_mtxf, &old_op.matrix_mult.mf, &new_op.matrix_mult.mf);
// Matrix_Mult(gInterpolationMatrix, (Matrix*) &tmp_mtxf, new_op.matrix_mult.mode);
break;
@@ -512,10 +519,14 @@ struct InterpolateCtx {
break;
}
case Op::CalculateOrientationMatrix: {
case Op::SetTranslateRotate: {
lerp_vec3f(&tmp_vec3f, &old_op.set_translate_rotate_data.location,
&new_op.set_translate_rotate_data.location);
lerp_vec3s(&tmp_vec3s, old_op.set_translate_rotate_data.rotation,
new_op.set_translate_rotate_data.rotation);
calculate_orientation_matrix(* tmp_mat3);
mtxf_translate_rotate(*gInterpolationMatrix, tmp_vec3f, tmp_vec3s);
break;
}
}
@@ -654,6 +665,11 @@ void FrameInterpolation_RecordSetTransformMatrix(Mat4* dest, Vec3f orientationVe
append(Op::SetTransformMatrix).set_transform_matrix_data = { dest, {orientationVector[0], orientationVector[1], orientationVector[2]}, { positionVector[0], positionVector[1], positionVector[2] }, rotationAngle, scaleFactor};
}
void FrameInterpolation_RecordTranslateRotate(Mat4* dest, Vec3f pos, Vec3s rotation) {
if (!is_recording) { return; }
append(Op::SetTranslateRotate).set_translate_rotate_data = { dest, {pos[0], pos[1], pos[2]}, { rotation[0], rotation[1], rotation[2] }};
}
void FrameInterpolation_RecordSetMatrixTransformation(Mat4* dest, Vec3f location, Vec3su rotation, f32 scale) {
if (!is_recording)
@@ -664,7 +680,7 @@ void FrameInterpolation_RecordSetMatrixTransformation(Mat4* dest, Vec3f location
void FrameInterpolation_RecordCalculateOrientationMatrix(Mat3* dest, f32 x, f32 y, f32 z, s16 rot) {
if (!is_recording) return;
append(Op::SetMatrixTransformation).set_calculate_orientation_matrix_data = { dest, x, y, z, rot};
// append(Op::SetMatrixTransformation).set_calculate_orientation_matrix_data = { dest, x, y, z, rot};
}
// Make a template for deref
+5 -1
View File
@@ -74,8 +74,12 @@ void FrameInterpolation_RecordSetMatrixTransformation(Mat4* dest, Vec3f location
void FrameInterpolation_RecordCalculateOrientationMatrix(Mat3*, f32, f32, f32, s16);
void FrameInterpolation_RecordTranslateRotate(Mat4* dest, Vec3f pos, Vec3s rotation);
//void FrameInterpolation_func_80062B18(f32* arg0, f32* arg1, f32* arg2, arg3, arg4, arg5, arg6, arg7);
#ifdef __cplusplus
}
#endif
#endif // __FRAME_INTERPOLATION_H
#endif // __FRAME_INTERPOLATION_H
+4 -2
View File
@@ -903,6 +903,8 @@ void mtxf_translate_rotate(Mat4 dest, Vec3f pos, Vec3s orientation) {
f32 sinZ = sins(orientation[2]);
f32 cosZ = coss(orientation[2]);
FrameInterpolation_RecordTranslateRotate(dest, pos, orientation);
dest[0][0] = (cosY * cosZ) + ((sinX * sinY) * sinZ);
dest[1][0] = (-cosY * sinZ) + ((sinX * sinY) * cosZ);
dest[2][0] = cosX * sinY;
@@ -1609,7 +1611,8 @@ void render_kart(Player* player, s8 playerId, s8 screenId, s8 arg3) {
f32 sp140;
s16 temp_v1;
s16 thing;
FrameInterpolation_RecordOpenChild("Player", playerId | screenId << 8);
if (player->unk_044 & 0x2000) {
sp14C[0] = 0;
sp14C[1] = player->unk_048[screenId];
@@ -1666,7 +1669,6 @@ void render_kart(Player* player, s8 playerId, s8 screenId, s8 arg3) {
// convert_to_fixed_point_matrix(&gGfxPool->mtxKart[playerId + (screenId * 8)], mtx);
// @port: Tag the transform.
FrameInterpolation_RecordOpenChild("Player", playerId | screenId << 8);
if ((player->effects & BOO_EFFECT) == BOO_EFFECT) {
if (screenId == playerId) {
+3 -3
View File
@@ -1,5 +1,5 @@
#ifndef CODE_8001F980_H
#define CODE_8001F980_H
#ifndef RENDER_PLAYER_H
#define RENDER_PLAYER_H
#include <common_structs.h>
#include "buffers.h"
@@ -278,4 +278,4 @@ extern s16 D_80165150[4][8];
extern s16 D_80165190[4][8];
extern s16 D_801651D0[4][8];
#endif
#endif // RENDER_PLAYER_H