fix for 2012-04-08T21:42:48Z!justas.tomkus@google.com; making tile width and zoom independant
This commit is contained in:
parent
402653e01b
commit
bb7b4f7b79
1 changed files with 5 additions and 4 deletions
|
@ -552,10 +552,11 @@ const display::rect_of_hexes display::hexes_under_rect(const SDL_Rect& r) const
|
|||
double tile_width = hex_width();
|
||||
double tile_size = hex_size();
|
||||
double border = theme_.border().size;
|
||||
// we minus 18, because it's how many pixels overlap of each two nearby
|
||||
// hexes, and dividing it by tile width becomes horizontal imbrication.
|
||||
// in this case 18/54 = 0.(3)
|
||||
res.left = static_cast<int>(std::floor(-border + (x-18) / tile_width));
|
||||
// we minus "0.(3)", for horizontal imbrication.
|
||||
// reason is: two adjacent hexes each overlap 1/4 of their width, so for
|
||||
// grid calculation 3/4 of tile width is used, which by default gives
|
||||
// 18/54=0.(3). Note that, while tile_width is zoom dependand, 0.(3) is not.
|
||||
res.left = static_cast<int>(std::floor(-border + x / tile_width - 0.3333333));
|
||||
// we remove 1 pixel of the rectangle dimensions
|
||||
// (the rounded division take one pixel more than needed)
|
||||
res.right = static_cast<int>(std::floor(-border + (x + r.w-1) / tile_width));
|
||||
|
|
Loading…
Add table
Reference in a new issue