fix gpu contour Y with inside only

This commit is contained in:
Stewart Allen 2025-12-22 10:07:10 -05:00
commit a4af3a9166
2 changed files with 19 additions and 4 deletions

View file

@ -126,6 +126,18 @@ class Point {
return this; return this;
} }
/**
* Swap X and Y coordinates in place
* @returns {Point} This point (for chaining)
*/
swapXY() {
let p = this,
t = p.x;
p.x = p.y;
p.y = t;
return this;
}
/** /**
* Swap X and Z coordinates in place * Swap X and Z coordinates in place
* @returns {Point} This point (for chaining) * @returns {Point} This point (for chaining)

View file

@ -182,10 +182,7 @@ export class Topo {
for (let i=0; i<numScanlines; i++) { for (let i=0; i<numScanlines; i++) {
let lineStart = i * pointsPerLine; let lineStart = i * pointsPerLine;
let lineData = pathData.slice(lineStart, lineStart + pointsPerLine); let lineData = pathData.slice(lineStart, lineStart + pointsPerLine);
let points = contourY let points = Array.from(lineData).map((v,j) => calcPoint(j * xmult + xoff, i * ymult + yoff, v, j * xStep, i * yStep));
? Array.from(lineData).map((v,j) => calcPoint(i * ymult + yoff, j * xmult + xoff, v, i * xStep, j * yStep))
: Array.from(lineData).map((v,j) => calcPoint(j * xmult + xoff, i * ymult + yoff, v, j * xStep, i * yStep))
;
let slice = newSlice(i); let slice = newSlice(i);
let poly = newPolygon().setOpen(); let poly = newPolygon().setOpen();
let lines = [ ]; let lines = [ ];
@ -228,6 +225,12 @@ export class Topo {
if (poly.length > 1) { if (poly.length > 1) {
lines.push(poly); lines.push(poly);
} }
if (contourY) {
for (let poly of lines)
for (let p of poly.points) {
p.swapXY();
}
}
// raise output points when inside tab boundaries // raise output points when inside tab boundaries
if (!inside && tabsOn && clipTab.length) if (!inside && tabsOn && clipTab.length)
for (let poly of lines) { for (let poly of lines) {