auto-adjust camZBottom when flipping only one widget

This commit is contained in:
Stewart Allen 2020-12-28 14:27:38 -05:00
commit 16c43b94b1
2 changed files with 9 additions and 3 deletions

View file

@ -359,6 +359,7 @@
}); });
func.opFlip = () => { func.opFlip = () => {
let widgets = API.widgets.all();
let { process } = current; let { process } = current;
let { ops, op2 } = process; let { ops, op2 } = process;
// add flip singleton to b-side // add flip singleton to b-side
@ -371,7 +372,7 @@
middle: "middle" middle: "middle"
}[process.camZAnchor]; }[process.camZAnchor];
// flip tabs // flip tabs
API.widgets.all().forEach(widget => { for (let widget of widgets) {
let anno = API.widgets.annotate(widget.id).tab || []; let anno = API.widgets.annotate(widget.id).tab || [];
let wbm = widget.bounds.max.z; let wbm = widget.bounds.max.z;
for (let tab of anno) { for (let tab of anno) {
@ -398,7 +399,7 @@
} }
clearTabs(widget, true); clearTabs(widget, true);
restoreTabs([widget]); restoreTabs([widget]);
}); }
// flip widget // flip widget
if (axis === 'X') { if (axis === 'X') {
API.selection.rotate(Math.PI, 0, 0); API.selection.rotate(Math.PI, 0, 0);
@ -409,6 +410,11 @@
flipping = false; flipping = false;
process.ops = op2; process.ops = op2;
process.op2 = ops; process.op2 = ops;
// special case, auto-adjust camZBottom
if (process.camZBottom && widgets.length === 1) {
process.camZBottom = widgets[0].bounds.max.z - process.camZBottom;
API.util.rec2ui(process);
}
for (let op of op2) { for (let op of op2) {
if (op.type === 'flip') { if (op.type === 'flip') {
op.axis = poppedRec.axis; op.axis = poppedRec.axis;

View file

@ -262,7 +262,7 @@
function cutTabs(tabs, offset, z) { function cutTabs(tabs, offset, z) {
let noff = []; let noff = [];
tabs = tabs.filter(tab => z < tab.pos.z + tab.dim.z/2).map(tab => tab.off).flat(); tabs = tabs.filter(tab => z < tab.pos.z + tab.dim.z/2).map(tab => tab.off).flat();
offset.forEach(op => noff.appendAll( op.cut(POLY.union(tabs)) )); offset.forEach(op => noff.appendAll( op.cut(POLY.union(tabs, 0, true)) ));
if (noff.length > 1) { if (noff.length > 1) {
let heal = 0; let heal = 0;
// heal/rejoin open segments that share endpoints // heal/rejoin open segments that share endpoints