Skip to content
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

Avoid excessive reallocations in PolySet #4642

Merged
merged 5 commits into from
May 28, 2023

Conversation

ochafik
Copy link
Contributor

@ochafik ochafik commented May 19, 2023

PolySet is a vector of polygons (vectors), so we can avoid a myriad of tiny (or big) reallocs by:

  • Reserving the vector of polygons when it's easy (e.g. in binary STL import, primitives...)
  • Requiring a polygon size arg in PolySet::append_poly to reserve the polygon's vector

sphere(10, $fn=1000); renders 1.18x faster with this!

And this one that does some actual CSG ops, still 1.13x faster (--enable=manifold --export-format=binstl):

sphere($fn=1000);
translate([0.5, 0, 0])
  sphere($fn=1000);

Can give up to 10% speed up of rendering of models like this:

$fn=1000;

sphere();
translate([0.5, 0, 0])
  sphere();
@ochafik ochafik changed the title Avoid excessive reallocations in PolySet append_poly Avoid excessive reallocations in PolySet append_poly + append_vertex flow May 19, 2023
src/geometry/PolySet.cc Outdated Show resolved Hide resolved
@ochafik ochafik changed the title Avoid excessive reallocations in PolySet append_poly + append_vertex flow Avoid excessive reallocations in PolySet May 25, 2023
@kintel
Copy link
Member

kintel commented May 27, 2023

To merge once CI goes green

@kintel kintel merged commit a3ef277 into openscad:master May 28, 2023
5 checks passed
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.

None yet

3 participants