You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem or limitation you are having in your project
you are able to cut polylines with polygons but there isnt a function to cut polygons with polylines
Describe the feature / enhancement and how it helps to overcome the problem or limitation
a function that will cut the polygon with the polyline and returns the resulting polygons if the polyline is cuts straigt though a square polygon it will create 2 polygons if the line is some crazy shape it will create more
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
the clip_polygon_2d_with_polyline takes the polygon and polyline and returns the polygon/s
If this enhancement will not be used often, can it be worked around with a few lines of script?
you can offset_polyline2d to make a polygon from the polyline and then clip both polygons but it isnt as elegant and has its limitations if you have a polyline that is shaped like the outline of a closed circle and its being offset instead of making the polygon the outline it will fill the outline and create a big shape and will just cut a hole into the other
Is there a reason why this should be core and not an add-on in the asset library?
Because the reverse is already implemented there already is an clip_polyline_with_polygon_2d function so just for the symetry
The text was updated successfully, but these errors were encountered:
Godot uses Clipper for polygon boolean operations. It does support clipping polylines with polygons, but I don't see an equivalent method for doing the opposite.
If you look at the discussion at Clipper repository, the author says it's not possible to do this either:
It's not possible to use lines or polylines to clip polygons. However, as a
workaround, you could convert a line/polyline into a polygon before clipping.
So, not sure if it's not possible at all or not possible to do in Clipper, but according the proposed solutions there, it would likely require significant workarounds over a feature which is not supported, as suggested above.
However, if this proposal gains plenty of support and use cases, then it will be worth implementing. I may post a GDScript solution for the mentioned workaround if I'll need this myself at some point. 🙂
I don't know whether other polygon boolean libraries support this either. I think that the authors would already implement such a feature in case it's trivial, but apparently not.
Describe the project you are working on
n/a
It's not necessarily the project you need to describe, there must be concrete cases where a particular feature is needed. What do you need this for in your project?
I personally think that the suggested workaround is an acceptable solution for game development needs (like Fruit Ninja®).
Describe the project you are working on
n/a
Describe the problem or limitation you are having in your project
you are able to cut polylines with polygons but there isnt a function to cut polygons with polylines
Describe the feature / enhancement and how it helps to overcome the problem or limitation
a function that will cut the polygon with the polyline and returns the resulting polygons if the polyline is cuts straigt though a square polygon it will create 2 polygons if the line is some crazy shape it will create more
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
the clip_polygon_2d_with_polyline takes the polygon and polyline and returns the polygon/s
If this enhancement will not be used often, can it be worked around with a few lines of script?
you can offset_polyline2d to make a polygon from the polyline and then clip both polygons but it isnt as elegant and has its limitations if you have a polyline that is shaped like the outline of a closed circle and its being offset instead of making the polygon the outline it will fill the outline and create a big shape and will just cut a hole into the other
Is there a reason why this should be core and not an add-on in the asset library?
Because the reverse is already implemented there already is an clip_polyline_with_polygon_2d function so just for the symetry
The text was updated successfully, but these errors were encountered: