#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_ShaderProgram.hxx>
#include <OpenGl_StructureShadow.hxx>
-#include <OpenGl_telem_util.hxx>
#include <OpenGl_Vec.hxx>
#include <OpenGl_View.hxx>
#include <OpenGl_Workspace.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
-IMPLEMENT_STANDARD_HANDLE (OpenGl_Structure, Graphic3d_CStructure)
-IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Structure, Graphic3d_CStructure)
+
+IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Structure,Graphic3d_CStructure)
//! Auxiliary class for bounding box presentation
class OpenGl_BndBoxPrs : public OpenGl_Element
{
#if !defined(GL_ES_VERSION_2_0)
// Apply line aspect
- const OpenGl_AspectLine* anAspectLine = theWorkspace->AspectLine (Standard_True);
const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
glDisable (GL_LIGHTING);
// Use highlight colors
- theWorkspace->GetGlContext()->core11->glColor3fv ((theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) ? theWorkspace->HighlightColor->rgb : anAspectLine->Color().rgb);
+ theWorkspace->GetGlContext()->core11->glColor3fv (theWorkspace->LineColor().GetData());
glEnableClientState (GL_VERTEX_ARRAY);
glVertexPointer (3, GL_FLOAT, 0, (GLfloat* )&myVerts);
{
theWorkspace->EnableTexture (aPrevTexture);
}
+ #else
+ (void )theWorkspace;
#endif
}
// =======================================================================
OpenGl_Structure::OpenGl_Structure (const Handle(Graphic3d_StructureManager)& theManager)
: Graphic3d_CStructure (theManager),
- myTransformation(NULL),
- myTransPers(NULL),
- myAspectLine(NULL),
- myAspectFace(NULL),
- myAspectMarker(NULL),
- myAspectText(NULL),
- myHighlightColor(NULL),
- myIsRaytracable (Standard_False),
- myModificationState (0),
- myIsCulled (Standard_True),
- myIsMirrored (Standard_False)
+ myHighlightColor (NULL),
+ myInstancedStructure (NULL),
+ myIsRaytracable (Standard_False),
+ myModificationState (0),
+ myIsCulled (Standard_True),
+ myIsMirrored (Standard_False)
{
//
}
OpenGl_Structure::~OpenGl_Structure()
{
Release (Handle(OpenGl_Context)());
- delete myTransformation; myTransformation = NULL;
- delete myTransPers; myTransPers = NULL;
-}
-
-// =======================================================================
-// function : UpdateAspects
-// purpose :
-// =======================================================================
-void OpenGl_Structure::UpdateAspects()
-{
- SetTransformPersistence (TransformPersistence);
-
- if (ContextLine.IsDef)
- SetAspectLine (ContextLine);
-
- if (ContextFillArea.IsDef)
- SetAspectFace (ContextFillArea);
-
- if (ContextMarker.IsDef)
- SetAspectMarker (ContextMarker);
-
- if (ContextText.IsDef)
- SetAspectText (ContextText);
}
// =======================================================================
// =======================================================================
void OpenGl_Structure::UpdateTransformation()
{
- if (myTransformation == NULL)
- {
- myTransformation = new OpenGl_Matrix();
- }
-
- Standard_ShortReal (*aMat)[4] = Graphic3d_CStructure::Transformation;
-
+ const OpenGl_Mat4& aMat = Graphic3d_CStructure::Transformation;
Standard_ShortReal aDet =
- aMat[0][0] * (aMat[1][1] * aMat[2][2] - aMat[2][1] * aMat[1][2]) -
- aMat[0][1] * (aMat[1][0] * aMat[2][2] - aMat[2][0] * aMat[1][2]) +
- aMat[0][2] * (aMat[1][0] * aMat[2][1] - aMat[2][0] * aMat[1][1]);
+ aMat.GetValue(0, 0) * (aMat.GetValue(1, 1) * aMat.GetValue(2, 2) - aMat.GetValue(2, 1) * aMat.GetValue(1, 2)) -
+ aMat.GetValue(0, 1) * (aMat.GetValue(1, 0) * aMat.GetValue(2, 2) - aMat.GetValue(2, 0) * aMat.GetValue(1, 2)) +
+ aMat.GetValue(0, 2) * (aMat.GetValue(1, 0) * aMat.GetValue(2, 1) - aMat.GetValue(2, 0) * aMat.GetValue(1, 1));
// Determinant of transform matrix less then 0 means that mirror transform applied.
myIsMirrored = aDet < 0.0f;
- matcpy (myTransformation->mat, &Graphic3d_CStructure::Transformation[0][0]);
-
- if (myIsRaytracable)
- {
- UpdateStateWithAncestorStructures();
- }
-}
-
-// =======================================================================
-// function : SetTransformPersistence
-// purpose :
-// =======================================================================
-void OpenGl_Structure::SetTransformPersistence(const CALL_DEF_TRANSFORM_PERSISTENCE &ATransPers)
-{
- if (!myTransPers)
- myTransPers = new TEL_TRANSFORM_PERSISTENCE;
-
- myTransPers->mode = ATransPers.Flag;
- myTransPers->pointX = ATransPers.Point.x;
- myTransPers->pointY = ATransPers.Point.y;
- myTransPers->pointZ = ATransPers.Point.z;
- MarkAsNotCulled();
-}
-
-// =======================================================================
-// function : SetAspectLine
-// purpose :
-// =======================================================================
-void OpenGl_Structure::SetAspectLine (const CALL_DEF_CONTEXTLINE &theAspect)
-{
- if (!myAspectLine)
+ if (IsRaytracable())
{
- myAspectLine = new OpenGl_AspectLine();
+ ++myModificationState;
}
- myAspectLine->SetAspect (theAspect);
-}
-
-// =======================================================================
-// function : SetAspectFace
-// purpose :
-// =======================================================================
-void OpenGl_Structure::SetAspectFace (const CALL_DEF_CONTEXTFILLAREA& theAspect)
-{
- if (!myAspectFace)
- {
- myAspectFace = new OpenGl_AspectFace();
- }
- myAspectFace->SetAspect (theAspect);
-
- if (myIsRaytracable)
- {
- UpdateStateWithAncestorStructures();
- }
-}
-
-// =======================================================================
-// function : SetAspectMarker
-// purpose :
-// =======================================================================
-void OpenGl_Structure::SetAspectMarker (const CALL_DEF_CONTEXTMARKER& theAspect)
-{
- if (!myAspectMarker)
- {
- myAspectMarker = new OpenGl_AspectMarker();
- }
- myAspectMarker->SetAspect (theAspect);
-}
-
-// =======================================================================
-// function : SetAspectText
-// purpose :
-// =======================================================================
-void OpenGl_Structure::SetAspectText (const CALL_DEF_CONTEXTTEXT &theAspect)
-{
- if (!myAspectText)
- {
- myAspectText = new OpenGl_AspectText();
- }
- myAspectText->SetAspect (theAspect);
}
// =======================================================================
myHighlightBox = new OpenGl_Group (theStruct);
}
- CALL_DEF_CONTEXTLINE& aContextLine = myHighlightBox->ChangeContextLine();
- aContextLine.IsDef = 1;
- aContextLine.Color = HighlightColor;
- aContextLine.LineType = Aspect_TOL_SOLID;
- aContextLine.Width = 1.0f;
- myHighlightBox->UpdateAspectLine (Standard_True);
+ myHighlightBox->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (HighlightColor, Aspect_TOL_SOLID, 1.0));
OpenGl_BndBoxPrs* aBndBoxPrs = new OpenGl_BndBoxPrs (myBndBox);
myHighlightBox->AddElement (aBndBoxPrs);
clearHighlightBox (theGlCtx);
if (myHighlightColor == NULL)
{
- myHighlightColor = new TEL_COLOUR();
+ myHighlightColor = new OpenGl_Vec4 (theColor, 1.0f);
+ }
+ else
+ {
+ myHighlightColor->xyz() = theColor;
}
-
- myHighlightColor->rgb[0] = theColor.r();
- myHighlightColor->rgb[1] = theColor.g();
- myHighlightColor->rgb[2] = theColor.b();
- myHighlightColor->rgb[3] = 1.F;
}
// =======================================================================
// =======================================================================
void OpenGl_Structure::OnVisibilityChanged()
{
- if (myIsRaytracable)
+ if (IsRaytracable())
{
- UpdateStateWithAncestorStructures();
+ ++myModificationState;
}
}
// =======================================================================
-// function : RegisterAncestorStructure
+// function : IsRaytracable
// purpose :
// =======================================================================
-void OpenGl_Structure::RegisterAncestorStructure (const OpenGl_Structure* theStructure) const
+Standard_Boolean OpenGl_Structure::IsRaytracable() const
{
- for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
+ if (!myGroups.IsEmpty()
+ && myIsRaytracable)
{
- if (anIt.Value() == theStructure)
- {
- return;
- }
+ return Standard_True;
}
- myAncestorStructures.Append (theStructure);
+ return myInstancedStructure != NULL
+ && myInstancedStructure->IsRaytracable();
}
// =======================================================================
-// function : UnregisterAncestorStructure
+// function : UpdateRaytracableState
// purpose :
// =======================================================================
-void OpenGl_Structure::UnregisterAncestorStructure (const OpenGl_Structure* theStructure) const
+void OpenGl_Structure::UpdateStateIfRaytracable (const Standard_Boolean toCheck) const
{
- for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
- {
- if (anIt.Value() == theStructure)
- {
- myAncestorStructures.Remove (anIt);
- return;
- }
- }
-}
-
-// =======================================================================
-// function : UnregisterFromAncestorStructure
-// purpose :
-// =======================================================================
-void OpenGl_Structure::UnregisterFromAncestorStructure() const
-{
- for (OpenGl_ListOfStructure::Iterator anIta (myAncestorStructures); anIta.More(); anIta.Next())
+ myIsRaytracable = !toCheck;
+ if (!myIsRaytracable)
{
- OpenGl_Structure* anAncestor = const_cast<OpenGl_Structure*> (anIta.ChangeValue());
-
- for (OpenGl_ListOfStructure::Iterator anIts (anAncestor->myConnected); anIts.More(); anIts.Next())
+ for (OpenGl_Structure::GroupIterator anIter (myGroups); anIter.More(); anIter.Next())
{
- if (anIts.Value() == this)
+ if (anIter.Value()->IsRaytracable())
{
- anAncestor->myConnected.Remove (anIts);
- return;
+ myIsRaytracable = Standard_True;
+ break;
}
}
}
-}
-
-// =======================================================================
-// function : UpdateStateWithAncestorStructures
-// purpose :
-// =======================================================================
-void OpenGl_Structure::UpdateStateWithAncestorStructures() const
-{
- myModificationState++;
-
- for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
- {
- anIt.Value()->UpdateStateWithAncestorStructures();
- }
-}
-
-// =======================================================================
-// function : UpdateRaytracableWithAncestorStructures
-// purpose :
-// =======================================================================
-void OpenGl_Structure::UpdateRaytracableWithAncestorStructures() const
-{
- myIsRaytracable = OpenGl_Raytrace::IsRaytracedStructure (this);
-
- if (!myIsRaytracable)
- {
- for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
- {
- anIt.Value()->UpdateRaytracableWithAncestorStructures();
- }
- }
-}
-// =======================================================================
-// function : SetRaytracableWithAncestorStructures
-// purpose :
-// =======================================================================
-void OpenGl_Structure::SetRaytracableWithAncestorStructures() const
-{
- myIsRaytracable = Standard_True;
-
- for (OpenGl_ListOfStructure::Iterator anIt (myAncestorStructures); anIt.More(); anIt.Next())
+ if (IsRaytracable())
{
- if (!anIt.Value()->IsRaytracable())
- {
- anIt.Value()->SetRaytracableWithAncestorStructures();
- }
+ ++myModificationState;
}
}
// =======================================================================
void OpenGl_Structure::Connect (Graphic3d_CStructure& theStructure)
{
- OpenGl_Structure* aStruct = (OpenGl_Structure* )&theStructure;
- Disconnect (theStructure);
- myConnected.Append (aStruct);
+ OpenGl_Structure* aStruct = static_cast<OpenGl_Structure*> (&theStructure);
+
+ Standard_ASSERT_RAISE (myInstancedStructure == NULL || myInstancedStructure == aStruct,
+ "Error! Instanced structure is already defined");
+
+ myInstancedStructure = aStruct;
if (aStruct->IsRaytracable())
{
- UpdateStateWithAncestorStructures();
- SetRaytracableWithAncestorStructures();
+ UpdateStateIfRaytracable (Standard_False);
}
-
- aStruct->RegisterAncestorStructure (this);
}
// =======================================================================
// =======================================================================
void OpenGl_Structure::Disconnect (Graphic3d_CStructure& theStructure)
{
- OpenGl_Structure* aStruct = (OpenGl_Structure* )&theStructure;
- for (OpenGl_ListOfStructure::Iterator anIter (myConnected); anIter.More(); anIter.Next())
- {
- // Check for the given structure
- if (anIter.Value() == aStruct)
- {
- myConnected.Remove (anIter);
+ OpenGl_Structure* aStruct = static_cast<OpenGl_Structure*> (&theStructure);
- if (aStruct->IsRaytracable())
- {
- UpdateStateWithAncestorStructures();
- UpdateRaytracableWithAncestorStructures();
- }
+ if (myInstancedStructure == aStruct)
+ {
+ myInstancedStructure = NULL;
- aStruct->UnregisterAncestorStructure (this);
- return;
+ if (aStruct->IsRaytracable())
+ {
+ UpdateStateIfRaytracable();
}
}
}
// Check for the given group
if (aGroupIter.Value() == theGroup)
{
+ const Standard_Boolean wasRaytracable =
+ static_cast<const OpenGl_Group&> (*theGroup).IsRaytracable();
+
theGroup->Clear (Standard_False);
- if (((OpenGl_Group* )theGroup.operator->())->IsRaytracable())
+ if (wasRaytracable)
{
- UpdateStateWithAncestorStructures();
- UpdateRaytracableWithAncestorStructures();
+ UpdateStateIfRaytracable();
}
myGroups.Remove (aGroupIter);
if (aRaytracableGroupDeleted)
{
- UpdateStateWithAncestorStructures();
- UpdateRaytracableWithAncestorStructures();
+ myIsRaytracable = Standard_False;
}
Is2dText = Standard_False;
}
// =======================================================================
-// function : RenderGeometry
+// function : renderGeometry
// purpose :
// =======================================================================
-void OpenGl_Structure::RenderGeometry (const Handle(OpenGl_Workspace) &theWorkspace) const
+void OpenGl_Structure::renderGeometry (const Handle(OpenGl_Workspace)& theWorkspace,
+ bool& theHasClosed) const
{
- // Render groups
- const Graphic3d_SequenceOfGroup& aGroups = DrawGroups();
- for (OpenGl_Structure::GroupIterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
+ if (myInstancedStructure != NULL)
+ {
+ myInstancedStructure->renderGeometry (theWorkspace, theHasClosed);
+ }
+
+ for (OpenGl_Structure::GroupIterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
{
+ theHasClosed = theHasClosed || aGroupIter.Value()->IsClosed();
aGroupIter.Value()->Render (theWorkspace);
}
}
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
// Render named status
- const Standard_Integer aNamedStatus = theWorkspace->NamedStatus;
if (highlight)
{
- theWorkspace->NamedStatus |= OPENGL_NS_HIGHLIGHT;
+ theWorkspace->SetHighlight (true);
}
- // Do we need to restore GL_NORMALIZE?
+ // Apply local transformation
+ aCtx->ModelWorldState.Push();
+ aCtx->ModelWorldState.SetCurrent (Transformation);
+
const Standard_Boolean anOldGlNormalize = aCtx->IsGlNormalizeEnabled();
- // Apply local transformation
- if (myTransformation)
+#if !defined(GL_ES_VERSION_2_0)
+ // detect scale transform
+ if (aCtx->core11 != NULL)
{
- OpenGl_Matrix aModelWorld;
- OpenGl_Transposemat3 (&aModelWorld, myTransformation);
- aCtx->ModelWorldState.Push();
- aCtx->ModelWorldState.SetCurrent (OpenGl_Mat4::Map ((Standard_ShortReal* )aModelWorld.mat));
-
- Standard_ShortReal aScaleX = OpenGl_Vec3 (myTransformation->mat[0][0],
- myTransformation->mat[0][1],
- myTransformation->mat[0][2]).SquareModulus();
- // Scale transform detected.
+ const Standard_ShortReal aScaleX = Transformation.GetRow (0).xyz().SquareModulus();
if (Abs (aScaleX - 1.f) > Precision::Confusion())
{
aCtx->SetGlNormalizeEnabled (Standard_True);
}
}
+#endif
- // Apply transform persistence
- const TEL_TRANSFORM_PERSISTENCE *aTransPersistence = NULL;
- if ( myTransPers && myTransPers->mode != 0 )
+ if (TransformPersistence.Flags)
{
- aTransPersistence = theWorkspace->ActiveView()->BeginTransformPersistence (aCtx, myTransPers, theWorkspace->Width(), theWorkspace->Height());
+ OpenGl_Mat4 aProjection = aCtx->ProjectionState.Current();
+ OpenGl_Mat4 aWorldView = aCtx->WorldViewState.Current();
+ TransformPersistence.Apply (aProjection, aWorldView, theWorkspace->Width(), theWorkspace->Height());
+
+ aCtx->ProjectionState.Push();
+ aCtx->WorldViewState.Push();
+ aCtx->ProjectionState.SetCurrent (aProjection);
+ aCtx->WorldViewState.SetCurrent (aWorldView);
+ aCtx->ApplyProjectionMatrix();
+
+ #if !defined(GL_ES_VERSION_2_0)
+ if (!aCtx->IsGlNormalizeEnabled()
+ && aCtx->core11 != NULL)
+ {
+ const Standard_Real aScale = Graphic3d_TransformUtils::ScaleFactor<Standard_ShortReal> (aWorldView);
+ if (Abs (aScale - 1.0f) > Precision::Confusion())
+ {
+ aCtx->SetGlNormalizeEnabled (Standard_True);
+ }
+ }
+ #endif
}
// Take into account transform persistence
aCtx->ApplyModelViewMatrix();
- // Apply aspects
- const OpenGl_AspectLine *anAspectLine = theWorkspace->AspectLine (Standard_False);
- const OpenGl_AspectFace *anAspectFace = theWorkspace->AspectFace (Standard_False);
- const OpenGl_AspectMarker *anAspectMarker = theWorkspace->AspectMarker (Standard_False);
- const OpenGl_AspectText *anAspectText = theWorkspace->AspectText (Standard_False);
- if (myAspectLine)
- {
- theWorkspace->SetAspectLine (myAspectLine);
- }
- if (myAspectFace)
- {
- theWorkspace->SetAspectFace (myAspectFace);
- }
- if (myAspectMarker)
- {
- theWorkspace->SetAspectMarker (myAspectMarker);
- }
- if (myAspectText)
- {
- theWorkspace->SetAspectText (myAspectText);
- }
+ // remember aspects
+ const OpenGl_AspectLine* aPrevAspectLine = theWorkspace->AspectLine();
+ const OpenGl_AspectFace* aPrevAspectFace = theWorkspace->AspectFace();
+ const OpenGl_AspectMarker* aPrevAspectMarker = theWorkspace->AspectMarker();
+ const OpenGl_AspectText* aPrevAspectText = theWorkspace->AspectText();
// Apply correction for mirror transform
if (myIsMirrored)
}
// Apply highlight color
- const TEL_COLOUR *aHighlightColor = theWorkspace->HighlightColor;
+ const OpenGl_Vec4* aHighlightColor = theWorkspace->HighlightColor;
if (myHighlightColor)
theWorkspace->HighlightColor = myHighlightColor;
- // Render connected structures
- OpenGl_ListOfStructure::Iterator anIter (myConnected);
- while (anIter.More())
- {
- anIter.Value()->RenderGeometry (theWorkspace);
- anIter.Next();
- }
-
// Set up plane equations for non-structure transformed global model-view matrix
// List of planes to be applied to context state
- NCollection_Handle<Graphic3d_SequenceOfHClipPlane> aUserPlanes;
+ Handle(NCollection_Shared<Graphic3d_SequenceOfHClipPlane>) aUserPlanes, aDisabledPlanes;
// Collect clipping planes of structure scope
if (!myClipPlanes.IsEmpty())
{
- Graphic3d_SequenceOfHClipPlane::Iterator aClippingIter (myClipPlanes);
- for (; aClippingIter.More(); aClippingIter.Next())
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aClippingIter (myClipPlanes); aClippingIter.More(); aClippingIter.Next())
{
const Handle(Graphic3d_ClipPlane)& aClipPlane = aClippingIter.Value();
if (!aClipPlane->IsOn())
if (aUserPlanes.IsNull())
{
- aUserPlanes = new Graphic3d_SequenceOfHClipPlane();
+ aUserPlanes = new NCollection_Shared<Graphic3d_SequenceOfHClipPlane>();
}
-
aUserPlanes->Append (aClipPlane);
}
}
-
- if (!aUserPlanes.IsNull() && !aUserPlanes->IsEmpty())
+ if (!aUserPlanes.IsNull())
{
// add planes at loaded view matrix state
- aCtx->ChangeClipping().AddWorld (*aUserPlanes, theWorkspace);
+ aCtx->ChangeClipping().AddWorld (aCtx, *aUserPlanes);
// Set OCCT state uniform variables
- if (!aCtx->ShaderManager()->IsEmpty())
+ aCtx->ShaderManager()->UpdateClippingState();
+ }
+
+ // True if structure is fully clipped
+ bool isClipped = false;
+
+ // Set of clipping planes that do not intersect the structure,
+ // and thus can be disabled to improve rendering performance
+ const Graphic3d_BndBox4f& aBBox = BoundingBox();
+ if (!aCtx->Clipping().Planes().IsEmpty() && aBBox.IsValid() && TransformPersistence.Flags == Graphic3d_TMF_None)
+ {
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (aCtx->Clipping().Planes()); aPlaneIt.More(); aPlaneIt.Next())
{
- aCtx->ShaderManager()->UpdateClippingState();
+ const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
+ if (!aPlane->IsOn())
+ {
+ continue;
+ }
+
+ // check for clipping
+ const Graphic3d_Vec4d& aPlaneEquation = aPlane->GetEquation();
+ const Graphic3d_Vec4d aMaxPnt (aPlaneEquation.x() > 0.0 ? aBBox.CornerMax().x() : aBBox.CornerMin().x(),
+ aPlaneEquation.y() > 0.0 ? aBBox.CornerMax().y() : aBBox.CornerMin().y(),
+ aPlaneEquation.z() > 0.0 ? aBBox.CornerMax().z() : aBBox.CornerMin().z(),
+ 1.0);
+ if (aPlaneEquation.Dot (aMaxPnt) < 0.0) // max vertex is outside the half-space
+ {
+ isClipped = true;
+ break;
+ }
+
+ // check for no intersection (e.g. object is "entirely not clipped")
+ const Graphic3d_Vec4d aMinPnt (aPlaneEquation.x() > 0.0 ? aBBox.CornerMin().x() : aBBox.CornerMax().x(),
+ aPlaneEquation.y() > 0.0 ? aBBox.CornerMin().y() : aBBox.CornerMax().y(),
+ aPlaneEquation.z() > 0.0 ? aBBox.CornerMin().z() : aBBox.CornerMax().z(),
+ 1.0);
+ if (aPlaneEquation.Dot (aMinPnt) > 0.0) // min vertex is inside the half-space
+ {
+ aCtx->ChangeClipping().SetEnabled (aCtx, aPlane, Standard_False);
+ if (aDisabledPlanes.IsNull())
+ {
+ aDisabledPlanes = new NCollection_Shared<Graphic3d_SequenceOfHClipPlane>();
+ if (aUserPlanes.IsNull())
+ {
+ aCtx->ShaderManager()->UpdateClippingState();
+ }
+ }
+ aDisabledPlanes->Append (aPlane);
+ }
}
}
// Render groups
- const Graphic3d_SequenceOfGroup& aGroups = DrawGroups();
- for (OpenGl_Structure::GroupIterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
+ bool hasClosedPrims = false;
+ if (!isClipped)
{
- aGroupIter.Value()->Render (theWorkspace);
+ renderGeometry (theWorkspace, hasClosedPrims);
}
// Reset correction for mirror transform
}
// Render capping for structure groups
- if (!aCtx->Clipping().Planes().IsEmpty())
+ if (hasClosedPrims
+ && aCtx->Clipping().IsCappingOn())
{
- OpenGl_CappingAlgo::RenderCapping (theWorkspace, aGroups);
+ OpenGl_CappingAlgo::RenderCapping (theWorkspace, *this);
}
// Revert structure clippings
- if (!aUserPlanes.IsNull() && !aUserPlanes->IsEmpty())
+ if (!aDisabledPlanes.IsNull())
{
- aCtx->ChangeClipping().Remove (*aUserPlanes);
-
- // Set OCCT state uniform variables
- if (!aCtx->ShaderManager()->IsEmpty())
+ // enable planes that were previously disabled
+ for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aDisabledPlanes); aPlaneIt.More(); aPlaneIt.Next())
+ {
+ aCtx->ChangeClipping().SetEnabled (aCtx, aPlaneIt.Value(), Standard_True);
+ }
+ if (aUserPlanes.IsNull())
{
aCtx->ShaderManager()->RevertClippingState();
}
}
+ if (!aUserPlanes.IsNull())
+ {
+ aCtx->ChangeClipping().Remove (aCtx, *aUserPlanes);
- // Apply local transformation
- if (myTransformation)
+ // Set OCCT state uniform variables
+ aCtx->ShaderManager()->RevertClippingState();
+ }
+
+ // Restore local transformation
+ aCtx->ModelWorldState.Pop();
+ aCtx->SetGlNormalizeEnabled (anOldGlNormalize);
+ if (TransformPersistence.Flags)
{
- aCtx->ModelWorldState.Pop();
- aCtx->SetGlNormalizeEnabled (anOldGlNormalize);
+ aCtx->ProjectionState.Pop();
+ aCtx->WorldViewState.Pop();
+ aCtx->ApplyProjectionMatrix();
}
// Restore highlight color
theWorkspace->HighlightColor = aHighlightColor;
// Restore aspects
- theWorkspace->SetAspectLine (anAspectLine);
- theWorkspace->SetAspectFace (anAspectFace);
- theWorkspace->SetAspectMarker (anAspectMarker);
- theWorkspace->SetAspectText (anAspectText);
-
- // Restore transform persistence
- if ( myTransPers && myTransPers->mode != 0 )
- {
- theWorkspace->ActiveView()->BeginTransformPersistence (aCtx, aTransPersistence, theWorkspace->Width(), theWorkspace->Height());
- }
+ theWorkspace->SetAspectLine (aPrevAspectLine);
+ theWorkspace->SetAspectFace (aPrevAspectFace);
+ theWorkspace->SetAspectMarker (aPrevAspectMarker);
+ theWorkspace->SetAspectText (aPrevAspectText);
// Apply highlight box
if (!myHighlightBox.IsNull())
}
// Restore named status
- theWorkspace->NamedStatus = aNamedStatus;
+ theWorkspace->SetHighlight (false);
}
// =======================================================================
{
// Release groups
Clear (theGlCtx);
- OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectLine);
- OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectFace);
- OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectMarker);
- OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectText);
clearHighlightColor (theGlCtx);
-
- // Remove from connected list of ancestor
- UnregisterFromAncestorStructure();
}
// =======================================================================
{
aGroupIter.ChangeValue()->Release (theGlCtx);
}
- if (myAspectLine != NULL)
- {
- myAspectLine->Release (theGlCtx.operator->());
- }
- if (myAspectFace != NULL)
- {
- myAspectFace->Release (theGlCtx.operator->());
- }
- if (myAspectMarker != NULL)
- {
- myAspectMarker->Release (theGlCtx.operator->());
- }
- if (myAspectText != NULL)
- {
- myAspectText->Release (theGlCtx.operator->());
- }
if (!myHighlightBox.IsNull())
{
myHighlightBox->Release (theGlCtx.operator->());