浏览代码

Merge pull request #23451 from akien-mga/world_to_map_precision

TileMap: Fix floor precision in world_to_map on tile borders
Rémi Verschelde 6 年之前
父节点
当前提交
c8700f83a1
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      scene/2d/tile_map.cpp

+ 5 - 0
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();
 }