Fix bed filling with more existing instances than needed

This commit is contained in:
tamasmeszaros 2020-11-26 13:58:21 +01:00
parent 7f22ce63f6
commit dfbf4cbab2
7 changed files with 49 additions and 16 deletions

View file

@ -90,17 +90,20 @@ void FillBedJob::process()
params.min_obj_distance = scaled(settings.distance);
params.allow_rotations = settings.enable_rotation;
unsigned curr_bed = 0;
params.stopcondition = [this, &curr_bed]() {
return was_canceled() || curr_bed > 0;
bool do_stop = false;
params.stopcondition = [this, &do_stop]() {
return was_canceled() || do_stop;
};
params.progressind = [this, &curr_bed](unsigned st, unsigned bed) {
curr_bed = bed;
params.progressind = [this](unsigned st) {
if (st > 0)
update_status(int(m_status_range - st), _(L("Filling bed")));
};
params.on_packed = [&do_stop] (const ArrangePolygon &ap) {
do_stop = ap.bed_idx > 0 && ap.priority == 0;
};
arrangement::arrange(m_selected, m_unselected, m_bedpts, params);
// finalize just here.
@ -119,7 +122,7 @@ void FillBedJob::finalize()
size_t inst_cnt = model_object->instances.size();
for (ArrangePolygon &ap : m_selected) {
if (ap.priority != 0 || !(ap.bed_idx == arrangement::UNARRANGED || ap.bed_idx > 0))
if (ap.bed_idx != arrangement::UNARRANGED && (ap.priority != 0 || ap.bed_idx == 0))
ap.apply();
}