From c86b7e17c8bc304c6fc51031bd17a44f48f78312 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 9 Dec 2013 13:40:42 +0100 Subject: [PATCH] + A more reliable workaround for regression in SoQtViewer --- src/Gui/View3DInventorViewer.cpp | 50 ++++++++++++++------------------ 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index a2ac8669b..02d410251 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -34,7 +34,6 @@ # include # endif # include -# include # include # include # include @@ -73,6 +72,7 @@ # include # include # include +# include # include # include # include @@ -345,11 +345,6 @@ SbBool View3DInventorViewer::hasViewProvider(ViewProvider* pcProvider) const /// adds an ViewProvider to the view, e.g. from a feature void View3DInventorViewer::addViewProvider(ViewProvider* pcProvider) { -#if (COIN_MAJOR_VERSION >= 4) - if (!this->isAutoClipping()) - this->setAutoClipping(TRUE); // setCameraType() -#endif - SoSeparator* root = pcProvider->getRoot(); if (root){ pcViewProviderRoot->addChild(root); @@ -379,16 +374,8 @@ void View3DInventorViewer::removeViewProvider(ViewProvider* pcProvider) if (back) backgroundroot->removeChild(back); _ViewProviderSet.erase(pcProvider); - -#if (COIN_MAJOR_VERSION >= 4) - if (_ViewProviderSet.empty()) { - if (this->isAutoClipping()) - this->setAutoClipping(FALSE); // setCameraType() - } -#endif } - SbBool View3DInventorViewer::setEditingViewProvider(Gui::ViewProvider* p, int ModNum) { if (this->editViewProvider) @@ -1004,6 +991,27 @@ void View3DInventorViewer::renderFramebuffer() // upon spin. void View3DInventorViewer::renderScene(void) { + // https://bitbucket.org/Coin3D/sogui/src/239bd7ae533d/viewers/SoGuiViewer.cpp.in + // The commit introduced a regression for empty view volumes. +#if SOQT_MAJOR_VERSION > 1 || (SOQT_MAJOR_VERSION == 1 && SOQT_MINOR_VERSION >= 6) + // With SoQt 1.6 we have problems when the scene is empty and auto-clipping is turned on. + // There is always a warning that the frustum is invalid because the far and near distance + // values were set to garbage values when trying to determine the clipping planes. + // It will be turned on/off depending on the bounding box since the Coin3d doc says it may + // have a bad impact on performance if it's always off. + SoGetBoundingBoxAction action(getViewportRegion()); + action.apply(this->getSceneGraph()); + SbXfBox3f xbox = action.getXfBoundingBox(); + if (xbox.isEmpty()) { + if (this->isAutoClipping()) + this->setAutoClipping(FALSE); + } + else { + if (!this->isAutoClipping()) + this->setAutoClipping(TRUE); + } +#endif + // Must set up the OpenGL viewport manually, as upon resize // operations, Coin won't set it up until the SoGLRenderAction is // applied again. And since we need to do glClear() before applying @@ -1459,20 +1467,6 @@ void View3DInventorViewer::setCameraType(SoType t) if (cam == 0) return; static_cast(cam)->heightAngle = (float)(M_PI / 4.0); } - - // With SoQt 1.6/Coin4.0 we have problems when the scene is empty and auto-clipping is turned on. - // There is always a warning that the frustum is invalid because the far and near distance - // values were set to garbage values when trying to determine the clipping planes. - // It will be turned on again when adding nodes by addViewProvider() since the Coin3d doc - // says it may have a bad impact on performance. -#if (COIN_MAJOR_VERSION >= 4) - SoGetBoundingBoxAction action(getViewportRegion()); - action.apply(this->getSceneGraph()); - SbXfBox3f xbox = action.getXfBoundingBox(); - if (xbox.isEmpty()) { - this->setAutoClipping(FALSE); - } -#endif } void View3DInventorViewer::moveCameraTo(const SbRotation& rot, const SbVec3f& pos, int steps, int ms)