From c61392c72286fad2a614e31b66989b3fb0e361be Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Tue, 11 Aug 2026 12:45:00 +0300 Subject: [PATCH] Fix terrain patch add mode not picking patches in scaled terrain --- Source/Editor/Tools/Terrain/TerrainTools.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Editor/Tools/Terrain/TerrainTools.cpp b/Source/Editor/Tools/Terrain/TerrainTools.cpp index 8e83e77cf..9914c0bac 100644 --- a/Source/Editor/Tools/Terrain/TerrainTools.cpp +++ b/Source/Editor/Tools/Terrain/TerrainTools.cpp @@ -21,7 +21,7 @@ bool TerrainTools::TryGetPatchCoordToAdd(Terrain* terrain, const Ray& ray, Int2& { CHECK_RETURN(terrain, true); result = Int2::Zero; - const float patchSize = terrain->GetChunkSize() * TERRAIN_UNITS_PER_VERTEX * Terrain::ChunksCountEdge; + const auto patchSize = terrain->GetChunkSize() * TERRAIN_UNITS_PER_VERTEX * Terrain::ChunksCountEdge * terrain->GetScale(); // Try to pick any of the patch edges for (int32 patchIndex = 0; patchIndex < terrain->GetPatchesCount(); patchIndex++) @@ -36,7 +36,7 @@ bool TerrainTools::TryGetPatchCoordToAdd(Terrain* terrain, const Ray& ray, Int2& #define CHECK_EDGE(dx, dz) \ if (terrain->GetPatch(x + dx, z + dz) == nullptr) \ { \ - if (bounds.MakeOffsetted(Vector3(patchSize * dx, 0, patchSize * dz)).Intersects(ray)) \ + if (bounds.MakeOffsetted(Vector3(patchSize.X * dx, 0, patchSize.Z * dz)).Intersects(ray)) \ { \ result = Int2(x + dx, z + dz); \ return true; \