optimize path when runnung preview without slicing first

This commit is contained in:
Stewart Allen 2021-01-11 13:41:42 -05:00
commit d51f469b0b

View file

@ -804,7 +804,7 @@
} }
} }
function prepareSlices(callback) { function prepareSlices(callback, scale = 1, offset = 0) {
if (viewMode == VIEWS.ARRANGE) { if (viewMode == VIEWS.ARRANGE) {
let snap = SPACE.screenshot(); let snap = SPACE.screenshot();
API.view.snapshot = snap.substring(snap.indexOf(",")+1); API.view.snapshot = snap.substring(snap.indexOf(",")+1);
@ -872,7 +872,9 @@
if (--countdown === 0 || error || errored) { if (--countdown === 0 || error || errored) {
// mark slicing complete for prep/preview // mark slicing complete for prep/preview
complete.slice = true; complete.slice = true;
if (scale === 1) {
API.show.progress(0); API.show.progress(0);
}
SPACE.scene.active(); SPACE.scene.active();
API.event.emit('slice.end', getMode()); API.event.emit('slice.end', getMode());
// print stats // print stats
@ -905,20 +907,22 @@
forAllWidgets(function(w) { forAllWidgets(function(w) {
totalProgress += (track[w.id] || 0); totalProgress += (track[w.id] || 0);
}); });
API.show.progress((totalProgress / WIDGETS.length), msg); API.show.progress(offset + (totalProgress / WIDGETS.length) * scale, msg);
}); });
}); });
} }
function preparePreview(callback) { function preparePreview(callback, scale = 1, offset = 0) {
if (complete.preview) { if (complete.preview) {
if (callback) callback(); if (callback) callback();
return; return;
} }
if (!complete.slice) { if (!complete.slice) {
settings.render = false;
prepareSlices(() => { prepareSlices(() => {
preparePreview(callback); settings.render = true;
}); preparePreview(callback, 0.25, 0.75);
}, 0.75);
return; return;
} }
@ -960,7 +964,7 @@
lastMsg = message; lastMsg = message;
startTime = mark; startTime = mark;
} }
API.show.progress(progress, message); API.show.progress(offset + progress * scale, message);
}, function (oldout, maxSpeed) { }, function (oldout, maxSpeed) {
if (lastMsg) { if (lastMsg) {
segtimes[`${segNumber++}_${lastMsg}`] = Date.now() - startTime; segtimes[`${segNumber++}_${lastMsg}`] = Date.now() - startTime;