0 votes

Hi. I have a problem with tilemaps, viewport and performance.

Quick Questions:

  1. What rect2 means in context of Viewport? 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?
  2. Can Viewport.rect2.pos be set to negative value?
  3. get_rect() and get_visible_rect() difference?
  4. If set_size_override() set's Rect2, why both get_rect() and set_size_override() exists?
  5. 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.

in Engine by (186 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.