mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-03-14 00:39:57 -04:00
parent
a5a13f541a
commit
f66c73e534
2 changed files with 21 additions and 2 deletions
|
@ -1822,9 +1822,10 @@ new function() { // Scope for bezier intersection using fat-line clipping
|
|||
} else {
|
||||
// Apply the result of the clipping to curve 1:
|
||||
v1 = Curve.getPart(v1, tMinClip, tMaxClip);
|
||||
var uDiff = uMax - uMin;
|
||||
if (tMaxClip - tMinClip > 0.8) {
|
||||
// Subdivide the curve which has converged the least.
|
||||
if (tMaxNew - tMinNew > uMax - uMin) {
|
||||
if (tMaxNew - tMinNew > uDiff) {
|
||||
var parts = Curve.subdivide(v1, 0.5),
|
||||
t = (tMinNew + tMaxNew) / 2;
|
||||
calls = addCurveIntersections(
|
||||
|
@ -1844,7 +1845,10 @@ new function() { // Scope for bezier intersection using fat-line clipping
|
|||
recursion, calls, u, uMax, tMinNew, tMaxNew);
|
||||
}
|
||||
} else { // Iterate
|
||||
if (uMax - uMin >= fatLineEpsilon) {
|
||||
// For some unclear reason we need to check against uDiff === 0
|
||||
// here, to prevent a regression from happening, see #1638.
|
||||
// Maybe @iconexperience could shed some light on this.
|
||||
if (uDiff === 0 || uDiff >= fatLineEpsilon) {
|
||||
calls = addCurveIntersections(
|
||||
v2, v1, c2, c1, locations, include, !flip,
|
||||
recursion, calls, uMin, uMax, tMinNew, tMaxNew);
|
||||
|
|
|
@ -343,3 +343,18 @@ test('#1284', function() {
|
|||
var path2 = createPath(curve2);
|
||||
testIntersections(path1.getIntersections(path2), expected);
|
||||
});
|
||||
|
||||
test('#1638', function() {
|
||||
var circle1 = new Path.Circle({
|
||||
center: [100, 100],
|
||||
radius: 100
|
||||
});
|
||||
var circle2 = new Path.Circle({
|
||||
center: [150, 150],
|
||||
radius: 100
|
||||
});
|
||||
testIntersections(circle1.getIntersections(circle2), [
|
||||
{ point: { x: 191.16238, y: 58.83762 }, index: 1, time: 0.73431, crossing: true },
|
||||
{ point: { x: 58.83762, y: 191.16238 }, index: 3, time: 0.26569, crossing: true }
|
||||
]);
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue