-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tiled Quick: rendering only visible tiles in isometric maps #2769
Comments
@bjorn, can you please give some guidance about which parts of the code would need to be modified to fix this? I'd like to have a go at fixing it, but am unsure where to start. From what I can see, this: should become:
and then this fixed to work with isometric maps: There's also a comment here so I assume this needs to be changed too: |
With this patch, I see that visibleTileArea() needs to account for the different "shape" of an isometric map:
but at worst this should just mean that too little of the map is rendered. A more important issue is the glitch in rendering: I wonder where this issue comes from. I'm looking at IsometricRenderHelper::addTilesToNode(), and it just works with the given rect, so I don't see how it could be causing this issue. Perhaps that TODO comment is wrong. TilesNode::processTileData() seems to just be responsible for drawing individual tiles, so I don't see it causing this... |
Well, one problem is that Alternatively, we'd pass the visible area in pixels to the renderer and then the renderer can only draw the visible tiles (this is how it works with the current I can't currently explain that glitch either though. I'd also expect a different result. Maybe I can play with it a bit tomorrow. |
@mitchcurtis I've fixed that rendering issue in your screenshot in change 0712c20. I need to stop for today. Feel free to see if you can improve the rendering by expanding that rectangle until it fills the viewport (the rectangle would have to be based on which tiles are visible in the corners). |
It sounds like you'd prefer this approach. Do I understand correctly that this work would be done in IsometricRenderHelper::addTilesToNode() in that case?
Thanks for fixing that! |
Fixes mapeditor#2769
Well that was easier than I expected... copying the code from IsometricRenderer::drawTileLayer() worked well. With mitchcurtis@bd119e6 it's almost perfect. There is still some red showing through when moving the map from left to right and vice versa. Do you know where I'd fix that? Or why it's not a problem for the widget-based rendering path? |
Ah, nice work!
Could it just be an updating issue? The Of course, this was also an optimization, which will not work when we work with the visible area in pixels. |
Btw, I wonder if it would make sense to adjust the |
Yeah it seems a bit silly to duplicate the code. I can try, but no guarantees. :p |
Before I spend any more time on this, is that what you had in mind? |
Yeah, exactly! Two things which come to mind:
In addition, there is a bunch of logic in |
Is it OK to call CellRenderer::flush() if the overload of OrthogonalRenderer::drawTileLayer() that takes the RenderTileCallback returns early (i.e. nothing was drawn)?
|
Almost there, but I have an issue: 55572e6#diff-549a459c3d8ce7cb85758e9418548567R262 Do you know how I can get the tile pos? Converting there feels inefficient and the visual result is also wrong... the map is rendered in an incorrect position... |
Sure, then it should exit early: if (!mTile)
return; However, you can remove that call entirely, since
You should not need the tile pos. Just change |
Hmm... I've made those changes you suggested but it still renders weirdly... |
@mitchcurtis Can you please open a pull request? It would make collaboration a bit easier. :) |
This change adds support for staggered and hexagonal maps to Tiled Quick, as well as making sure only visible tiles are rendered, reusing the rendering code from the MapRenderer. The small optimization that was used for orthogonal tile layers was dropped for the sake of simplicity. It is not expected to make much of an impact. Fixes #2769 Co-authored-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
Support for isometric maps in tiledquickplugin was added in #1535, but all tiles in the map are rendered, rather than only those tiles within the MapItem's visibleArea.
The text was updated successfully, but these errors were encountered: