From dbc19c45db0d707b84659e83d102e38a3cf1f661 Mon Sep 17 00:00:00 2001 From: knives214 Date: Wed, 29 Nov 2017 17:00:14 +0100 Subject: [PATCH 1/2] fix performance issue with 16k+ sites --- rhill-voronoi-core.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rhill-voronoi-core.js b/rhill-voronoi-core.js index 779b9d5..9389913 100644 --- a/rhill-voronoi-core.js +++ b/rhill-voronoi-core.js @@ -1352,7 +1352,7 @@ Voronoi.prototype.clipEdge = function(edge, bbox) { if (r>t1) {return false;} if (r>t0) {t0=r;} } - // bottom + // bottom q = bbox.yb-ay; if (dy===0 && q<0) {return false;} r = q/dy; @@ -1397,7 +1397,8 @@ Voronoi.prototype.clipEdge = function(edge, bbox) { Voronoi.prototype.clipEdges = function(bbox) { // connect all dangling edges to bounding box // or get rid of them if it can't be done - var edges = this.edges, + var newEdges = [], + edges = this.edges, iEdge = edges.length, edge, abs_fn = Math.abs; @@ -1413,8 +1414,11 @@ Voronoi.prototype.clipEdges = function(bbox) { (abs_fn(edge.va.x-edge.vb.x)<1e-9 && abs_fn(edge.va.y-edge.vb.y)<1e-9)) { edge.va = edge.vb = null; edges.splice(iEdge,1); + } else { + newEdges.unshift(edge); } - } + } + this.edges = newEdges; }; // Close the cells. From fbfbb2bdab7643bf3fa4971114d4a9220f46ccaa Mon Sep 17 00:00:00 2001 From: vash1486 Date: Wed, 29 Nov 2017 17:18:02 +0100 Subject: [PATCH 2/2] - fix mistype --- rhill-voronoi-core.js | 1 - 1 file changed, 1 deletion(-) diff --git a/rhill-voronoi-core.js b/rhill-voronoi-core.js index 9389913..9d1f56b 100644 --- a/rhill-voronoi-core.js +++ b/rhill-voronoi-core.js @@ -1413,7 +1413,6 @@ Voronoi.prototype.clipEdges = function(bbox) { !this.clipEdge(edge, bbox) || (abs_fn(edge.va.x-edge.vb.x)<1e-9 && abs_fn(edge.va.y-edge.vb.y)<1e-9)) { edge.va = edge.vb = null; - edges.splice(iEdge,1); } else { newEdges.unshift(edge); }