From ce866070070dbdcaf46a2ae8d6fa4dfb805162e2 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 26 May 2020 10:39:58 +0300 Subject: [PATCH] 0031579: Visualization - OpenGl_CappingAlgo performance on some clipping planes --- src/OpenGl/OpenGl_CappingAlgo.cxx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/OpenGl/OpenGl_CappingAlgo.cxx b/src/OpenGl/OpenGl_CappingAlgo.cxx index eed90116dd..6060fcb050 100755 --- a/src/OpenGl/OpenGl_CappingAlgo.cxx +++ b/src/OpenGl/OpenGl_CappingAlgo.cxx @@ -80,6 +80,32 @@ namespace theWorkspace->SetAllowFaceCulling (wasCullAllowed); } + Standard_Boolean isGroupClipped (const Handle(Graphic3d_Group)& theGroup, const Handle(OpenGl_Context)& theContext) + { + const Graphic3d_BndBox3d& aBBox = theGroup->Structure()->CStructure()->BoundingBox(); + if (!aBBox.IsValid()) + { + return Standard_False; + } + + for (OpenGl_ClippingIterator aPlaneIt (theContext->Clipping()); aPlaneIt.More(); aPlaneIt.Next()) + { + const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value(); + if (!aPlane->IsOn()) + { + continue; + } + + const Graphic3d_ClipState aBoxState = aPlane->ProbeBox (aBBox); + if (aBoxState == Graphic3d_ClipState_Out) + { + return Standard_True; + } + } + return Standard_False; + } + + //! Render capping for specific structure. static void renderCappingForStructure (StencilTestSentry& theStencilSentry, const Handle(OpenGl_Workspace)& theWorkspace, @@ -100,6 +126,11 @@ namespace continue; } + if (isGroupClipped (aGroupIter.Value(), aContext)) + { + continue; + } + // clear stencil only if something has been actually drawn theStencilSentry.Init(); -- 2.31.1.windows.1