fix multi object drag bounding

This commit is contained in:
Stewart Allen 2020-05-01 10:29:50 -04:00
commit d270de3a92
3 changed files with 14 additions and 14 deletions

View file

@ -1697,22 +1697,17 @@ var gs_kiri_init = exports;
// });
SPACE.mouse.onDrag(function(delta) {
let dev = settings().device;
let bmaxx = dev.bedWidth/2;
let bminx = -bmaxx;
let bmaxy = dev.bedDepth/2;
let bminy = -bmaxy
if (delta && UI.freeLayout.checked) {
let set = settings();
let dev = set.device;
let bound = set.bounds;
let width = dev.bedWidth/2;
let depth = dev.bedDepth/2;
if (bound.min.x + delta.x <= -width) return;
if (bound.min.y + delta.y <= -depth) return;
if (bound.max.x + delta.x >= width) return;
if (bound.max.y + delta.y >= depth) return;
API.selection.for_widgets(function(widget) {
let wbnd = widget.getBoundingBox();
let wwid = wbnd.max.x - wbnd.min.x;
let wminx = widget.track.pos.x + delta.x - wwid / 2;
let wmaxx = wminx + wwid + delta.x;
if (wminx < bminx || wmaxx > bmaxx) return;
let whei = wbnd.max.y - wbnd.min.y;
let wminy = widget.track.pos.y + delta.y - whei / 2;
let wmaxy = wminy + whei + delta.y;
if (wminy < bminy || wmaxy > bmaxy) return;
widget.move(delta.x, delta.y, 0);
API.event.emit('widget.move', {widget, delta});
});

View file

@ -964,6 +964,10 @@ self.kiri.copyright = exports.COPYRIGHT;
forAllWidgets(function(widget) {
let wp = widget.track.pos;
let wb = widget.mesh.getBoundingBox().clone();
wb.min.x += wp.x;
wb.max.x += wp.x;
wb.min.y += wp.y;
wb.max.y += wp.y;
bounds.union(wb);
});
return settings.bounds = bounds;

View file

@ -11,6 +11,7 @@
* `P` server-side processing (determine protocol and storage)
* `P` refactor / simplify POLY.expand (put onus on collector)
* `P` duplicate objects should share same slice data unless rotated or scaled
* `F` https://poeditor.com/projects/view_terms?id=336467&per_page=20
# FDM