From cddbf6a98500ed818983129a325f7048c06433a2 Mon Sep 17 00:00:00 2001 From: apl Date: Thu, 9 Oct 2014 13:46:52 +0400 Subject: [PATCH 1/1] 0024717: TKOpenGl - globally defined clipping planes blink when operating with view Specify viewer (global) clippings in correct view transformation space. Correction of test case for issue CR24717 --- src/OpenGl/OpenGl_View_2.cxx | 53 ++++++++++++++++++------------------ tests/bugs/vis/bug24717 | 30 ++++++++++++++++++++ 2 files changed, 56 insertions(+), 27 deletions(-) create mode 100644 tests/bugs/vis/bug24717 diff --git a/src/OpenGl/OpenGl_View_2.cxx b/src/OpenGl/OpenGl_View_2.cxx index d8c54657f5..507ddc7402 100644 --- a/src/OpenGl/OpenGl_View_2.cxx +++ b/src/OpenGl/OpenGl_View_2.cxx @@ -1145,7 +1145,7 @@ void OpenGl_View::RedrawScene (const Handle(OpenGl_PrinterContext)& thePrintCont aPlaneFront = new Graphic3d_ClipPlane (aFrontEquation); } - // do some "memory allocation"-wise optimization + // Specify slicing planes with identity transformation if (!aPlaneBack.IsNull() || !aPlaneFront.IsNull()) { Graphic3d_SequenceOfHClipPlane aSlicingPlanes; @@ -1164,32 +1164,6 @@ void OpenGl_View::RedrawScene (const Handle(OpenGl_PrinterContext)& thePrintCont } } - // Apply user clipping planes - if (!myClipPlanes.IsEmpty()) - { - Graphic3d_SequenceOfHClipPlane aUserPlanes; - Graphic3d_SequenceOfHClipPlane::Iterator aClippingIt (myClipPlanes); - for (; aClippingIt.More(); aClippingIt.Next()) - { - const Handle(Graphic3d_ClipPlane)& aClipPlane = aClippingIt.Value(); - if (aClipPlane->IsOn()) - { - aUserPlanes.Append (aClipPlane); - } - } - - if (!aUserPlanes.IsEmpty()) - { - // add planes at actual matrix state. - aContext->ChangeClipping().AddWorld (aUserPlanes); - } - - if (!aContext->ShaderManager()->IsEmpty()) - { - aContext->ShaderManager()->UpdateClippingState(); - } - } - #if !defined(GL_ES_VERSION_2_0) // Setup view projection glMatrixMode (GL_PROJECTION); @@ -1221,6 +1195,31 @@ void OpenGl_View::RedrawScene (const Handle(OpenGl_PrinterContext)& thePrintCont // Setup view orientation theWorkspace->SetViewMatrix (theOrientation); + // Specify clipping planes in view transformation space + if (!myClipPlanes.IsEmpty()) + { + Graphic3d_SequenceOfHClipPlane aUserPlanes; + Graphic3d_SequenceOfHClipPlane::Iterator aClippingIt (myClipPlanes); + for (; aClippingIt.More(); aClippingIt.Next()) + { + const Handle(Graphic3d_ClipPlane)& aClipPlane = aClippingIt.Value(); + if (aClipPlane->IsOn()) + { + aUserPlanes.Append (aClipPlane); + } + } + + if (!aUserPlanes.IsEmpty()) + { + aContext->ChangeClipping().AddWorld (aUserPlanes); + } + + if (!aContext->ShaderManager()->IsEmpty()) + { + aContext->ShaderManager()->UpdateClippingState(); + } + } + #if !defined(GL_ES_VERSION_2_0) // Apply Lights { diff --git a/tests/bugs/vis/bug24717 b/tests/bugs/vis/bug24717 new file mode 100644 index 0000000000..06ead2728e --- /dev/null +++ b/tests/bugs/vis/bug24717 @@ -0,0 +1,30 @@ +puts "============" +puts "OCC24717" +puts "============" +puts "" +#################################################################################### +# TKOpenGl - globally defined clipping planes blink when operating with view +# Test checks that state of clippings always corresponds to a state of viewed +# scene. +#################################################################################### + +set check_x 204 +set check_y 204 + +vinit View1 +vsetdispmode 1 +box b 1 1 1 +vdisplay b +vmoveto $check_x $check_y +vclipplane create pln1 +vclipplane set pln1 view Driver1/Viewer1/View1 +vclipplane change pln1 equation 0 1 0 0 +vfit + +checkcolor $check_x $check_y 0 1 1 + +if {$stat != 1} { + puts "Error : Viewer clipping is broken." +} + +vdump ${imagedir}/${casename}.png -- 2.20.1