From 9ddc7311f10080f6b5ccda357259f37ba306195c Mon Sep 17 00:00:00 2001 From: Isaac0-dev <62234577+Isaac0-dev@users.noreply.github.com> Date: Tue, 7 Jan 2025 07:55:59 +1000 Subject: [PATCH] cleaner fix for headPos bug nametags --- include/types.h | 1 + src/game/mario_misc.c | 3 ++- src/pc/nametags.c | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/types.h b/include/types.h index f567c0c50..90d616197 100644 --- a/include/types.h +++ b/include/types.h @@ -317,6 +317,7 @@ struct MarioBodyState /*????*/ Vec3f handFootPos[4]; /*????*/ u32 updateTorsoTime; /*????*/ Vec3f headPos; + /*????*/ u32 updateHeadPosTime; /*????*/ u16 shadeR; /// shadow red value /*????*/ u16 shadeG; /// shadow green value /*????*/ u16 shadeB; /// shadow blue value diff --git a/src/game/mario_misc.c b/src/game/mario_misc.c index d59f16ed5..70c509422 100644 --- a/src/game/mario_misc.c +++ b/src/game/mario_misc.c @@ -432,7 +432,7 @@ Gfx* geo_mario_tilt_torso(s32 callContext, struct GraphNode* node, Mat4* mtx) { if (callContext == GEO_CONTEXT_RENDER) { struct GraphNodeRotation* rotNode = (struct GraphNodeRotation*) node->next; - if (action != ACT_BUTT_SLIDE && action != ACT_HOLD_BUTT_SLIDE && action != ACT_WALKING && action != ACT_RIDING_SHELL_GROUND + if (action != ACT_BUTT_SLIDE && action != ACT_HOLD_BUTT_SLIDE && action != ACT_WALKING && action != ACT_RIDING_SHELL_GROUND && !bodyState->allowPartRotation) { vec3s_copy(bodyState->torsoAngle, gVec3sZero); } @@ -490,6 +490,7 @@ Gfx* geo_mario_head_rotation(s32 callContext, struct GraphNode* node, Mat4* c) { get_pos_from_transform_mtx(bodyState->headPos, *c, *gCurGraphNodeCamera->matrixPtr); + bodyState->updateHeadPosTime = gGlobalTimer; } return NULL; } diff --git a/src/pc/nametags.c b/src/pc/nametags.c index e5d3ac807..789bf1da1 100644 --- a/src/pc/nametags.c +++ b/src/pc/nametags.c @@ -80,12 +80,12 @@ void nametags_render(void) { continue; } - if (!djui_hud_world_pos_to_screen_pos(m->marioObj->header.gfx.pos, (Vec3f){})) { continue; } + if (m->marioBodyState->updateHeadPosTime != gGlobalTimer) { continue; } Vec3f pos; Vec3f out; - vec3f_copy(pos, m->marioObj->header.gfx.pos); - pos[1] += 200; + vec3f_copy(pos, m->marioBodyState->headPos); + pos[1] += 100; if (djui_hud_world_pos_to_screen_pos(pos, out) && (i != 0 || (i == 0 && m->action != ACT_FIRST_PERSON))) {