LocalDecoder.dds wrote every block of a mip's stored grid under a DDS
header. For NPOT chains the stored grid is wider or taller than the DDS
mip: 17x13 BC1 stores its 8x6 mip 1 as 3x2 blocks where DDS holds 2x2,
so the payload was 208 bytes instead of 192 and a DDS reader saw every
later mip shifted. ASSET-568 switched the compact branch to the stored
grid to get the offsets right but dropped the crop. The mode-1 array
branch kept the DDS grid instead, and addresses() takes its tile pitch
from that grid, so a 513x520 BC7 array read mip 1 rows 64 and on from the
wrong tile.
Read each mip on its stored grid (which also gives the tile pitch) and
keep only the DDS rows and columns, as ttpf_mips._visible_rows does for
the regular export. Both cases now give the same bytes as
ttpf_mips.texture_dds.
Tested: new test_dds_npot_mips_are_cropped_to_the_dds_grid (fails before
the fix in both cases, passes after).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`python -I` implies `-P`, so the directory of the script is not `sys.path[0]` and a tool that imports the module
next to it dies before `main()`:
python -I tools/calibrated_texture.py --help
ModuleNotFoundError: No module named 'bcpack'
`calibrated_texture.py` imports `bcpack`, `bcpack_tables` and `ttpf_mips` and added nothing; `ttpf_assets.py`
imports `bcpack`, `file_mode`, `ttpf_mips` and `calibrated_texture` and added nothing either, so the build's
texture stage tools could only be run through `make_game.py`, never directly as CONTRIBUTING.md documents.
Insert `os.path.dirname(os.path.abspath(__file__))` before the sibling imports, the pattern already used by
`tools/anim_clips.py`. `tests/test_tool_startup.py` derives the affected set from the sources and runs
`python -I <tool> --help` for all of them, so a new tool with a sibling import is covered without editing the
test; without the two fixes it fails exactly on those two tools.
A sweep of `python -I tools/*.py --help` over all 110 tools found no other case.