mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-08-28 22:08:54 -04:00
Avoid checking curves if completely out of control bounds.
This leads to a huge speed increase! Relates to #765
This commit is contained in:
parent
1c1e19614e
commit
dae8bb630b
1 changed files with 14 additions and 1 deletions
|
@ -1695,7 +1695,20 @@ new function() { // Scope for intersection using bezier fat-line clipping
|
|||
// #getIntersections() calls as it is required to create the resulting
|
||||
// CurveLocation objects.
|
||||
_getIntersections: function(v1, v2, curve1, curve2, locations, param) {
|
||||
if (!param.startConnected && !param.endConnected
|
||||
var min = Math.min,
|
||||
max = Math.max;
|
||||
// Avoid checking curves if completely out of control bounds.
|
||||
// Also detect and handle overlaps.
|
||||
if (!(
|
||||
max(v1[0], v1[2], v1[4], v1[6]) >=
|
||||
min(v2[0], v2[2], v2[4], v2[6]) &&
|
||||
max(v1[1], v1[3], v1[5], v1[7]) >=
|
||||
min(v2[1], v2[3], v2[5], v2[7]) &&
|
||||
min(v1[0], v1[2], v1[4], v1[6]) <=
|
||||
max(v2[0], v2[2], v2[4], v2[6]) &&
|
||||
min(v1[1], v1[3], v1[5], v1[7]) <=
|
||||
max(v2[1], v2[3], v2[5], v2[7])
|
||||
) || !param.startConnected && !param.endConnected
|
||||
&& addOverlap(v1, v2, curve1, curve2, locations, param))
|
||||
return locations;
|
||||
var straight1 = Curve.isStraight(v1),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue