mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 20:55:56 +08:00
Merge pull request #3591 from lordofhyphens/3589-viewport-divide-by-zero
Avoid recentering viewport if the bounding box is max size 0
This commit is contained in:
commit
7472077540
@ -376,12 +376,15 @@ sub zoom_to_bounding_box {
|
||||
# bounding box
|
||||
my $max_size = max(@{$bb->size}) * 1.05;
|
||||
my $min_viewport_size = min($self->GetSizeWH);
|
||||
$self->_zoom($min_viewport_size / $max_size);
|
||||
if ($max_size != 0) {
|
||||
# only re-zoom if we have a valid bounding box, avoid a divide by 0 error.
|
||||
$self->_zoom($min_viewport_size / $max_size);
|
||||
|
||||
# center view around bounding box center
|
||||
$self->_camera_target($bb->center);
|
||||
# center view around bounding box center
|
||||
$self->_camera_target($bb->center);
|
||||
|
||||
$self->on_viewport_changed->() if $self->on_viewport_changed;
|
||||
$self->on_viewport_changed->() if $self->on_viewport_changed;
|
||||
}
|
||||
}
|
||||
|
||||
sub zoom_to_bed {
|
||||
|
Loading…
x
Reference in New Issue
Block a user