Artifact bugfix

This commit is contained in:
be5invis 2023-03-20 03:07:16 -07:00
parent 68ba19ff68
commit 4a3728ebe3
2 changed files with 8 additions and 10 deletions

View file

@ -3,7 +3,7 @@ import zlib from "zlib";
import { encode, decode } from "@msgpack/msgpack"; import { encode, decode } from "@msgpack/msgpack";
const Edition = 25; const Edition = 26;
const MAX_AGE = 16; const MAX_AGE = 16;
class GfEntry { class GfEntry {
constructor(age, value) { constructor(age, value) {

View file

@ -146,6 +146,7 @@ class QuadifySink {
let c = this.lastContour; let c = this.lastContour;
c = this.alignHVKnots(c); c = this.alignHVKnots(c);
c = this.dropDuplicateFirstLast(c); c = this.dropDuplicateFirstLast(c);
c = this.cleanupOccurrentKnots1(c);
c = this.cleanupOccurrentKnots2(c); c = this.cleanupOccurrentKnots2(c);
c = this.cleanupOccurrentKnots1(c); c = this.cleanupOccurrentKnots1(c);
c = this.removeColinearArc(c); c = this.removeColinearArc(c);
@ -271,11 +272,9 @@ class QuadifySink {
removeColinearCorners(c0) { removeColinearCorners(c0) {
const c = c0.slice(0); const c = c0.slice(0);
let lengthBefore = c.length, let found = false;
lengthAfter = c.length;
do { do {
lengthBefore = c.length; found = false;
const shouldRemove = [];
for (let i = 0; i < c.length; i++) { for (let i = 0; i < c.length; i++) {
const zPrev = c[(i - 1 + c.length) % c.length], const zPrev = c[(i - 1 + c.length) % c.length],
zCurr = c[i], zCurr = c[i],
@ -285,13 +284,12 @@ class QuadifySink {
zNext.type === Point.Type.Corner && zNext.type === Point.Type.Corner &&
pointsColinear(zPrev, zCurr, zNext) pointsColinear(zPrev, zCurr, zNext)
) { ) {
shouldRemove[i] = true; found = true;
c.splice(i, 1);
break;
} }
} }
} while (found);
dropBy(c, shouldRemove);
lengthAfter = c.length;
} while (lengthAfter < lengthBefore);
return c; return c;
} }