only add non-empty loops. add simple to top on legacy/support path. fix invalid healed report

This commit is contained in:
Stewart Allen 2021-09-16 10:39:04 -10:00
commit 69eb0356a9
4 changed files with 12 additions and 3 deletions

View file

@ -214,7 +214,7 @@
} }
// cannot start on split // cannot start on split
if (line.adjacentUnused().length > 2) { if (line.adjacentUnused().length > 2) {
console.log('cannot start on a split'); // console.log('cannot start on a split');
continue; continue;
} }
// line.used = true; // line.used = true;
@ -253,7 +253,9 @@
loop.push(line); loop.push(line);
line.used = true; line.used = true;
} }
loops.push(loop); if (loop.length) {
loops.push(loop);
}
} }
// attempt to connect open loops // attempt to connect open loops
@ -288,9 +290,13 @@
} }
} }
// console.log({loops})
// store invalid loops for display / culling
this.shorts = loops.filter(l => l && l.length <= 2);
// filter out null and short loops // filter out null and short loops
this.loops = loops = loops.filter(l => l && l.length > 2); this.loops = loops = loops.filter(l => l && l.length > 2);
// console.log({loops})
// rotate/flatten to Z plane and use earcut to generate faces // rotate/flatten to Z plane and use earcut to generate faces
// because earcut emits point indexes, no need to un-rotate // because earcut emits point indexes, no need to un-rotate

View file

@ -870,7 +870,7 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
setTimeout(() => { setTimeout(() => {
Promise.all(widgets.map(w => w.heal())).then(mod => { Promise.all(widgets.map(w => w.heal())).then(mod => {
API.hide.alert(marker); API.hide.alert(marker);
let healed = mod.map(m => m).length; let healed = mod.filter(m => m).length;
if (healed) { if (healed) {
API.show.alert(`${healed} Object${healed ? 's':''} healed`); API.show.alert(`${healed} Object${healed ? 's':''} healed`);
} else { } else {

View file

@ -184,6 +184,7 @@
// standard legacy polygon // standard legacy polygon
let top = new Top(poly); let top = new Top(poly);
this.tops.push(top); this.tops.push(top);
top.simple = poly;
return top; return top;
} else { } else {
// frop top object passed back by slicePost() // frop top object passed back by slicePost()

View file

@ -346,6 +346,8 @@ console.log/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
if (data.vertices) { if (data.vertices) {
this.loadVertices(data.vertices); this.loadVertices(data.vertices);
this.modified = true; this.modified = true;
} else {
this.modified = false;
} }
resolve(this.modified); resolve(this.modified);
}); });