mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-11 00:38:18 +03:00
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user