Bisecting PolygonShape3D with Geometry.clip_polygon not returning what I expect.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By benis

I’ve made a prism-shaped ConvexPolygonshape3D with points at [(0, 0.5, 0.5), (0.5, -0.5, 0.5), (0, 0.5, -0.5), (-0.5, -0.5, 0.5), (0.5, -0.5, -0.5), (-0.5, -0.5, -0.5)], so with triangular faces aligned with the z-axis at 0.5z and -0.5z on either side. 1

I set up a plane along xy, [N: (0, 0, 1), D: 0]. When I call Geometry.clip_polygon(points, plane), what I’d expect based on the description is that it would bisect the shape along the xy plane and return vertices [(0, 0.5, 0), (0.5, -0.5, 0), (0, 0.5, -0.5), (-0.5, -0.5, 0), (0.5, -0.5, -0.5), (-0.5, -0.5, -0.5)].

But what it actually returns is [(-0.25, -0, -0), (0.25, 0, -0), (0, 0.5, -0.5), (-0.25, 0, -0), (0, -0.5, -0), (0.5, -0.5, -0.5), (-0.5, -0.5, -0.5)], so where the plane is cutting the new shape has been shrunk rather than neatly bisected preserving the edges.

I’m not sure if this is what it’s supposed to be doing or if I’ve misunderstood what it’s supposed to do or misapplied it somehow. If Geometry.clip_polygon isn’t the way to bisect some geometry along a plane without, then is there a method that can do that without distorting it?