mapeditor / mapeditor/tiled

Screen to tile coord

Open
#987 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.