From 85cf995458bd1121907a56de237f3481153a1986 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Wed, 19 Feb 2025 10:21:16 +0800 Subject: [PATCH] Fix fov so off-plate objects can be rendered properly. Adopted from bambulab/BambuStudio@ba1951338045b04537159052a64e167bdac411ae and bambulab/BambuStudio@d0e91b5164afdb5b13e8b837aea6dfc884596546 Co-authored-by: zhou.xu --- src/slic3r/GUI/GLCanvas3D.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 26688a238..8ad93ff07 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1541,15 +1541,22 @@ void GLCanvas3D::refresh_camera_scene_box() BoundingBoxf3 GLCanvas3D::volumes_bounding_box(bool current_plate_only) const { BoundingBoxf3 bb; - PartPlate *plate = wxGetApp().plater()->get_partplate_list().get_curr_plate(); - + BoundingBoxf3 expand_part_plate_list_box; + bool is_limit = m_canvas_type != ECanvasType::CanvasAssembleView; + if (is_limit) { + auto plate_list_box = current_plate_only ? wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_bounding_box() : + wxGetApp().plater()->get_partplate_list().get_bounding_box(); + auto horizontal_radius = 0.5 * sqrt(std::pow(plate_list_box.min[0] - plate_list_box.max[0], 2) + std::pow(plate_list_box.min[1] - plate_list_box.max[1], 2)); + const float scale = 2; + expand_part_plate_list_box.merge(plate_list_box.min - scale * Vec3d(horizontal_radius, horizontal_radius, 0)); + expand_part_plate_list_box.merge(plate_list_box.max + scale * Vec3d(horizontal_radius, horizontal_radius, 0)); + } for (const GLVolume *volume : m_volumes.volumes) { if (!m_apply_zoom_to_volumes_filter || ((volume != nullptr) && volume->zoom_to_volumes)) { - const auto plate_bb = plate->get_bounding_box(); - const auto v_bb = volume->transformed_bounding_box(); - if (!plate_bb.overlap(v_bb)) - continue; - bb.merge(v_bb); + const auto v_bb = volume->transformed_bounding_box(); + if (is_limit && !expand_part_plate_list_box.overlap(v_bb)) + continue; + bb.merge(v_bb); } } return bb;