-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using earcut instead of libtess #7492
base: dev-2.0
Are you sure you want to change the base?
Conversation
https://editor.p5js.org/aman12345/sketches/Qp1A_qgnj hey @davepagurek, I can confirm that the number of extra faces is lower than what we experienced with the libtess algorithm; the earcut algorithm has noticeably improved the outcome. So, should implementing Also, If you try to run the sketch, you can see the log values of the deviation. Deviation basically returns the relative difference between the total area of triangles and the area of the input polygon. 0 means the triangulation is fully correct.. The deviation is still not zero and it's very very close to 0, and I believe that even if it were, there might still be some extra faces. |
So it looks like this won't fully fix #7474, so it could be worth pausing this to explore the other potential ways to fix this I mentioned in #7474 (comment), since fixing the buggy behaviour is probably higher priority than changing the algorithm, but I think this effort is worth picking up after that for its other potential benefits of using a more maintained codebase and potential performance improvements (I tested it out a bit here https://editor.p5js.org/davepagurek/sketches/gmd_WPXX9 in the past and saw a ~5fps improvement on this test case? We can double check that the same applies here.) With the checks for clockwise/counterclockwise/containment, do you still see the performance of earcut being better than libtess if you were to run the algorithm every frame? e.g. drawing text from contours directly in |
So sorry for the delay, now earcut works for 3d-cases as well. I am using Newell's method for normal computation.
I tried using code similar to the one in the sketch, but the handling of holes and outer counters wasn’t correct. To fix these issues, I had to add extra checks, which made the code a bit bulky. Additionally, I didn’t notice a 5fps increase on my system with the sketch (https://editor.p5js.org/davepagurek/sketches/gmd_WPXX9). Instead, both versions only showed about a 2fps improvement—not a significant difference. I was using the same sketch you mentioned (https://editor.p5js.org/davepagurek/sketches/gmd_WPXX9). Even though this doesn’t resolve issue #7474, we can still use earcut for better performance and to reduce the number of extra faces that extend beyond our models. |
Solves issue : #7474