-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
CanvasItem.draw_rect() culling problems #23711
Comments
This happens because there is no way to define a size of Node2D (it's just a point, without width or height). |
@kubecz3k Will it work if I scale the Control node? |
Actually, I think maybe it is a good idea to give some way to define a size for culling inside the CanvasItem (so reopening). |
@wingedadventurer I think the scale will be taken into account, but you for sure will need to define some width and height first (if the size is 0 it will still be 0 after scaling) |
@wingedadventurer another node which you can use is Sprite (if you for some reason don't want to use Control one). Sprite will have the size of the texture that is assigned to it, plus it will take scale into account (so you can attach small transparent texture and regulate the culling with the scale). |
This is either a bug or a misuse of Rect2. var left = Rect2(Vector2(-16, -16), Vector2(16, 32))
var right = Rect2(Vector2(16, -16), Vector2(-16, 32)) Note that the the Printing Printing So, either |
What @bojidar-bg says is indeed true, making Rect2's size positive doesn't result in said bug anymore. Thanks! The reason I had negative rect size is because I was drawing a door that opens by splitting. Therefore each door wing had variable width. For consistency in the code, I drew each wing from the edges, which works fine for the first one, but gives negative rect for second one. Glad we sorted this out. 😄 |
Related to #25829. |
bugsquad edit: The root of the problem was recognized in this comment: #23711 (comment)
Godot version:
3.1 alpha 2
OS/device including version:
Windows 10
Issue description:
Take a look at the gif below first:
So each box consists of 2 rectangles that are drawn using
draw_rect()
. However when I move the camera so they are positioned at either top or left edge, if one of those rects is outside, both of them disappear. The rects can even be separated, doesn't matter. This even happened at the rightmost edge of screen.On Discord we suspected it's because of culling. But it doesn't make sense to cull anything because there are visible parts on the screen.
I've tried drawing a lot of rects and got mixed results, but I was unable to understand how exactly it works. Feel free to play around in the minimal reproduction project.
Minimal reproduction project:
draw_rect invisible.zip
The text was updated successfully, but these errors were encountered: