Added back texture scale calculation to the blocky mesher.

This commit is contained in:
Relintai 2022-02-26 01:48:57 +01:00
parent b0efd71c47
commit 26e6a17e24

View File

@ -82,6 +82,8 @@ void Terrain2DMesherBlocky::add_chunk_normal(Ref<Terrain2DChunkDefault> chunk) {
mcache = _library->material_cache_get(chunk->material_cache_key_get()); mcache = _library->material_cache_get(chunk->material_cache_key_get());
} }
int texture_scale = get_texture_scale();
int margin_start = chunk->get_margin_start(); int margin_start = chunk->get_margin_start();
//z_size + margin_start is fine, x, and z are in data space. //z_size + margin_start is fine, x, and z are in data space.
for (int y = margin_start; y < y_size + margin_start; ++y) { for (int y = margin_start; y < y_size + margin_start; ++y) {
@ -147,10 +149,10 @@ void Terrain2DMesherBlocky::add_chunk_normal(Ref<Terrain2DChunkDefault> chunk) {
add_indices(vc + 3); add_indices(vc + 3);
Vector2 uvs[] = { Vector2 uvs[] = {
surface->transform_uv(Vector2(0, 0)), surface->transform_uv_scaled(Vector2(0, 0), x % texture_scale, y % texture_scale, texture_scale),
surface->transform_uv(Vector2(1, 0)), surface->transform_uv_scaled(Vector2(1, 0), x % texture_scale, y % texture_scale, texture_scale),
surface->transform_uv(Vector2(0, 1)), surface->transform_uv_scaled(Vector2(0, 1), x % texture_scale, y % texture_scale, texture_scale),
surface->transform_uv(Vector2(1, 1)) surface->transform_uv_scaled(Vector2(1, 1), x % texture_scale, y % texture_scale, texture_scale)
}; };
int xx = x * cell_size_x; int xx = x * cell_size_x;