akgl_tilemap_compute_tileset_offsets silently requires spacing == 0 and margin == 0 #43

Open
opened 2026-08-02 18:33:27 -04:00 by tachikoma · 0 comments
Collaborator

Source: TODO.md, "Found while writing the manual" -> "Defects with no prior entry", item 8 (at bbb7b8f)

Two bugs in the offset computation, both silent:

  1. It adds spacing to the tile pitch but sets row 0's y offset to spacing
    rather than 0
    (src/tilemap.c:228).
  2. It ignores margin entirely -- the value is read into the struct at
    src/tilemap.c:153 and never used again.

A tileset with a gutter -- which is most published tileset packs -- renders
misaligned with no diagnostic.

This materially constrains what art the library can consume: it ruled out
several otherwise suitable CC0 packs while sourcing the tutorial assets.

The alternative to fixing it is to refuse a tileset with a non-zero spacing or
margin at load, which is at least honest. Fixing it is not hard and is worth
more.

Files: src/tilemap.c:153-154, src/tilemap.c:207-231


Filed by Tachikoma (Claude Code, Opus 5, 1M context)

**Source:** TODO.md, "Found while writing the manual" -> "Defects with no prior entry", item 8 (at bbb7b8f) Two bugs in the offset computation, both silent: 1. It adds `spacing` to the tile pitch but sets **row 0's y offset to `spacing` rather than 0** (`src/tilemap.c:228`). 2. It **ignores `margin` entirely** -- the value is read into the struct at `src/tilemap.c:153` and never used again. A tileset with a gutter -- which is most published tileset packs -- renders misaligned with no diagnostic. **This materially constrains what art the library can consume**: it ruled out several otherwise suitable CC0 packs while sourcing the tutorial assets. The alternative to fixing it is to refuse a tileset with a non-zero `spacing` or `margin` at load, which is at least honest. Fixing it is not hard and is worth more. **Files:** `src/tilemap.c:153-154`, `src/tilemap.c:207-231` --- Filed by Tachikoma (Claude Code, Opus 5, 1M context)
tachikoma added this to the 0.9.x milestone 2026-08-02 18:33:27 -04:00
tachikoma added the defectblast-radius:high labels 2026-08-02 18:33:27 -04:00
tachikoma added the status::grooming label 2026-08-02 18:49:21 -04:00
Sign in to join this conversation.