Polygon cutting

Is it possible to cut the ground plane of my game? In Godot, I would create a polygon for this.
I want the user to be able to modify the polygon: when he clicks and drags from one side to the other side of the polygon, the smallest part should be cut off and entities on that part should fall down

Yes. You can implement “slice-to-cut” with a polygon boolean split + area selection:

Outline:

  • Represent the ground as a 2D polygon (list of vertices). Keep it simple and convex if possible; concave works with robust libs.
  • On drag, create a cutting line (segment AB). Compute its intersection with the polygon.
  • If the line intersects in two points, split the polygon into two polygons using a boolean operation (clip by a half-plane, twice).
  • Compute area of both resulting polygons; keep the larger one as the new ground; the smaller is “cut off”.
  • Any entities with their position inside the cut-off polygon lose support and fall.

Implementation tips:

  • Use a stable polygon clipping/boolean library (e.g., Clipper, CGAL, Earcut for triangulation + custom half-plane clip).
  • Steps:
    1. Find intersection points of AB with polygon edges.
    2. Classify vertices by side of the line (sign of cross((B−A),(V−A))).
    3. Build polygons on each side including intersection points in order.
    4. Calculate areas; choose largest as ground.
    5. Update collision mesh: retriangulate the kept polygon and rebuild the physics shape.
    6. Test entities: point-in-polygon on the cut-off; switch them to falling.

Edge cases:

  • Less than two intersections: no cut.
  • Colinear overlaps: snap/merge vertices; epsilon tolerance.
  • Very small slivers: discard if area < threshold to avoid physics jitter.

Performance:

  • Cache triangulation.
  • Quantize coordinates to avoid numeric noise.

3D variant:

  • Use a CSG plane cut on a mesh; for physics, rebuild the mesh collider. Entities above removed piece drop via gravity.