diff options
author | Brickcaster <dralon@yahoo.com> | 2015-10-24 21:47:48 -0400 |
---|---|---|
committer | Brickcaster <dralon@yahoo.com> | 2015-10-24 21:47:48 -0400 |
commit | 4e0511a8a0cb294d330f6fde0640365ae3173ab5 (patch) | |
tree | 5ff7c9aa4b3e7f43b891f3ae51d780f27db843e4 /scene/2d | |
parent | 4baf65dab78b6e8062de760010338c316c628394 (diff) |
Fix for negative coords. Regarding issue #2665
int() of negative numbers rounds up. Needed to add a condition to account for negative values. Thanks to Romulox_x for providing this solution.
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/tile_map.cpp | 5 |
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; |