I'm trying to get the contact points between a RectangleShape2D and a SegmentShape2D. I'm using the collideandget_contacts function. The problem is that sometimes the result is not as expected.
In the attached gif you can see that when the segment is completely inside the rectangle one of the points does not mark the end of the segment but the intersection between the segment's extension and the rectangle.
Something similar happens when the segment is larger than the rectangle and the points of contact are two.
Is it an engine error or should I follow another way (maybe clipping techniques) to get what I want? In that case, how could I solve it?
Thanks in advance