I am building a drag and drop editing system. The objects that I'm moving are Area2D with CollisionPolygon2D nodes. The polygons are very simple and every point's position consists of whole numbers. Also when I move the objects, I use ceil on their x and y positions to align everything with a 1x1 grid.
I don't want these objects intersect, so I check if getoverlappingareas() returns anything before dropping. But, I do want the objects to touch on the edges. My problem is that getoverlappingareas() returns ares that don't overlap but do touch.
How can I get around this?
I have since solved the problem like this:
When placing a shape, I check to see if there are any overlapping areas.
If there are, I take the returned polygons and use intersectpolygons2d to generate the intersecting areas.
Then I check to see if the combined area of these intersecting areas is zero.
This kills two birds with one stone. I now know if the shapes are overlapping or just touching.