Skip to content

Commit 1af0958

Browse files
authored
Merge pull request #228 from Sebanisu/fix_get_triangle_strip
[bug] Fix incorrect tile alignment caused by flooring source positions in deswizzled maps
2 parents 0dbe9aa + 70b615c commit 1af0958

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/opengl/main/map_operation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,11 @@ QuadStrip get_triangle_strip(
394394
// source_position and destination_position are in TILE_SIZE cordinates.
395395
// TILE_SIZE default is 16x16. So we pass in the scaled up source_tile_size
396396
// and destination_tile_size and do the conversion.
397-
constexpr static auto tile_size = static_cast<float>(map_group::TILE_SIZE);
398-
const glm::vec2 aligned_source = glm::floor(source_position / tile_size);
397+
constexpr static auto tile_size = static_cast<float>(map_group::TILE_SIZE);
398+
const glm::vec2 base_source = source_position / tile_size;
399399
return { .uv_min
400-
= (aligned_source * source_tile_size) / source_texture_size,
401-
.uv_max = ((aligned_source + glm::vec2(1)) * source_tile_size)
400+
= (base_source * source_tile_size) / source_texture_size,
401+
.uv_max = ((base_source + glm::vec2(1)) * source_tile_size)
402402
/ source_texture_size,
403403
.draw_pos
404404
= (destination_position / tile_size) * destination_tile_size };
@@ -576,4 +576,4 @@ void save_modified_map(
576576
path,
577577
"");
578578
}
579-
}// namespace ff_8
579+
}// namespace ff_8

0 commit comments

Comments
 (0)