Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Kamil Lewan | |
Old Version | Published before Godot 3 was released. |
Hi. I have a problem with tilemaps, viewport and performance.
Quick Questions:
- What
rect2
means in context ofViewport
? Is it position and size relative to parent node, or to what is visible in viewport (and if so, in wich coords, global, local, canvaslayer)? What’s this? - Can Viewport.rect2.pos be set to negative value?
get_rect()
andget_visible_rect()
difference?- If
set_size_override()
set’s Rect2, why bothget_rect()
andset_size_override()
exists? - How
render_target_clear()
works?
Question:
How to set viewport to render needed Rect2
relative to childrens? I need get an Image
(get_screen_capture()
) of given properties. I think I should use Camera2D like:
-root
--SubViewport
---Camera2D
---CanvasItem's
and use canvas transform, but I can’t figure how to do that. Or just use Viewport’s canvas transform?
My full situation:
I have few (currently 5) TileMap
’s, 32px^2 per tile. I set them to scale = Vector2(2,2).
For map size of 100x100 tiles AND zoom out (to see full map) I have 20 fps. When zoom in, I don’t have any performance issues.
Now I have something like this:
-root
--Viewport
---TileMap's
--customSprite
--other nodes, UI
--main Camera2D
I want to update full map every turn, pause, etc (works, c. 850-1000msec), and in runtime by chunk (probably 30-150msec, not sure). I draw on customSprite LargeTexture
where first piece is full map, next are chunks (not VRAM good solution (c. 200MB)). That part is ok (100msec isn’t bad) but in my algorithm i need iterate on part of catched image (one row of pixels) to see if all tilemaps are ready. I just set example tile on (-1,-1),(-2,-1) etc. When I update Viewport
and check !Viewport.get_screen_capture.empty()
i can’t get changes e.g added entitie to tilemap), because some tilemap updates before other.
I try use set_rect()
but, as I see it don’t works as expected…
Hope someone can help me. Thanks in advance.