From 0a6242ef3cba2623ef54734e9ed53086c767a664 Mon Sep 17 00:00:00 2001 From: Sara Date: Wed, 14 Jun 2023 18:50:55 +0200 Subject: [PATCH] sprite origin is now applied to untransformed rect --- src/corelib/render.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/render.c b/src/corelib/render.c index 7eb4ded..abee531 100644 --- a/src/corelib/render.c +++ b/src/corelib/render.c @@ -80,10 +80,10 @@ static void _exec_sprite_cmd(const drawcmd_t* cmd) { const sprite_t* sprite = &cmd->sprite; SDL_FRect untransformed = {sprite->x, sprite->y, sprite->sx, sprite->sy}; + untransformed.x -= sprite->origin.x; + untransformed.y -= sprite->origin.y; SDL_FRect destrect = get_dest_with_size(untransformed, cmd->ui); SDL_FPoint origin = {destrect.w * sprite->origin.x, destrect.h * sprite->origin.y}; - destrect.x -= origin.x; - destrect.y -= origin.y; SDL_RenderCopyExF(g_context.renderer, sprite->texture, &sprite->uv, &destrect, sprite->rot, &origin, sprite->flip);