fixed bug with instancing

This commit is contained in:
Pavel Mikus 2022-12-13 12:41:21 +01:00 committed by Pavel Mikuš
parent 49b68b936c
commit a57e2a22f6
3 changed files with 19 additions and 8 deletions

View File

@ -202,6 +202,11 @@ public:
}
};
struct GeneratedSupportPoints{
Transform3d object_transform; // for frontend object mapping
SupportSpotsGenerator::SupportPoints support_points;
};
std::vector<std::unique_ptr<PrintRegion>> all_regions;
std::vector<LayerRangeRegions> layer_ranges;
// Transformation of this ModelObject into one of the associated PrintObjects (all PrintObjects derived from a single modelObject differ by a Z rotation only).
@ -209,7 +214,7 @@ public:
Transform3d trafo_bboxes;
std::vector<ObjectID> cached_volume_ids;
SupportSpotsGenerator::SupportPoints generated_support_points;
std::optional<GeneratedSupportPoints> generated_support_points;
void ref_cnt_inc() { ++ m_ref_cnt; }
void ref_cnt_dec() { if (-- m_ref_cnt == 0) delete this; }
@ -217,7 +222,7 @@ public:
all_regions.clear();
layer_ranges.clear();
cached_volume_ids.clear();
generated_support_points.clear();
generated_support_points.reset();
}
private:

View File

@ -419,10 +419,12 @@ void PrintObject::generate_support_spots()
if (this->set_started(posSupportSpotsSearch)) {
BOOST_LOG_TRIVIAL(debug) << "Searching support spots - start";
m_print->set_status(75, L("Searching support spots"));
SupportSpotsGenerator::Params params{this->print()->m_config.filament_type.values};
SupportSpotsGenerator::SupportPoints supp_points = SupportSpotsGenerator::full_search(this, params);
this->m_shared_regions->generated_support_points = supp_points;
m_print->throw_if_canceled();
if (!this->shared_regions()->generated_support_points.has_value()) {
SupportSpotsGenerator::Params params{this->print()->m_config.filament_type.values};
SupportSpotsGenerator::SupportPoints supp_points = SupportSpotsGenerator::full_search(this, params);
this->m_shared_regions->generated_support_points = {this->trafo_centered(), supp_points};
m_print->throw_if_canceled();
}
BOOST_LOG_TRIVIAL(debug) << "Searching support spots - end";
this->set_done(posSupportSpotsSearch);
}

View File

@ -405,13 +405,17 @@ void GLGizmoFdmSupports::apply_data_from_backend()
if (!has_backend_supports())
return;
ModelObject *mo = m_c->selection_info()->model_object();
if (!mo) {
this->waiting_for_autogenerated_supports = false;
return;
}
// find the respective PrintObject, we need a pointer to it
for (const PrintObject *po : m_parent.fff_print()->objects()) {
if (po->model_object()->id() == mo->id()) {
std::unordered_map<size_t, TriangleSelectorWrapper> selectors;
SupportSpotsGenerator::SupportPoints support_points = po->shared_regions()->generated_support_points;
auto obj_transform = po->trafo_centered();
SupportSpotsGenerator::SupportPoints support_points = po->shared_regions()->generated_support_points->support_points;
auto obj_transform = po->shared_regions()->generated_support_points->object_transform;
for (ModelVolume *model_volume : po->model_object()->volumes) {
if (model_volume->is_model_part()) {
Transform3d mesh_transformation = obj_transform * model_volume->get_matrix();