From d741c4f4ddcae21d24e555fbedf182d8f4ceab95 Mon Sep 17 00:00:00 2001 From: Mr-Wiseguy Date: Mon, 1 Apr 2024 03:40:54 -0400 Subject: [PATCH] Skip rotation interpolation on the ground in the intro cutscene --- patches/billboard_tagging.c | 1 - patches/patches.h | 3 ++ patches/terrain_transform_tagging.c | 58 +++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/patches/billboard_tagging.c b/patches/billboard_tagging.c index 1958e68..303a5a1 100644 --- a/patches/billboard_tagging.c +++ b/patches/billboard_tagging.c @@ -53,7 +53,6 @@ void edit_billboard_groups(PlayState* play) { gEXEditGroupByAddress(POLY_XLU_DISP++, tracked_billboard_matrices[i], G_EX_INTERPOLATE_DECOMPOSE, G_MTX_PUSH, G_MTX_MODELVIEW, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_SKIP, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_SKIP, G_EX_COMPONENT_INTERPOLATE, G_EX_ORDER_LINEAR); - recomp_printf("Skipped matrix %08X\n", (u32)tracked_billboard_matrices[i]); } } diff --git a/patches/patches.h b/patches/patches.h index 014cf9a..21b7c53 100644 --- a/patches/patches.h +++ b/patches/patches.h @@ -17,6 +17,9 @@ #define gEXMatrixGroupDecomposedNormal(cmd, id, push, proj, edit) \ gEXMatrixGroupDecomposed(cmd, id, push, proj, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_SKIP, G_EX_COMPONENT_INTERPOLATE, G_EX_ORDER_LINEAR, edit) +#define gEXMatrixGroupDecomposedSkipRot(cmd, id, push, proj, edit) \ + gEXMatrixGroupDecomposed(cmd, id, push, proj, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_SKIP, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_SKIP, G_EX_COMPONENT_INTERPOLATE, G_EX_ORDER_LINEAR, edit) + #define gEXMatrixGroupDecomposedSkipPosRot(cmd, id, push, proj, edit) \ gEXMatrixGroupDecomposed(cmd, id, push, proj, G_EX_COMPONENT_SKIP, G_EX_COMPONENT_SKIP, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_SKIP, G_EX_COMPONENT_INTERPOLATE, G_EX_ORDER_LINEAR, edit) diff --git a/patches/terrain_transform_tagging.c b/patches/terrain_transform_tagging.c index bc83b13..2b392c7 100644 --- a/patches/terrain_transform_tagging.c +++ b/patches/terrain_transform_tagging.c @@ -1,5 +1,6 @@ #include "patches.h" #include "transform_ids.h" +#include "overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h" static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; @@ -39,3 +40,60 @@ void Room_Draw(PlayState* play, Room* room, u32 flags) { return; } +extern Gfx gKeikokuDemoFloorDL[]; +extern Gfx gKeikokuDemoFloorEmptyDL[]; +extern Gfx gKeikokuDemoTallTreeWithRootBaseDL[]; +extern Gfx gKeikokuDemoTallTreeWithRootBaseEmptyDL[]; +extern Gfx gKeikokuDemoTallTreeCutDL[]; +extern Gfx gKeikokuDemoTallTreeCutEmptyDL[]; +extern Gfx gKeikokuDemoTallTreeStraightDL[]; +extern Gfx gKeikokuDemoTallTreeStraightEmptyDL[]; + +// @recomp Tag the ground in the intro cutscene to not interpolate rotation. +void DmOpstage_Draw(Actor* thisx, PlayState* play) { + DmOpstage* this = (DmOpstage*)thisx; + + if (DMOPSTAGE_GET_TYPE(&this->dyna.actor) > DMOPSTAGE_TYPE_GROUND) { + // Assumption: worldPos is being manipulated by cutscene + Matrix_Translate(this->dyna.actor.world.pos.x + this->drawOffset.x, + this->dyna.actor.world.pos.y + this->drawOffset.y, + this->dyna.actor.world.pos.z + this->drawOffset.z, MTXMODE_NEW); + Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + } + + switch (DMOPSTAGE_GET_TYPE(&this->dyna.actor)) { + case DMOPSTAGE_TYPE_GROUND: + OPEN_DISPS(play->state.gfxCtx); + + // @recomp Tag the ground to skip rotation. + gEXMatrixGroupDecomposedSkipRot(POLY_OPA_DISP++, actor_transform_id(thisx) + 0, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE); + + Gfx_DrawDListOpa(play, gKeikokuDemoFloorDL); + Gfx_DrawDListXlu(play, gKeikokuDemoFloorEmptyDL); + + // @recomp Pop the tag. + gEXPopMatrixGroup(POLY_OPA_DISP++, G_MTX_MODELVIEW); + + CLOSE_DISPS(play->state.gfxCtx); + break; + + case DMOPSTAGE_TYPE_ROOT_TREE: + Gfx_DrawDListOpa(play, gKeikokuDemoTallTreeWithRootBaseDL); + Gfx_DrawDListXlu(play, gKeikokuDemoTallTreeWithRootBaseEmptyDL); + break; + + case DMOPSTAGE_TYPE_CUT_TREE: + Gfx_DrawDListOpa(play, gKeikokuDemoTallTreeCutDL); + Gfx_DrawDListXlu(play, gKeikokuDemoTallTreeCutEmptyDL); + break; + + case DMOPSTAGE_TYPE_STRAIGHT_TREE: + Gfx_DrawDListOpa(play, gKeikokuDemoTallTreeStraightDL); + Gfx_DrawDListXlu(play, gKeikokuDemoTallTreeStraightEmptyDL); + break; + + default: + break; + } +}