Skip to content

Commit

Permalink
fix(geom-clip-line): off-by-one error in clipLinePoly()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Aug 15, 2021
1 parent eb6872b commit 7898810
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/geom-clip-line/src/clip-poly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ export const clipLinePoly = (
b: ReadonlyVec,
pts: ReadonlyVec[]
) => {
const isecs = intersectRayPolylineAll(a, direction([], a, b), pts, true)
.isec;
const isecs = intersectRayPolylineAll(
a,
direction([], a, b),
pts,
true
).isec;
if (!isecs) return;
const segments: Vec[][] = [];
for (let i = 0; i < isecs.length; i += 2) {
for (let i = 0, n = isecs.length - 1; i < n; i += 2) {
segments.push([<Vec>isecs[i], <Vec>isecs[i + 1]]);
}
return segments;
Expand Down

0 comments on commit 7898810

Please sign in to comment.