Apply scale correction for tile interpolation (#881)
Some checks are pending
Build coop / build-linux (push) Waiting to run
Build coop / build-steamos (push) Waiting to run
Build coop / build-windows-opengl (push) Waiting to run
Build coop / build-windows-directx (push) Waiting to run
Build coop / build-macos-arm (push) Waiting to run
Build coop / build-macos-intel (push) Waiting to run

* Apply scale correction for tile interpolation

Credit to wibble in coop cafe for figuring out the correction

* add error checking

* float -> f32

---------

Co-authored-by: MysterD <myster@d>
This commit is contained in:
djoslin0 2025-07-24 07:27:07 -07:00 committed by GitHub
parent b76985eb64
commit fe2c31554d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -446,6 +446,8 @@ void djui_hud_render_texture_raw(const u8* texture, u32 bitSize, u32 width, u32
return;
}
if (!texture) { return; }
gDjuiHudUtilsZ += 0.01f;
// translate position
@ -478,9 +480,11 @@ void djui_hud_render_texture_raw(const u8* texture, u32 bitSize, u32 width, u32
}
void djui_hud_render_texture_tile_raw(const u8* texture, u32 bitSize, u32 width, u32 height, f32 x, f32 y, f32 scaleW, f32 scaleH, u32 tileX, u32 tileY, u32 tileW, u32 tileH) {
if (!texture) { return; }
gDjuiHudUtilsZ += 0.01f;
scaleW *= (f32) tileW / (f32) width;
scaleH *= (f32) tileH / (f32) height;
if (width != 0) { scaleW *= (f32) tileW / (f32) width; }
if (height != 0) { scaleH *= (f32) tileH / (f32) height; }
// translate position
f32 translatedX = x;
@ -513,10 +517,12 @@ void djui_hud_render_texture_tile_raw(const u8* texture, u32 bitSize, u32 width,
}
void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH) {
if (!texInfo) { return; }
djui_hud_render_texture_raw(texInfo->texture, texInfo->bitSize, texInfo->width, texInfo->height, x, y, scaleW, scaleH);
}
void djui_hud_render_texture_tile(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH, u32 tileX, u32 tileY, u32 tileW, u32 tileH) {
if (!texInfo) { return; }
djui_hud_render_texture_tile_raw(texInfo->texture, texInfo->bitSize, texInfo->width, texInfo->height, x, y, scaleW, scaleH, tileX, tileY, tileW, tileH);
}
@ -524,6 +530,8 @@ void djui_hud_render_texture_interpolated(struct TextureInfo* texInfo, f32 prevX
Gfx* savedHeadPos = gDisplayListHead;
f32 savedZ = gDjuiHudUtilsZ;
if (!texInfo) { return; }
djui_hud_render_texture_raw(texInfo->texture, texInfo->bitSize, texInfo->width, texInfo->height, prevX, prevY, prevScaleW, prevScaleH);
if (sInterpHudCount >= MAX_INTERP_HUD) { return; }
@ -548,6 +556,18 @@ void djui_hud_render_texture_tile_interpolated(struct TextureInfo* texInfo, f32
Gfx* savedHeadPos = gDisplayListHead;
f32 savedZ = gDjuiHudUtilsZ;
if (!texInfo) { return; }
// apply scale correction for tiles
if (texInfo->width != 0) {
scaleW *= ((f32)tileW / (f32)texInfo->width);
prevScaleW *= ((f32)tileW / (f32)texInfo->width);
}
if (texInfo->height != 0) {
scaleH *= ((f32)tileH / (f32)texInfo->height);
prevScaleH *= ((f32)tileH / (f32)texInfo->height);
}
djui_hud_render_texture_tile_raw(texInfo->texture, texInfo->bitSize, texInfo->width, texInfo->height, prevX, prevY, prevScaleW, prevScaleH, tileX, tileY, tileW, tileH);
if (sInterpHudCount >= MAX_INTERP_HUD) { return; }