From 67b9090bd189bfbac7808b28c925f85a7369bdc1 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 26 Feb 2022 23:32:25 +0100 Subject: [PATCH] Use the normal transform_uv method if the texture scale is 1. --- meshers/blocky/terrain_2d_mesher_blocky.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/meshers/blocky/terrain_2d_mesher_blocky.cpp b/meshers/blocky/terrain_2d_mesher_blocky.cpp index 7386312..d4e815a 100644 --- a/meshers/blocky/terrain_2d_mesher_blocky.cpp +++ b/meshers/blocky/terrain_2d_mesher_blocky.cpp @@ -154,12 +154,22 @@ void Terrain2DMesherBlocky::add_chunk_normal(Ref chunk) { } Vector2 uvs[] = { - surface->transform_uv_scaled(Vector2(0, 0), x % texture_scale, y % texture_scale, texture_scale), - surface->transform_uv_scaled(Vector2(1, 0), x % texture_scale, y % texture_scale, texture_scale), - surface->transform_uv_scaled(Vector2(0, 1), x % texture_scale, y % texture_scale, texture_scale), - surface->transform_uv_scaled(Vector2(1, 1), x % texture_scale, y % texture_scale, texture_scale) + Vector2(0, 0), + Vector2(1, 0), + Vector2(0, 1), + Vector2(1, 1) }; + if (texture_scale <= 1) { + for (int i = 0; i < 4; ++i) { + uvs[i] = surface->transform_uv_scaled(uvs[i], x % texture_scale, y % texture_scale, texture_scale); + } + } else { + for (int i = 0; i < 4; ++i) { + uvs[i] = surface->transform_uv(uvs[i]); + } + } + Vector2 verts_normal[] = { Vector2(0, 0), Vector2(cell_size_x, 0),