Fix Nametags and some interpolation jank

This commit is contained in:
Agent X 2024-06-27 07:39:54 -04:00
parent 436049fe7c
commit 51f90260eb
3 changed files with 23 additions and 3 deletions

View file

@ -43,6 +43,7 @@
#include "pc/djui/djui.h"
#include "pc/lua/smlua_hooks.h"
#include "pc/mods/mods.h"
#include "pc/nametags.h"
#include "game/screen_transition.h"
@ -681,6 +682,7 @@ void check_instant_warp(void) {
}
warp_camera(warp->displacement[0], warp->displacement[1], warp->displacement[2]);
skip_camera_interpolation();
gMarioStates[0].area->camera->yaw = cameraAngle;
return;
@ -1351,6 +1353,7 @@ s32 play_mode_paused(void) {
if (!gLevelValues.zoomOutCameraOnPause || !network_check_singleplayer_pause()) {
gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN;
skip_camera_interpolation();
}
return 0;
}
@ -1831,6 +1834,9 @@ s32 init_level(void) {
extern u8 gGfxPcResetTex1;
gGfxPcResetTex1 = 1;
// reset nametags
nametags_reset();
if (gDelayedInitSound >= 0) {
play_character_sound(&gMarioStates[0], gDelayedInitSound);
gDelayedInitSound = -1;

View file

@ -15,6 +15,7 @@
struct StateExtras {
Vec3f prevPos;
f32 prevScale;
bool inited;
};
static struct StateExtras sStateExtras[MAX_PLAYERS];
@ -43,7 +44,7 @@ void djui_hud_print_outlined_text_interpolated(const char* text, f32 prevX, f32
djui_hud_print_text_interpolated(text, prevX, prevY - prevOffset, prevScale, x, y - offset, scale);
djui_hud_print_text_interpolated(text, prevX, prevY + prevOffset, prevScale, x, y + offset, scale);
// render text
djui_hud_set_color(r, g, b, 255);
djui_hud_set_color(r, g, b, a);
djui_hud_print_text_interpolated(text, prevX, prevY, prevScale, x, y, scale);
djui_hud_set_color(255, 255, 255, 255);
}
@ -72,6 +73,8 @@ void nametags_render(void) {
case ACT_START_CRAWLING:
case ACT_CRAWLING:
case ACT_STOP_CRAWLING:
case ACT_IN_CANNON:
case ACT_DISAPPEARED:
continue;
}
@ -81,7 +84,6 @@ void nametags_render(void) {
pos[1] = m->pos[1] + 210;
if (djui_hud_world_pos_to_screen_pos(pos, out) &&
m->action != ACT_IN_CANNON &&
(i != 0 || (i == 0 && m->action != ACT_FIRST_PERSON))) {
f32 scale = NAMETAG_MAX_SCALE;
f32 dist = vec3f_dist(gLakituState.pos, m->pos);
@ -100,9 +102,14 @@ void nametags_render(void) {
};
f32 measure = djui_hud_measure_text(name) * scale * 0.5f;
f32 alpha = (np->fadeOpacity / 32.0f) * 255;
u8 alpha = i == 0 ? 255 : MIN(np->fadeOpacity << 3, 255);
struct StateExtras* e = &sStateExtras[i];
if (!e->inited) {
vec3f_copy(e->prevPos, out);
e->prevScale = scale;
e->inited = true;
}
djui_hud_print_outlined_text_interpolated(name, e->prevPos[0] - measure, e->prevPos[1], e->prevScale, out[0] - measure, out[1], scale, color[0], color[1], color[2], alpha, 0.25);
if (i != 0 && gNametagsSettings.showHealth) {
@ -120,3 +127,9 @@ void nametags_render(void) {
}
}
}
void nametags_reset(void) {
for (u8 i = 0; i < MAX_PLAYERS; i++) {
sStateExtras[i].inited = false;
}
}

View file

@ -4,5 +4,6 @@
#include "sm64.h"
void nametags_render(void);
void nametags_reset(void);
#endif // NAMETAGS_H