diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 7815391e9..6253f4e89 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -946,6 +946,7 @@ Print::ApplyStatus Print::apply(const Model &model, const DynamicPrintConfig &co // Simple case, just generate new instances. for (const PrintInstances &print_instances : new_print_instances) { PrintObject *print_object = new PrintObject(this, model_object, model_object->raw_bounding_box()); + print_object->set_trafo(print_instances.trafo); print_object->set_copies(print_instances.copies); print_object->config_apply(config); print_objects_new.emplace_back(print_object); @@ -959,10 +960,11 @@ Print::ApplyStatus Print::apply(const Model &model, const DynamicPrintConfig &co // Merge the old / new lists. auto it_old = old.begin(); for (const PrintInstances &new_instances : new_print_instances) { - for (; transform3d_lower((*it_old)->trafo, new_instances.trafo); ++ it_old); - if (! transform3d_equal((*it_old)->trafo, new_instances.trafo)) { + for (; it_old != old.end() && transform3d_lower((*it_old)->trafo, new_instances.trafo); ++ it_old); + if (it_old == old.end() || ! transform3d_equal((*it_old)->trafo, new_instances.trafo)) { // This is a new instance (or a set of instances with the same trafo). Just add it. PrintObject *print_object = new PrintObject(this, model_object, model_object->raw_bounding_box()); + print_object->set_trafo(new_instances.trafo); print_object->set_copies(new_instances.copies); print_object->config_apply(config); print_objects_new.emplace_back(print_object); diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index bd04cd371..5127b588e 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -203,7 +203,9 @@ public: void config_apply_only(const ConfigBase &other, const t_config_option_keys &keys, bool ignore_nonexistent = false) { this->m_config.apply_only(other, keys, ignore_nonexistent); } const LayerPtrs& layers() const { return m_layers; } const SupportLayerPtrs& support_layers() const { return m_support_layers; } + const Transform3d& trafo() const { return m_trafo; } + void set_trafo(const Transform3d& trafo) { m_trafo = trafo; } const Points& copies() const { return m_copies; } bool add_copy(const Vec2d &point); diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 38b2e678b..b7b33087f 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1615,10 +1615,7 @@ std::vector PrintObject::_slice_volumes(const std::vector &z, for (const ModelVolume *v : volumes) mesh.merge(v->mesh); if (mesh.stl.stats.number_of_facets > 0) { - // transform mesh - // we ignore the per-instance transformations currently and only - // consider the first one - this->model_object()->instances.front()->transform_mesh(&mesh, true); + mesh.transform(m_trafo.cast()); // align mesh to Z = 0 (it should be already aligned actually) and apply XY shift mesh.translate(- unscale(m_copies_shift(0)), - unscale(m_copies_shift(1)), - float(this->model_object()->bounding_box().min(2))); // perform actual slicing diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index e39760184..8fdb5fd3b 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2408,7 +2408,7 @@ void Plater::reslice() // Don't reslice if export of G-code or sending to OctoPrint is running. // if (! defined($self->{export_gcode_output_file}) && ! defined($self->{send_gcode_file})) { // Stop the background processing threads, stop the async update timer. - this->p->stop_background_process(); +// this->p->stop_background_process(); // Rather perform one additional unnecessary update of the print object instead of skipping a pending async update. this->p->async_apply_config(); /*