From b9232ce7a36bd5c17e514d85c6e5dbcf79fea817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 2 Nov 2018 13:06:43 +0100 Subject: TileMap: Fix floor precision in world_to_map on tile borders Fixes #23250, supersedes #23315. --- scene/2d/tile_map.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 67e25ec508..a7ac2bb982 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1445,6 +1445,11 @@ Vector2 TileMap::world_to_map(const Vector2 &p_pos) const { default: {} } + // Account for precision errors on the border (GH-23250). + // 0.00005 is 5*CMP_EPSILON, results would start being unpredictible if + // cell size is > 15,000, but we can hardly have more precision anyway with + // floating point. + ret += Vector2(0.00005, 0.00005); return ret.floor(); } -- cgit v1.2.3