From 3ec090171861605939ccba121969f274d8b0e939 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Fri, 16 May 2025 19:06:17 -0600 Subject: [PATCH] Interp Works --- src/actors/mario_sign/render.inc.c | 15 ++++++++------- src/actors/mario_sign/update.inc.c | 4 ++-- src/actors/yoshi_egg/render.inc.c | 7 +++++++ src/animation.c | 6 +++++- src/engine/Matrix.cpp | 3 --- src/port/Engine.cpp | 1 + src/port/interpolation/FrameInterpolation.cpp | 12 ++++++------ src/port/interpolation/FrameInterpolation.h | 4 ++-- 8 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/actors/mario_sign/render.inc.c b/src/actors/mario_sign/render.inc.c index 7914a283f..84e1a8068 100644 --- a/src/actors/mario_sign/render.inc.c +++ b/src/actors/mario_sign/render.inc.c @@ -11,10 +11,9 @@ * @param arg2 */ void render_actor_mario_sign(Camera* arg0, UNUSED Mat4 arg1, struct Actor* arg2) { - Mat4 sp40; + Mat4 mtx; f32 unk; s16 temp = arg2->flags; - FrameInterpolation_RecordOpenChild(arg2, 0); if (temp & 0x800) { return; } @@ -24,14 +23,16 @@ void render_actor_mario_sign(Camera* arg0, UNUSED Mat4 arg1, struct Actor* arg2) unk = MAX(unk, 0.0f); } if (!(unk < 0.0f)) { + + FrameInterpolation_RecordMatrixPush(mtx); + gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); - mtxf_pos_rotation_xyz(sp40, arg2->pos, arg2->rot); - if (render_set_position(sp40, 0) != 0) { + mtxf_pos_rotation_xyz(mtx, arg2->pos, arg2->rot); + if (render_set_position(mtx, 0) != 0) { gSPDisplayList(gDisplayListHead++, d_course_mario_raceway_dl_sign); } + FrameInterpolation_RecordMatrixPop(mtx); + } - - FrameInterpolation_RecordCloseChild(); - } diff --git a/src/actors/mario_sign/update.inc.c b/src/actors/mario_sign/update.inc.c index 7a85e8ac5..6a061eddd 100644 --- a/src/actors/mario_sign/update.inc.c +++ b/src/actors/mario_sign/update.inc.c @@ -11,10 +11,10 @@ void update_actor_mario_sign(struct Actor* arg0) { arg0->pos[1] += 4.0f; if (arg0->pos[1] > 800.0f) { arg0->flags |= 0x800; - arg0->rot[1] += 4; + arg0->rot[1] += 1820; } } else { - arg0->rot[1] += 4; + arg0->rot[1] += 182; } } } diff --git a/src/actors/yoshi_egg/render.inc.c b/src/actors/yoshi_egg/render.inc.c index e38625df0..2e0fe8ac0 100644 --- a/src/actors/yoshi_egg/render.inc.c +++ b/src/actors/yoshi_egg/render.inc.c @@ -51,6 +51,9 @@ void render_actor_yoshi_egg(Camera* arg0, Mat4 arg1, struct YoshiValleyEgg* egg, sp5C[0] = 0; sp5C[1] = egg->eggRot; sp5C[2] = 0; + + FrameInterpolation_RecordMatrixPush(sp60); + mtxf_pos_rotation_xyz(sp60, egg->pos, sp5C); if (render_set_position(sp60, 0) == 0) { return; @@ -58,14 +61,18 @@ void render_actor_yoshi_egg(Camera* arg0, Mat4 arg1, struct YoshiValleyEgg* egg, gSPSetGeometryMode(gDisplayListHead++, G_LIGHTING); gSPDisplayList(gDisplayListHead++, d_course_yoshi_valley_dl_16D70); + FrameInterpolation_RecordMatrixPop(sp60); } else { arg1[3][0] = egg->pos[0]; arg1[3][1] = egg->pos[1]; arg1[3][2] = egg->pos[2]; + FrameInterpolation_RecordMatrixPush(arg1); + if (render_set_position(arg1, 0) != 0) { gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gSPDisplayList(gDisplayListHead++, d_course_yoshi_valley_dl_egg_lod0); } + FrameInterpolation_RecordMatrixPop(arg1); } } diff --git a/src/animation.c b/src/animation.c index d81123ae9..92525dfc7 100644 --- a/src/animation.c +++ b/src/animation.c @@ -35,6 +35,9 @@ void convert_to_fixed_point_matrix_animation(Mtx* dest, Mat4 src) { } void mtxf_translate_rotate2(Mat4 dest, Vec3f pos, Vec3s angle) { + + FrameInterpolation_RecordMatrixPosRotXYZ(&dest, pos, angle); + f32 sx = sins(angle[0]); f32 cx = coss(angle[0]); @@ -92,7 +95,7 @@ void render_limb_or_add_mtx(Armature* arg0, s16* arg1, AnimationLimbVector arg2, } angle[i] = arg1[arg2[i].indexCycle + some_offset]; } - + FrameInterpolation_RecordMatrixPush(modelMatrix); mtxf_translate_rotate2(modelMatrix, pos, angle); //convert_to_fixed_point_matrix_animation(&gGfxPool->mtxHud[gMatrixHudCount], modelMatrix); sMatrixStackSize += 1; @@ -104,6 +107,7 @@ void render_limb_or_add_mtx(Armature* arg0, s16* arg1, AnimationLimbVector arg2, model = (virtualModel); gSPDisplayList(gDisplayListHead++, model); } + FrameInterpolation_RecordMatrixPop(modelMatrix); } void render_armature(Armature* animation, Animation* arg1, s16 timeCycle) { diff --git a/src/engine/Matrix.cpp b/src/engine/Matrix.cpp index 44e5f081d..e46804ad5 100644 --- a/src/engine/Matrix.cpp +++ b/src/engine/Matrix.cpp @@ -10,9 +10,6 @@ extern "C" { } void AddMatrix(std::vector& stack, Mat4 mtx, s32 flags) { - // Reserve space if needed to avoid reallocation overhead - stack.reserve(1000); - // Push a new matrix to the stack stack.emplace_back(); diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 58e3920ea..cc7d0755d 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -379,6 +379,7 @@ void GameEngine::ProcessGfxCommands(Gfx* commands) { mtx_replacements.emplace_back(); } } + // printf("mtxf size: %d\n", mtx_replacements.size()); time -= fps; diff --git a/src/port/interpolation/FrameInterpolation.cpp b/src/port/interpolation/FrameInterpolation.cpp index 9064cdb04..a674c1ff2 100644 --- a/src/port/interpolation/FrameInterpolation.cpp +++ b/src/port/interpolation/FrameInterpolation.cpp @@ -330,11 +330,11 @@ struct InterpolateCtx { break; case Op::MatrixPush: - // Matrix_Push(&gInterpolationMatrix); + Matrix_Push((Matrix**)&gInterpolationMatrix); break; case Op::MatrixPop: - // Matrix_Pop(&gInterpolationMatrix); + Matrix_Pop((Matrix**)&gInterpolationMatrix); break; // Unused on SF64 @@ -519,11 +519,11 @@ void FrameInterpolation_RecordActorPosRotMatrix(void) { next_is_actor_pos_rot_matrix = true; } -void FrameInterpolation_RecordMatrixPush(Mat4** matrix) { +void FrameInterpolation_RecordMatrixPush(Mat4* matrix) { if (!is_recording) return; - append(Op::MatrixPush).matrix_ptr = { matrix }; + append(Op::MatrixPush).matrix_ptr = { (Mat4**)matrix }; } void FrameInterpolation_RecordMarker(const char* file, int line) { @@ -533,10 +533,10 @@ void FrameInterpolation_RecordMarker(const char* file, int line) { // append(Op::Marker).marker = { file, line }; } -void FrameInterpolation_RecordMatrixPop(Mat4** matrix) { +void FrameInterpolation_RecordMatrixPop(Mat4* matrix) { if (!is_recording) return; - append(Op::MatrixPop).matrix_ptr = { matrix }; + append(Op::MatrixPop).matrix_ptr = { (Mat4**)matrix }; } void FrameInterpolation_RecordMatrixPut(MtxF* src) { diff --git a/src/port/interpolation/FrameInterpolation.h b/src/port/interpolation/FrameInterpolation.h index 7d2df76a8..93f4dd0a9 100644 --- a/src/port/interpolation/FrameInterpolation.h +++ b/src/port/interpolation/FrameInterpolation.h @@ -35,9 +35,9 @@ void FrameInterpolation_RecordActorPosRotMatrix(void); void FrameInterpolation_RecordMatrixPosRotXYZ(Mat4 out, Vec3f pos, Vec3s orientation); -//void FrameInterpolation_RecordMatrixPush(Matrix** mtx); +void FrameInterpolation_RecordMatrixPush(Mat4* mtx); -//void FrameInterpolation_RecordMatrixPop(Matrix** mtx); +void FrameInterpolation_RecordMatrixPop(Mat4* mtx); //void FrameInterpolation_RecordMatrixMult(Matrix* matrix, MtxF* mf, u8 mode);