From 26e6a17e248fcbb0d34fcf7812eaa105409e129c Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 26 Feb 2022 01:48:57 +0100 Subject: [PATCH] Added back texture scale calculation to the blocky mesher. --- meshers/blocky/terrain_2d_mesher_blocky.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/meshers/blocky/terrain_2d_mesher_blocky.cpp b/meshers/blocky/terrain_2d_mesher_blocky.cpp index 75fef48..0b7db98 100644 --- a/meshers/blocky/terrain_2d_mesher_blocky.cpp +++ b/meshers/blocky/terrain_2d_mesher_blocky.cpp @@ -82,6 +82,8 @@ void Terrain2DMesherBlocky::add_chunk_normal(Ref chunk) { mcache = _library->material_cache_get(chunk->material_cache_key_get()); } + int texture_scale = get_texture_scale(); + int margin_start = chunk->get_margin_start(); //z_size + margin_start is fine, x, and z are in data space. for (int y = margin_start; y < y_size + margin_start; ++y) { @@ -147,10 +149,10 @@ void Terrain2DMesherBlocky::add_chunk_normal(Ref chunk) { add_indices(vc + 3); Vector2 uvs[] = { - surface->transform_uv(Vector2(0, 0)), - surface->transform_uv(Vector2(1, 0)), - surface->transform_uv(Vector2(0, 1)), - surface->transform_uv(Vector2(1, 1)) + 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) }; int xx = x * cell_size_x;