From f9087eb7acce5f8a4ed743c58fbabc38c218f5b2 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Wed, 6 May 2026 18:07:44 +0900 Subject: [PATCH] Flat: Fix area_x/area_y leaking into screen position area_x/area_y select a sub-rectangle of the texture, but should not shift the on-screen position. Translate the quad by (-area_x, -area_y) to cancel the offset the sub-rect's top-left would otherwise introduce. --- src/parts/render.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/parts/render.c b/src/parts/render.c index 6424955..d4b40ef 100644 --- a/src/parts/render.c +++ b/src/parts/render.c @@ -197,6 +197,10 @@ static void render_flat_cg(struct parts *parts, Texture *tex, mat4 render_m; glm_mat4_copy(combined, render_m); + // area_x/area_y select a sub-rectangle of the texture atlas, but + // should not shift the on-screen position. This translation cancels + // the offset that the sub-rect's top-left would otherwise introduce. + glm_translate(render_m, (vec3){ -(float)key->area_x, -(float)key->area_y, 0.0f }); glm_scale(render_m, (vec3){ tex->w, tex->h, 1.0f }); Rectangle rect;