Skip to content

[fast-csg] Port minkowski to the hybrid fast-csg world#4113

Merged
t-paul merged 7 commits intoopenscad:masterfrom
ochafik:fast-csg-fix-minkowski
Feb 13, 2022
Merged

[fast-csg] Port minkowski to the hybrid fast-csg world#4113
t-paul merged 7 commits intoopenscad:masterfrom
ochafik:fast-csg-fix-minkowski

Conversation

@ochafik
Copy link
Contributor

@ochafik ochafik commented Feb 11, 2022

Saves ~40% render time off a simple example like this compared to the last snapshot (with --enable=fast-csg --enable=fast-csg-trust-corefinement), and 18x faster than without fast-csg:

$fn=50;

minkowski() {
    difference() {
        hull() {
            translate([3, 0, 0]) cube(0.5, center=true);
            cube(1, center=true);
        }
        translate([0, 0, 0])
            sphere(1);
    }
    sphere(1);
}
// Baseline: 10m55s
// Baseline w/ fast-csg & trust: 1m20s
// This PR w/ fast-csg & trust: 35s

Notes:

  • I've tried switching things from Polyhedron_3 to Surface_mesh but it's still slower for some reason. Might revisit.
  • Models using minkowski are likely to hit the over-triangulation of corefinement, which is a known issue that should be fixed by [fast-csg] Support for upcoming CGAL remeshing #4107 (maybe when CGAL 5.5 gets out).

Olivier Chafik added 6 commits February 11, 2022 19:49
Saves ~10-20% off a simple example like this:

$fn=50;

minkowski() {
    difference() {
        hull() {
            translate([3, 0, 0])
                cube(0.5, center=true);
            cube(1, center=true);
        }
        translate([0, 0, 0])
            sphere(1);
    }
    sphere(1);
}
Change of expressions:
  i->opposite()->vertex()->point() -> p.point(p.target(p.opposite(i)))
  i->vertex()->point(),            -> p.point(p.target(i))
  i->next()->vertex()->point());   -> p.point(p.target(p.next(i))))

  i->opposite()->next()->vertex()->point()) -> p.point(p.target(p.next(p.opposite(i)))

  f->facet_begin()        -> p.halfedge(f)
  he->opposite()->facet() -> p.face(p.opposite(he))
…on const)

In the hybrid minkowski rewrite, we'll save some copies thanks to this
@ochafik ochafik changed the title [fast-csg] Remove unnecessary nef conversions in minkowski [fast-csg] Port minkowski to the hybrid fast-csg world Feb 12, 2022
@ochafik ochafik marked this pull request as ready for review February 12, 2022 03:13
@t-paul t-paul merged commit 3753d6c into openscad:master Feb 13, 2022
ochafik pushed a commit to ochafik/openscad that referenced this pull request Mar 4, 2022
…erimental feature b/c it's slower!!

Benchmarked:

hyperfine -L remesh ",--enable=fast-csg-remesh,--enable=fast-csg-remesh-predictibly" "./buildRelease/OpenSCAD.app/Contents/MacOS/OpenSCAD mnk.scad --enable=fast-csg --enable=fast-csg-trust-corefinement -o out.stl {remesh}"

With mnk.scad coming from openscad#4113

Mean : 38s (Baseline), 25s (remesh), 32s (remesh-predictibly)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants