fixup for origin point finder for high res meshes

This commit is contained in:
Stewart Allen 2025-09-22 12:09:49 -04:00
commit 3a4aa465da

View file

@ -25,6 +25,16 @@ export function originSelect() {
env.hover = pointHover; env.hover = pointHover;
env.hoverUp = pointHoverUp; env.hoverUp = pointHoverUp;
// less precise point key for hi-res meshes that leads to dups
function updateKey(pt) {
pt._key = [
((pt.x * 1000) | 0),
((pt.y * 1000) | 0),
((pt.z * 1000) | 0)
].join(' ');
return pt;
}
CAM.traces((ids) => { CAM.traces((ids) => {
api.hide.alert(alert); api.hide.alert(alert);
alert = api.show.alert("select origin<br>[esc] to cancel", 1000); alert = api.show.alert("select origin<br>[esc] to cancel", 1000);
@ -53,14 +63,14 @@ export function originSelect() {
}); });
for (let poly of polys) { for (let poly of polys) {
if (poly.circularity() >= 0.99) { if (poly.circularity() >= 0.99) {
let center = poly.calcCircleCenter(); let center = updateKey(poly.calcCircleCenter());
if (points[center.key]) { if (points[center.key]) {
continue; continue;
} }
addpoint(widget, center); addpoint(widget, center);
} else if (poly.isOpen()) { } else if (poly.isOpen()) {
incpoint(widget, poly.first()); incpoint(widget, updateKey(poly.first()));
incpoint(widget, poly.last()); incpoint(widget, updateKey(poly.last()));
} }
} }
}); });