diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 1f9638b348..7c5a748e87 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -3393,18 +3393,6 @@ SbBox3f View3DInventorViewer::getBoundingBox() const void View3DInventorViewer::viewAll() { - SbBox3f box = getBoundingBox(); - - if (box.isEmpty()) { - return; - } - - SbSphere sphere; - sphere.circumscribe(box); - if (sphere.getRadius() == 0) { - return; - } - // in the scene graph we may have objects which we want to exclude // when doing a fit all. Such objects must be part of the group // SoSkipBoundingGroup. @@ -3420,20 +3408,30 @@ void View3DInventorViewer::viewAll() group->mode = SoSkipBoundingGroup::EXCLUDE_BBOX; } - // Set the height angle to 45 deg - SoCamera* cam = this->getSoRenderManager()->getCamera(); + SbBox3f box = getBoundingBox(); - if (cam && cam->getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId())) { - static_cast(cam)->heightAngle = (float)(std::numbers::pi / 4.0); // NOLINT - } + if (!box.isEmpty()) { + SbSphere sphere; + sphere.circumscribe(box); + if (sphere.getRadius() != 0) { + // Set the height angle to 45 deg + SoCamera* cam = this->getSoRenderManager()->getCamera(); - if (isAnimationEnabled()) { - animatedViewAll(10, 20); // NOLINT - } + if (cam && cam->getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId())) { + static_cast(cam)->heightAngle = + (float)(std::numbers::pi / 4.0); // NOLINT + } - // make sure everything is visible - if (cam) { - cam->viewAll(getSoRenderManager()->getSceneGraph(), this->getSoRenderManager()->getViewportRegion()); + if (isAnimationEnabled()) { + animatedViewAll(10, 20); // NOLINT + } + + // make sure everything is visible + if (cam) { + cam->viewAll(getSoRenderManager()->getSceneGraph(), + this->getSoRenderManager()->getViewportRegion()); + } + } } for (int i = 0; i < pathlist.getLength(); i++) {