#2515: drawTiles() sets tileScreenInfo[i][j].y values which do not exactly correspond to rendered tiles ---------------------+------------------------------------- Reporter: Cyp | Owner: Type: bug | Status: new Priority: normal | Milestone: unspecified Component: other | Version: git/master Keywords: | Operating System: All/Non-Specific Blocked By: | Blocking: ---------------------+------------------------------------- When clicking on a tile, sometimes it thinks another tile was clicked on, as if the mouse was slightly higher than it really was.
To see this, put down a checkerboard of rearming pads, deselect anything in order to have the arrow cursor, and use this patch to constantly see (in the terminal) which tile it thinks the mouse is over, and what the corresponding tileScreenInfo[i][j] values of the corners of the tile are. "mouseXY = (%d,%d), quad = (%d,%d),(%d,%d),(%d,%d),(%d,%d)" is in actual pixels, "mousePos = (% 8.3lf,% 8.3lf)" is in map coordinates {{{ diff --git a/src/display3d.cpp b/src/display3d.cpp index a170f7d..a15533c 100644 --- a/src/display3d.cpp +++ b/src/display3d.cpp @@ -3581,6 +3581,8 @@ static void locateMouse(void) const Vector2i pt(mouseX(), mouseY()); unsigned int i; int nearestZ = INT_MAX; +QUAD q; +Vector2i aa, bb; for(i = 0; i < visibleTiles.x; ++i) { @@ -3623,10 +3625,14 @@ static void locateMouse(void) /* Store away z value */ nearestZ = tileZ; +aa = Vector2i(mouseTileX, mouseTileY); bb = positionInQuad(pt, quad); +//ASSERT(0 <= ret[0] && ret[0] <= TILE_UNITS && 0 <= ret[1] && ret[1] <= TILE_UNITS, "aaa (%d,%d)", ret[0], ret[1]); +q = quad; } } } } +printf("mouseXY = (%d,%d), quad = (%d,%d),(%d,%d),(%d,%d),(%d,%d), mousePos = (% 8.3lf,% 8.3lf) = (%d,%d) + .(%d,%d)\n", mouseX(), mouseY(), q.coords[0].x, q.coords[0].y, q.coords[1].x, q.coords[1].y, q.coords[2].x, q.coords[2].y, q.coords[3].x, q.coords[3].y, mousePos.x * (1./TILE_UNITS), mousePos.y * (1./TILE_UNITS), aa.x, aa.y, bb.x, bb.y); } /// Render the sky and surroundings }}} -- Ticket URL: <http://developer.wz2100.net/ticket/2515> Warzone 2100 Trac <http://developer.wz2100.net/> The Warzone 2100 Project _______________________________________________ Warzone-dev mailing list Warzone-dev@gna.org https://mail.gna.org/listinfo/warzone-dev