Open patrickmeehan opened 10 years ago
There's no plans for that at this point. Some asserts are there to capture a crash (i.e. mesh topology checks), some are more a validation (i.e. the assert in normalize).
The lib uses longjmp as a way to fail, so I think most asserts-as-errors could be implemented as: if (fail) { tess->errorCode = x; longjmp(tess->env,1); } Which asserts you are getting currently?
Had thought about hooking assert that way, but not sure if libtess will be left in a state where we can clean it up and continue. We're working on an SVG viewer. Desired behavior is to ignore malformed geometry (zero area rectangles, etc.). If I hook it, can I just free the buffers and continue on to the next shape?
Thanks!!
Sorry for the slow reply, I was on vacation. Looking at the code it looks like the tess->mesh is not properly cleaned up when the longjump is used. This should fix it:
if (setjmp(tess->env) != 0) {
/* come back here if out of memory */
if (tess->mesh != NULL) {
tessMeshDeleteMesh( &tess->alloc, tess->mesh );
tess->mesh = NULL;
}
return 0;
}
With that change it /should/ be safe to use longjmp instead of assert.
No worries, Mikko. Will give that a shot.
Just out of curiosity, do you have any bandwidth for funded work-for-hire on libtess2? Email me if so. My email is just my first name at ziplinegames dot com.
Let me know if you run into any problems.
My free time is quite random, so I don't dare to make any commitments and I have to say no :)
I know how that goes! Let me know if you change your mind. I am working on a client project and they do have a budget. So far they've been happy to fund open source. If you wind up having a few evenings free, email me and I'll let you know what they can pay.
Hi, Mikko! Thanks for the awesome library!
We'd like to see libtess2 fail gracefully on malformed geometry, etc. instead of assert. Ideally we'd get back an error code indicating what happened.
Any plans for a modification like this?