earcut icon indicating copy to clipboard operation
earcut copied to clipboard

Multipolygon speed-up

Open Sumbera opened this issue 8 years ago • 1 comments

While earcut is great for single polygon calculations, for multipolygon cases it could provide advanced API for more efficient working with Arrays:

  1. provide input params to work on data range for input data so earcut can work on single big user-pre-allocated array taking its slices (dStar, dEnd)
  2. provide input params to work on user pre-allocated triangles array as well, saving the results on specified offset and with correct index pointing to the data array being worked from dStart and dEnd.
  3. return new offset from writing new indices into the triangles.

all above is enabling to efficiently earcut hundreds of thousands polygons and passing the resulting arrays directly into the WebGL buffers.

I did that as experiment and saved hundreds of ms in total (for all polygons processing). Branch of this approach available here : https://github.com/Sumbera/earcut/tree/multipolygon

Sumbera avatar Jul 31 '16 11:07 Sumbera

Another vote for this

napter avatar Apr 18 '19 02:04 napter