diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-11-06 22:21:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-06 22:21:37 +0100 |
commit | c8700f83a1832a6c9b809af17ce67f5f0ba2ef32 (patch) | |
tree | 146efec3aa1af1a4b5e01bbab1af17a743483a72 /scene/2d | |
parent | 90d43084c204ca467b4a88ddc68bc9e2efa52d74 (diff) | |
parent | b9232ce7a36bd5c17e514d85c6e5dbcf79fea817 (diff) |
Merge pull request #23451 from akien-mga/world_to_map_precision
TileMap: Fix floor precision in world_to_map on tile borders
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/tile_map.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
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(); } |