Skip to content

Bug: Fix incorrect tile alignment caused by flooring source positions in deswizzled maps#228

Merged
Sebanisu merged 1 commit intomainfrom
fix_get_triangle_strip
Nov 25, 2025
Merged

Bug: Fix incorrect tile alignment caused by flooring source positions in deswizzled maps#228
Sebanisu merged 1 commit intomainfrom
fix_get_triangle_strip

Conversation

@Sebanisu
Copy link
Copy Markdown
Owner

@Sebanisu Sebanisu commented Nov 25, 2025

This PR fixes an issue where flooring the source position during tile
lookup caused misalignment when reading deswizzled files that include
pixel offsets.

For example, bdifirit1 is offset by (0 px, 8 px).
Because the code previously divided and then floored the source
position:

const glm::vec2 aligned_source = glm::floor(source_position / tile_size);

...the resulting tile index was shifted by 8 px, breaking map rendering
for any textures with non-zero offsets.

✔️ Fix

The flooring step has been removed to preserve accurate tile
coordinates:

const glm::vec2 base_source = source_position / tile_size;

This ensures maps with offsets are read correctly.

🔗 Related Issue

Fixes: #227

image

by flooring it would break reading in deswizzled files from maps that were offset. bdifirit1 is offset by (0 px, 8 px) so we'd do the division and divide and floor causing it all to be off by 8 px.
@Sebanisu Sebanisu added this to the Nov-2025 milestone Nov 25, 2025
@Sebanisu Sebanisu self-assigned this Nov 25, 2025
@Sebanisu Sebanisu added the bug Something isn't working label Nov 25, 2025
@Sebanisu Sebanisu changed the title Refactor source position calculation in map_operation [bug] Fix incorrect tile alignment caused by flooring source positions in deswizzled maps Nov 25, 2025
@Sebanisu Sebanisu merged commit 1af0958 into main Nov 25, 2025
2 checks passed
@Sebanisu Sebanisu deleted the fix_get_triangle_strip branch November 25, 2025 01:35
@Sebanisu Sebanisu changed the title [bug] Fix incorrect tile alignment caused by flooring source positions in deswizzled maps Bug: Fix incorrect tile alignment caused by flooring source positions in deswizzled maps Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Y coordinate incorrect in render from upscale deswizzle

1 participant