Fixed crash during thumbnail generation for SLA printers.

This commit is contained in:
Lukáš Hejl 2023-11-10 18:13:08 +01:00 committed by Lukas Matena
parent 5860d971bb
commit 87a58670f3

View File

@ -4902,7 +4902,8 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
camera.apply_projection(volumes_box, near_z, far_z); camera.apply_projection(volumes_box, near_z, far_z);
GLShaderProgram* shader = wxGetApp().get_shader("mm_gouraud"); const bool is_sla = current_printer_technology() == ptSLA;
GLShaderProgram *shader = wxGetApp().get_shader(is_sla ? "gouraud" : "mm_gouraud");
if (shader == nullptr) if (shader == nullptr)
return; return;
@ -4913,6 +4914,8 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
shader->start_using(); shader->start_using();
if (is_sla)
shader->set_uniform("emission_factor", 0.0f);
const Transform3d& projection_matrix = camera.get_projection_matrix(); const Transform3d& projection_matrix = camera.get_projection_matrix();
@ -4930,12 +4933,16 @@ void GLCanvas3D::_render_thumbnail_internal(ThumbnailData& thumbnail_data, const
const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose(); const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
shader->set_uniform("view_normal_matrix", view_normal_matrix); shader->set_uniform("view_normal_matrix", view_normal_matrix);
const ModelVolume &model_volume = *model_objects[vol->object_idx()]->volumes[vol->volume_idx()]; if (is_sla) {
const size_t extruder_idx = get_extruder_color_idx(model_volume, extruders_count); vol->render();
TriangleSelectorMmGui ts(model_volume.mesh(), extruders_colors, extruders_colors[extruder_idx]); } else {
ts.deserialize(model_volume.mmu_segmentation_facets.get_data(), true); const ModelVolume &model_volume = *model_objects[vol->object_idx()]->volumes[vol->volume_idx()];
ts.request_update_render_data(); const size_t extruder_idx = get_extruder_color_idx(model_volume, extruders_count);
ts.render(nullptr, model_matrix); TriangleSelectorMmGui ts(model_volume.mesh(), extruders_colors, extruders_colors[extruder_idx]);
ts.deserialize(model_volume.mmu_segmentation_facets.get_data(), true);
ts.request_update_render_data();
ts.render(nullptr, model_matrix);
}
vol->is_active = is_active; vol->is_active = is_active;
} }