]> OCCT Git - occt-copy.git/commitdiff
0031579: Visualization - OpenGl_CappingAlgo performance on some clipping planes
authorsshutina <sshutina@opencascade.com>
Fri, 2 Oct 2020 11:31:30 +0000 (14:31 +0300)
committersshutina <sshutina@opencascade.com>
Fri, 2 Oct 2020 11:31:30 +0000 (14:31 +0300)
src/OpenGl/OpenGl_CappingAlgo.cxx

index ca24e09d09c8f840bae99df4c0a12de35396ee58..8076946136a93de77be52a4edd1fa570d574dad8 100755 (executable)
@@ -177,6 +177,35 @@ namespace
     theWorkspace->SetAllowFaceCulling (wasCullAllowed);
   }
 
+  bool isGroupClipped (const Handle(Graphic3d_Group)& theGroup, const Handle(OpenGl_Context)& theContext)
+  {
+    const Graphic3d_BndBox4f& aBoxF = theGroup->BoundingBox();
+    Graphic3d_BndBox3d aBBox = Graphic3d_BndBox3d (Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMin().x(),
+                                                  (Standard_Real )aBoxF.CornerMin().y(),
+                                                  (Standard_Real )aBoxF.CornerMin().z()),
+                                 Graphic3d_Vec3d ((Standard_Real )aBoxF.CornerMax().x(),
+                                                  (Standard_Real )aBoxF.CornerMax().y(),
+                                                  (Standard_Real )aBoxF.CornerMax().z()));
+
+    Standard_Boolean isClipped = 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)
+      {
+        isClipped = true;
+        break;
+      }
+    }
+    return isClipped;
+  }
+
   //! Render capping for specific structure.
   static void renderCappingForStructure (StencilTestSentry& theStencilSentry,
                                          const Handle(OpenGl_Workspace)& theWorkspace,
@@ -207,6 +236,11 @@ namespace
         continue;
       }
 
+      if (isGroupClipped (aGroupIter.Value(), aContext))
+      {
+        continue;
+      }
+
       // clear stencil only if something has been actually drawn
       theStencilSentry.Init();