summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-11-18 19:07:53 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-11-18 19:07:53 -0300
commitd38fd747aba7bd452f4228a01f6d4a7487335c49 (patch)
treed11032580ed550805b270acd4dfaaf3d07c56fda /scene
parent5db52552602c781d1ea5241ead87e38856bccd27 (diff)
parent4e0511a8a0cb294d330f6fde0640365ae3173ab5 (diff)
Merge pull request #2672 from Brickcaster/patch-1
Fix for world_to_map() with negative coords. Fixes issue #2665
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/tile_map.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 418ee192b2..167b637bdc 100644
--- a/scene/2d/tile_map.cpp
+++ b/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;