Преглед на файлове

Merge pull request #2672 from Brickcaster/patch-1

Fix for world_to_map() with negative coords.  Fixes issue #2665
Juan Linietsky преди 9 години
родител
ревизия
d38fd747ab
променени са 1 файла, в които са добавени 2 реда и са изтрити 3 реда
  1. 2 3
      scene/2d/tile_map.cpp

+ 2 - 3
scene/2d/tile_map.cpp

@@ -1031,13 +1031,12 @@ Vector2 TileMap::world_to_map(const Vector2& p_pos) const{
 	switch(half_offset) {
 
 		case HALF_OFFSET_X: {
-			if (int(ret.y)&1) {
-
+			if ( ret.y > 0 ? int(ret.y)&1 : (int(ret.y)-1)&1 ) {
 				ret.x-=0.5;
 			}
 		} break;
 		case HALF_OFFSET_Y: {
-			if (int(ret.x)&1) {
+			if ( ret.x > 0 ? int(ret.x)&1 : (int(ret.x)-1)&1) {
 				ret.y-=0.5;
 			}
 		} break;