Blazingly fast rendering using Polygon Mesh Processing when possible#3641
Closed
ochafik wants to merge 151 commits intoopenscad:masterfrom
Closed
Blazingly fast rendering using Polygon Mesh Processing when possible#3641ochafik wants to merge 151 commits intoopenscad:masterfrom
ochafik wants to merge 151 commits intoopenscad:masterfrom
Conversation
added 4 commits
February 2, 2021 22:45
…ing CGAL packages (*massive* speedup) Uses blazing fast PMP csg operations, with in-place updates as much as possible. Detects non-manifold meshes not handled by PMP and reverts back to Nefs (to avoid costly checks, convex polysets are trusted, but also introduced --enable=trust-manifold to allow speedups on large STL imports, for instance). Also includes "fast-union" trick introduced in openscad#3636 (concatenate disjoint bodies) Speed improvements in the 10x to 100x range for my various grid patterns. More improvements to come when Polyhedron will become a Geometry subclass (should be able to cache a read-only version of them), and chain CSG operations instead of converting to PolySet as currently done.
Member
|
Linking to original issue #2360 for reference. |
added 24 commits
February 3, 2021 00:32
… earlier versions) Most of the functionality still seems possible in 4.x (e.g. is_non_manifold_vertex available from 4.14), but that's too many hoops to go through for this initial version.
-DPERFORMANCE_TIMINGS
…ate_non_manifold_vertices instead of quadratic calls to PMP::is_non_manifold_vertex
Difference sped up by union their subtracted terms. Exact mode converts to Nefs instead of PolySet. It's transitional as the new poly class will soon become a Geometry, so conversion will only happen at the top of the visitation
Also, handle CGALPolyhedron in createNefPolyhedronFromGeometry
Also, a few helpers:
- ResultObject.asMutableGeometry
- Geometry.{transform, resize}
Note that GeometryEvaluator force-converts to PolySet at the root level for now, for higher compatibility w/ exports
This was referenced Oct 28, 2021
added 8 commits
February 2, 2022 19:51
…grid params + reduce whitespace noise
This was referenced Feb 3, 2022
Draft
Contributor
Author
|
This is now mostly all in from other PRs, time to close this one! (see high-level summary in this blog post) |
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Experimental
fast-csgfeature for 10x faster rendering (or more... or less :-D) of lots of challenging models (see some benchmarks here)!This PR introduces the class
CGALHybridPolyhedron, a lazy hybridization ofCGAL::Polyhedron_3/ CGAL::Surface_mesh (using corefinement functions for CSG ops) and CGAL::Nef_polyhedron_3 (as a fallback for cases not supported by corefinement functions).As mentioned by @thehans, CGAL's Polygon Mesh Processing libraries (PMP) provide much faster CSG operations (union, intersection, difference) than the Nef polyhedron. Unfortunately, they also have strict input requirements: any shared
verticesedges between two unioned polyhedra or mis-oriented faces and they just bail out.This PR has being chunked and sent as separate PRs, now available in nightly builds. This blog post summarizes the process and some next steps:
fast-csg-exact-callbacksfeature to fix dramatically pathological cases like this one; includesfast-csg-debug-corefinementfeature to dump operands of failing operations to.offfiles to help create self-contained bugs for CGALfast-csg-trust-corefinementfeature to disable costly checks before calling corefinement methods (let them fail politely or not)Upgrade CGAL from 4.11 to 5.2 mxe#4 will make CGAL 5.2 available in the OpenSCAD's mxe environment: I'll then clean up the code that switches mxe build setups to using my branch.Known / open issues:
Some notes:
Currently requires CGAL 5.1+ (because Polyhedron_3 + corefinement doesn't work well together before) but compiles fine with older versions (thefast-csgfeature is then compiled away). A new github CI workflow builds and tests with various versions of CGAL (fast-csg-specific tests are disabled when its' not available). Now that there's a Surface_mesh codepath, might be able to lower the CGAL version requirement: stay tuned!CGAL::exactas suggested by @sloriot in this thread. In general, calling that after transforms, corefinement operations and upon conversion from nef to polyhedron/surface mesh, but in the case of surface meshes I'm calling exact during corefinement after a face is done being split up (which creates new numbers) rather than after. This makes some rare models faster.CGAL::Epeckkernel (which seems, with its inaccurateEpicksibling, to be the only kernels that work well with PMP's corefinement functions until after 5.2.0)cgalutils-*so this builds fine in all environments with older GCC or limitations of RAMFuture work:
cube(1); translate([0.5, 0, 0]) cube(1);goes from 6 (12 triangles) to 44 (before, after)tests/CMakeLists.txt), and generally address bug reports from usersHave a version of minkowski with the new kernel (the "native" nef minkowski is already wired, but not the custom alternative from CGALUtils, which currently incurs unnecessary conversions)CGAL::Polyhedron_3to only useCGAL::Surface_mesh. It's definitely faster!CGAL_Nef_polyhedronand use a single kernel to rule them all