You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently each of the elements are checked if the pixel color is transparent at the the clicked coordinates (with camera offsets and zoomlevel taken into account and if it's not, it's iso coordinates are returned.
It takes between 2 and 3 ms to calculate the isometric coordinates at a given screen coordinate this way and this is not viable. And certainly not for getting the current mouse over iso coordinates.
First attempt to improve performance.
Check all elements for SDL_PointInRect which should be way cheaper. If a collision occurs, check for pixel-alpha collision. If it's not the correct tile, use the next one in the list.
Further investiagtion showed that the performance penalty comes from iterating through all the tiles. Find a smarter way to do this.
The text was updated successfully, but these errors were encountered:
Now the clicked iso coordinate is caluclated mathematically. This coordinate is then traversed down in a "column" (with one field to the left and one to the right taken into account).
This reduces the nessary checks from 128x128 (or more for bigger maps) to 128 x 3 elements and calculating coordinates now takes <0ms.
Currently each of the elements are checked if the pixel color is transparent at the the clicked coordinates (with camera offsets and zoomlevel taken into account and if it's not, it's iso coordinates are returned.
It takes between 2 and 3 ms to calculate the isometric coordinates at a given screen coordinate this way and this is not viable. And certainly not for getting the current mouse over iso coordinates.
First attempt to improve performance.
Check all elements for SDL_PointInRect which should be way cheaper. If a collision occurs, check for pixel-alpha collision. If it's not the correct tile, use the next one in the list.
Further investiagtion showed that the performance penalty comes from iterating through all the tiles. Find a smarter way to do this.
The text was updated successfully, but these errors were encountered: