diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index bca3637368..b4ba4ce9dd 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -548,6 +548,23 @@ void View3DInventorViewer::init() pcViewProviderRoot->addChild(threePointLightingSeparator); pcViewProviderRoot->addChild(environment); + // add a global hidden anchor object to ensure transparent objects work correctly + // in empty scenes - OpenInventor's two-pass transparency rendering requires at least + // one opaque object to properly initialize the depth buffer. so this fixes transparency + // issues for image planes, planes, and other transparent geometry. + // wrap in SoSkipBoundingGroup to exclude from bounding box calculations + // check #15192 #24003 + auto hiddenAnchor = new SoSkipBoundingGroup(); + hiddenAnchor->mode = SoSkipBoundingGroup::EXCLUDE_BBOX; + auto hiddenSep = new SoSeparator(); + auto hiddenScale = new SoScale(); + hiddenScale->scaleFactor = SbVec3f(0, 0, 0); + auto hiddenCube = new SoCube(); + hiddenSep->addChild(hiddenScale); + hiddenSep->addChild(hiddenCube); + hiddenAnchor->addChild(hiddenSep); + pcViewProviderRoot->addChild(hiddenAnchor); + // increase refcount before passing it to setScenegraph(), to avoid // premature destruction pcViewProviderRoot->ref(); @@ -1530,15 +1547,6 @@ void View3DInventorViewer::showRotationCenter(bool show) rotationCenterGroup = new SoSkipBoundingGroup(); auto sphere = new SoSphere(); - - // There needs to be a non-transparent object to ensure the transparent sphere works - // when opening an new empty document - auto hidden = new SoSeparator(); - auto hiddenScale = new SoScale(); - hiddenScale->scaleFactor = SbVec3f(0, 0, 0); - hidden->addChild(hiddenScale); - hidden->addChild(sphere); - auto complexity = new SoComplexity(); complexity->value = 1; @@ -1561,7 +1569,6 @@ void View3DInventorViewer::showRotationCenter(bool show) scaledSphere->scaleFactor = size; rotationCenterGroup->addChild(translation); - rotationCenterGroup->addChild(hidden); rotationCenterGroup->addChild(scaledSphere); sep->addChild(rotationCenterGroup);