When triangulating a quad, the calculation is (4-1) / 2 = 3 / 2 = 1, i.e. it should only yield one triangle instead of two. I haven't tested this out, just looked at the code, so please correct me if this is a brainfart and the code works as intended. Basically this should be just a saturating_sub(2), without the division, shouldn't it?
3 vertices -> 1 triangle
4 vertices -> 2 triangles
5 vertices -> 3 triangles
...
Also the indices seem wrong, for example for a quad you want the series 0, 1, 2, 0, 2, 3, right? Your code would produce 0, 1, 2, 3, 4 which is already out of bounds.
I just had a quick look at this and found (besides some features I still miss) this bug:
In
Polygon::triangles
there is this:When triangulating a quad, the calculation is (4-1) / 2 = 3 / 2 = 1, i.e. it should only yield one triangle instead of two. I haven't tested this out, just looked at the code, so please correct me if this is a brainfart and the code works as intended. Basically this should be just a
saturating_sub(2)
, without the division, shouldn't it?Also the indices seem wrong, for example for a quad you want the series 0, 1, 2, 0, 2, 3, right? Your code would produce 0, 1, 2, 3, 4 which is already out of bounds.