Screen to tile coord
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 12.9k
- Forks
- 2k
- Avg merge
- 4h 27m
- Merged PRs (30d)
- 8
Description
Just to let you know there is a bug in the ISO conversion from screen to tile.
Found this while debugging my own stuff and comparing to tile.
``` c++
QPointF IsometricRenderer::tileToScreenCoords(qreal x, qreal y) const
{
const int tileWidth = map()->tileWidth();
const int tileHeight = map()->tileHeight();
const int originX = map()->height() * tileWidth / 2;
return QPointF((x - y) * tileWidth / 2 + originX,
(x + y) * tileHeight / 2);
}
```
Actually working with pure int here loses the conversion. (3.9 is rounded to 3 instead of 4....)
In swift, I had to round before converting to Int. Similar fix should work for Tiled.
return ( Int(round(tileY + tileX)), Int(round(tileY - tileX)))
Pretty late, so sorry for the quick and dirty report.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at IsometricRenderer::tileToScreenCoords and inspect how the calculated coordinates are converted to integers. Compare the behavior with the reported Swift rounding example; done means fractional results are rounded rather than truncated and screen-to-tile conversion returns the expected tile coordinates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100