diff --git a/src/pc/djui/djui_hud_utils.c b/src/pc/djui/djui_hud_utils.c index cf532ddbf..ab0a10488 100644 --- a/src/pc/djui/djui_hud_utils.c +++ b/src/pc/djui/djui_hud_utils.c @@ -642,8 +642,38 @@ bool djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out) { out[0] *= fovCoeff; out[1] *= fovCoeff; - out[0] += djui_hud_get_screen_width() / 2.0f; - out[1] += djui_hud_get_screen_height() / 2.0f; + f32 screenWidth, screenHeight; + if (sResolution == RESOLUTION_N64) { + screenWidth = GFX_DIMENSIONS_ASPECT_RATIO * SCREEN_HEIGHT; + screenHeight = SCREEN_HEIGHT; + } else { + u32 windowWidth, windowHeight; + WAPI.get_dimensions(&windowWidth, &windowHeight); + screenWidth = (f32) windowWidth; + screenHeight = (f32) windowHeight; + } + + out[0] += screenWidth / 2.0f; + out[1] += screenHeight / 2.0f; + + extern Vp *D_8032CE74; + if (D_8032CE74) { + Vp_t *viewport = &D_8032CE74->vp; + f32 width = viewport->vscale[0] / 2.0f; + f32 height = viewport->vscale[1] / 2.0f; + f32 x = (viewport->vtrans[0] / 4.0f) - width / 2.0f; + f32 y = SCREEN_HEIGHT - ((viewport->vtrans[1] / 4.0f) + height / 2.0f); + + f32 xDiff = screenWidth / SCREEN_WIDTH; + f32 yDiff = screenHeight / SCREEN_HEIGHT; + width *= xDiff; + height *= yDiff; + x = x * xDiff - 1; + y = (screenHeight - y * yDiff) - height; + + out[0] = x + (out[0] * (width / screenWidth)); + out[1] = y + (out[1] * (height / screenHeight)); + } return true; } diff --git a/src/pc/nametags.c b/src/pc/nametags.c index 04f478f39..e04a327a4 100644 --- a/src/pc/nametags.c +++ b/src/pc/nametags.c @@ -80,10 +80,12 @@ void nametags_render(void) { continue; } + if (!djui_hud_world_pos_to_screen_pos(m->marioObj->header.gfx.pos, (Vec3f){})) { continue; } + Vec3f pos; Vec3f out; vec3f_copy(pos, m->marioBodyState->headPos); - pos[1] = m->pos[1] + 180; + pos[1] += 100; if (djui_hud_world_pos_to_screen_pos(pos, out) && (i != 0 || (i == 0 && m->action != ACT_FIRST_PERSON))) {