How to react on warning message?

Try rendering the polygon as a line and see if it looks right. I think the coordinates of the third point are wrong.

Does the newPolygon return an object or nil? If nil then there is nothing to remove. I suspect it is that function call which fails, not the addBody call.

horacebury, this does not help, try yourself.

I was finally able to try it myself. I’ve been responding on my phone.

There is no value or event returned in code that I can find to indicate that the polygon is self-intersecting. This is a shame because it’s a very powerful function to have. There are, however, plenty of sites out there which provide code for detecting self-intersecting polygon definitions. Eg:

http://geomalgorithms.com/a09-_intersect-3.html

FYI, I have created a feature request for information on self-intersecting polygon data:

http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/5203229-self-intersecting-polygon-warning

horacebury, thanks!

Get done differently. I used physics.rayCast () to check the intersection. At the time when you draw a new side of the landfill, the beam scans the intersection with other lines.

You can actually calculate line intersections quite easily yourself. I’ve written a routine in my mathlib library to do it:

http://developer.coronalabs.com/code/line-intersection

You’ll need this to run with it:

https://developer.anscamobile.com/code/maths-library

To understand that the polygon is not created, you can check  object.contentHeight , If = 0 then the polygon intersects.

To understand that the polygon is not created, you can check  object.contentHeight , If = 0 then the polygon intersects.