Skip to content

intersect_polyline_with_polygon, but getting the cut polygons #132

Answered by Xrayez
opyate asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah that's an interesting problem, there was Q&A question I answered some time ago:

There's no such method exposed because the underlying library for polygon clipping in Godot (Clipper) doesn't support such operation.

You can in theory simulate this by using Geometry.offset_polyline_2d with a very small delta, which will grow your polyline into a thin polygon, and then do the clipping between polygons. Or, you can generate two rectangles along with a polyline (if it's a straight line), and do Geometry.intersect_polygons_2d two times against your subject polygon on the both side of the polyline.

Example

extends Node2D

func _draw():
	var circle = GoostGeometry2D.circle(50)

	var polyline =

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@opyate
Comment options

Answer selected by Xrayez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants