Fix:crash when multicolor printing

jira: none
Change-Id: I6289934a897644fb025acd20b59bea1a69995f89
(cherry picked from commit 576d931475c4b42582d78092e75ce0b0b7394ca7)
This commit is contained in:
jiangkai.zhao
2025-03-11 16:14:49 +08:00
committed by Noisyfox
parent 947e034b14
commit 99ec668aa0

View File

@@ -823,25 +823,24 @@ int GLVolumeCollection::load_real_wipe_tower_preview(
if (wt_mesh.its.vertices.empty()) return int(this->volumes.size() - 1);
std::vector<Slic3r::ColorRGBA> extruder_colors = GUI::wxGetApp().plater()->get_extruders_colors();
std::vector<Slic3r::ColorRGBA> colors;
GUI::PartPlateList &ppl = GUI::wxGetApp().plater()->get_partplate_list();
std::vector<int> plate_extruders = ppl.get_plate(plate_idx)->get_extruders(true);
for (int extruder_id : plate_extruders) {
if (extruder_id <= extruder_colors.size())
colors.push_back(extruder_colors[extruder_id - 1]);
std::vector<Slic3r::ColorRGBA> colors;
if (!plate_extruders.empty()) {
if (plate_extruders.front() <= extruder_colors.size())
colors.push_back(extruder_colors[plate_extruders.front() - 1]);
else
colors.push_back(extruder_colors[0]);
}
volumes.emplace_back(new GLWipeTowerVolume(colors));
if (colors.empty()) return int(this->volumes.size() - 1);
volumes.emplace_back(new GLWipeTowerVolume({colors}));
GLWipeTowerVolume &v = *dynamic_cast<GLWipeTowerVolume *>(volumes.back());
v.model_per_colors.resize(colors.size());
auto mesh = wt_mesh;
if (render_brim) {
mesh.merge(brim_mesh);
}
if (!colors.empty()) {
v.model_per_colors.resize(1);
v.model_per_colors[0].init_from(mesh);
}
TriangleMesh wipe_tower_shell = mesh.convex_hull_3d();