Repository: godot
Issue: Geometry.clip_polygons_2d sometimes produces polygon that can't be triangulated
Labels: bug,topic:core,topic:2d

### Godot version

 v3.3.3.stable.official.b973f997f

### System information

Windows 10, OpenGL ES 3.0 Renderer: GeForce GTX 1070/PCIe/SSE2

### Issue description

I am attempting to use `Geometry.clip_polygons_2d` in the following way; I have an initial polygon that must be clipped against a series of other polygons. I use the results of a given call to `Geometry.clip_polygons_2d` as the `polygon_a` input in the next clip iteration. The resulting polygon after all clip iterations is then drawn on the screen.

Occasionally, `Geometry.clip_polygons_2d` used in this manner will produce a polygon that can't be triangulated (and therefore can't be drawn), even though both input polygons are triangulatable. I haven't been able to come up with a simpler contrived example, so I just used actual data taken from the program for the attached reproduction project.

Here's the code from the reproduction project:

```gdscript
extends Node2D

var polygon_a: PoolVector2Array
var polygon_b: PoolVector2Array

func check_triangulation(polygon: PoolVector2Array) -> void:
	print("checking triangulation of " + str(polygon) + "...")
	if Geometry.triangulate_polygon(polygon).empty():
		print("triangulate polygon failed")
	else:
		print("triangulate polygon succeeded")

func _ready() -> void:
	polygon_a = PoolVector2Array([
		Vector2(210.119263, -83.963669),
		Vector2(214.227539, -82.201302),
		Vector2(7.50003, 6.48172),
		Vector2(7.50001, -0.04702),
		Vector2(211.698547, -87.645149),
	])
	polygon_b = PoolVector2Array([
		Vector2(193.326523, -125.987572),
		Vector2(180.710968, -96.579277),
		Vector2(210.119278, -83.963722),
		Vector2(54745.601563, -23478.873047),
		Vector2(54728.808594, -23520.898438),
	])

	check_triangulation(polygon_a)
	check_triangulation(polygon_b)

	print("clipping polygon_a against polygon_b")
	var clipped_polygons: Array = Geometry.clip_polygons_2d(polygon_a, polygon_b)
	for polygon in clipped_polygons:
		check_triangulation(polygon)

func _draw() -> void:
	draw_colored_polygon(polygon_a, Color("00FF00"))
	draw_colored_polygon(polygon_b, Color("880000FF"))
```

Here's the text output when it's run:

```
checking triangulation of [(210.119263, -83.963669), (214.227539, -82.201302), (7.50003, 6.48172), (7.50001, -0.04702), (211.698547, -87.645149)]...
triangulate polygon succeeded
checking triangulation of [(193.326523, -125.987572), (180.710968, -96.579277), (210.119278, -83.963722), (54745.601563, -23478.873047), (54728.808594, -23520.898438)]...
triangulate polygon succeeded
clipping polygon_a against polygon_b
checking triangulation of [(210.119278, -83.963722), (210.119278, -83.96373), (210.119263, -83.963661), (214.227524, -82.201302), (7.50003, 6.48171), (7.50001, -0.04701), (206.618042, -85.465683)]...
triangulate polygon failed
```

And here's a screenshot of the two polygons being clipped, scaled up and repositioned to better see the intersection between the them:

![ClipPolygonTest](https://user-images.githubusercontent.com/3267627/134993225-fb7f6526-1e9e-4f4a-af49-2c8fe50096e5.png)

The trouble seems to be with that inner concave point on `polygon_a`; both `polygon_a` and `polygon_b` share a nearly identical point there, and that point seems to be near-duplicated twice in the clipped polygon. Why the point is near-duplicated at all I have no idea.

### Steps to reproduce

Open the reproduction project and run it.

### Minimal reproduction project

[ClipPolygonTest.zip](https://github.com/godotengine/godot/files/7239663/ClipPolygonTest.zip)