Skip to content

Commit

Permalink
Merge pull request #3591 from lordofhyphens/3589-viewport-divide-by-zero
Browse files Browse the repository at this point in the history
Avoid recentering viewport if the bounding box is max size 0
  • Loading branch information
alranel authored Dec 16, 2016
2 parents d4d26a5 + d398c27 commit 7472077
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/Slic3r/GUI/3DScene.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7472077

Please sign in to comment.