MOI mesh export issue

 From:  Michael Gibson
11521.42 In reply to 11521.41 
Hi PaQ, there isn't a limit on number of points but it does a test that the centroid triangulation won't make a mess.

That happens in UV space and it's pretty simple. For every edge of the n-gon, make a triangle out of the centroid point and the edge points and calculate the signed area of the triangle. If the area is negative it means that triangle is reversed in orientation so don't do a centroid triangulation on that n-gon.

Signed area of a 2D triangle goes like this:

With 2D points K, L, M

XLK =   L.x - K.x;
XMK = M.x - K.x;
YLK =   L.y - K.y;
YMK = M.y - K.y;

signed_area = 0.5 * (XLK*YMK - XMK*YLK);

The sign will be negative if the triangle vertices are in clockwise order, positive if counter-clockwise.

ref:
A programmer's geometry pg. 62
Adrian Bowyer, John Woodwark
Page 62, chapter 4.1 "Area of a triangle"

You can leave out the * 0.5 in this case since it doesn't actually need the area, it just needs to know if it's positive or negative.

- Michael