godotengine / godotengine/godot
Polygon2D (with multiple parts) fails to mask with Clip Children when Inverted on
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproducible in: 4.3-dev5, 4.2.1-stable, 4.1.3-stable
### System information
Godot v4.2.2.rc3 - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 SUPER (NVIDIA; 31.0.15.5152) - Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz (8 Threads)
### Issue description
When using a Polygon2D of multiple parts (using the Polygons array to define them via their point indices), it will correctly mask its children when Clip Children is set to Clip Only. However if you Invert the polygon, the masking fails to give the expected 'opposite' result. It doesn't matter if the boxes are created clockwise or anticlockwise.
I hope this is a legal and valid method of doing this.. I'm using this video as a guide... https://www.youtube.com/watch?v=NvJuW7ruuN0



### Steps to reproduce
We need to make a Polygon2D whose points define two separate boxes and use the Polygons array to define them via their indexes 0-3 for one and 4-7 for the other.
1. In a new scene, add a Polygon2D and create a box with 4 points.
2. In the inspector for the polygon, manually add 4 more points with Add Element for a total of 8. Drag these new points to form a second box to the side (see picture).
3. In the Inspector, under the Data/Polygons section, increase the array Size to 2.
4. For each array, change the type from null to PackedInt32Array.
5. Under the first PackedIn32Array, add 4 elements and insert values 0 to 3
6. Under the second PackedIn32Array, add 4 elements and insert values 4 to 7
8. Drag the gogot icon.svg into the viewport and overlap the edges of both boxes of the polygon.
9. Make the icon a child of the Polygon2D and set the polygon's Clip Children to Clip Only.
10. This shows the masking working correctly.
11. If you now set the polygon's Invert flag to ON, it fails. It does not give the expected result of clipping out the opposite parts of the sprite.
### Minimal reproduction project (MRP)
[PolygonInvertedClippingBug.zip](https://github.com/godotengine/godot/files/15078891/PolygonInvertedClippingBug.zip)
Contributor guide
Assessment
This issue has not been assessed yet.