memononen / libtess2

Game and tools oriented refactored version of GLU tesselator.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assert failure tessellating planar triangle

kintel opened this issue · comments

Passing the following triangle to the tessellator causes an assert failure:

Assertion failed: (VertLeq( u, v ) && VertLeq( v, w )), function tesedgeSign, file ../Source/geom.c, line 83.
-70.4956,14.872283,14.6119
-70.4956,14.8722944,32.6832
-70.4956,14.872283,14.6119

The cause seems to be that the sentinels used for the edge dict touches the bounding box when any dimension of the bounding box is 0. The is again amplified by the worst-case normal being chosen for collinear input polygons. I'll send a patch for the latter issue shortly.

A special case of this issue is when a polygon is collinear in an axis-aligned fashion. In this case, my fix for the normal vector won't help:

0,0,0
0,0,1
0,0,2

PS, see https://github.com/openscad/libtess2/tree/test
I added a cmd-line test program which can be used to easily feed data to the tessellator. It outputs STL at the moment.

(in C++ as it was too annoying to port my existing code to C)