sprite origin is now applied to untransformed rect

pull/5/head
Sara 2023-06-14 18:50:55 +02:00
parent a0cc95873e
commit 0a6242ef3c
1 changed files with 2 additions and 2 deletions

View File

@ -80,10 +80,10 @@ static
void _exec_sprite_cmd(const drawcmd_t* cmd) { void _exec_sprite_cmd(const drawcmd_t* cmd) {
const sprite_t* sprite = &cmd->sprite; const sprite_t* sprite = &cmd->sprite;
SDL_FRect untransformed = {sprite->x, sprite->y, sprite->sx, sprite->sy}; 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_FRect destrect = get_dest_with_size(untransformed, cmd->ui);
SDL_FPoint origin = {destrect.w * sprite->origin.x, destrect.h * sprite->origin.y}; 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, SDL_RenderCopyExF(g_context.renderer, sprite->texture,
&sprite->uv, &destrect, sprite->rot, &sprite->uv, &destrect, sprite->rot,
&origin, sprite->flip); &origin, sprite->flip);