#include <Graphic3d_IndexBuffer.hxx>
#include <Graphic3d_Buffer.hxx>
#include <Graphic3d_BoundBuffer.hxx>
+#include <Graphic3d_TransformPers.hxx>
#include <gp_Ax2.hxx>
#include <TCollection_ExtendedString.hxx>
//! sets the flipping to theIsEnabled state.
Standard_EXPORT virtual void SetFlippingOptions (const Standard_Boolean theIsEnabled, const gp_Ax2& theRefPlane) = 0;
+ //! Return transformation persistence.
+ const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myTrsfPers; }
+
+ //! Set transformation persistence.
+ virtual void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers) { myTrsfPers = theTrsfPers; }
+
//! Returns true if the group contains Polygons, Triangles or Quadrangles.
bool ContainsFacet() const { return myContainsFacet; }
protected:
+ Handle(Graphic3d_TransformPers) myTrsfPers; //!< current transform persistence
Graphic3d_Structure* myStructure; //!< pointer to the parent structure
Graphic3d_BndBox4f myBounds; //!< bounding box
bool myIsClosed; //!< flag indicating closed volume
myInstancedStructure->renderGeometry (theWorkspace, theHasClosed);
}
+ const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
for (OpenGl_Structure::GroupIterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next())
{
+ Handle(Graphic3d_TransformPers) aTrsfPersistence = aGroupIter.Value()->TransformPersistence();
+ Standard_Boolean anOldCastShadows;
+ if (!aTrsfPersistence.IsNull())
+ {
+ applyPersistence (aCtx, aTrsfPersistence, anOldCastShadows, Standard_True);
+ }
+
theHasClosed = theHasClosed || aGroupIter.Value()->IsClosed();
aGroupIter.Value()->Render (theWorkspace);
+
+ if (!aTrsfPersistence.IsNull())
+ {
+ applyPersistence (aCtx, aTrsfPersistence, anOldCastShadows, Standard_False);
+ }
}
}
#endif
if (!myTrsfPers.IsNull())
{
- // temporarily disable shadows on non-3d objects
- anOldCastShadows = aCtx->ShaderManager()->SetCastShadows (false);
-
- aCtx->WorldViewState.Push();
- OpenGl_Mat4& aWorldView = aCtx->WorldViewState.ChangeCurrent();
- myTrsfPers->Apply (aCtx->Camera(),
- aCtx->ProjectionState.Current(), aWorldView,
- aCtx->VirtualViewport()[2], aCtx->VirtualViewport()[3]);
-
- #if !defined(GL_ES_VERSION_2_0)
- if (!aCtx->IsGlNormalizeEnabled()
- && aCtx->core11ffp != NULL)
- {
- const Standard_Real aScale = Graphic3d_TransformUtils::ScaleFactor<Standard_ShortReal> (aWorldView);
- if (Abs (aScale - 1.0) > Precision::Confusion())
- {
- aCtx->SetGlNormalizeEnabled (Standard_True);
- }
- }
- #endif
+ applyPersistence (aCtx, myTrsfPers, anOldCastShadows, Standard_True);
#ifdef GL_DEPTH_CLAMP
if (myTrsfPers->Mode() == Graphic3d_TMF_CameraPers
if (!myTrsfPers.IsNull())
{
- aCtx->WorldViewState.Pop();
+ applyPersistence (aCtx, myTrsfPers, anOldCastShadows, Standard_False);
aCtx->ShaderManager()->SetCastShadows (anOldCastShadows);
#ifdef GL_DEPTH_CLAMP
if (toRestoreDepthClamp) { aCtx->core11fwd->glDisable (GL_DEPTH_CLAMP); }
return new OpenGl_StructureShadow (theManager, this);
}
+// =======================================================================
+// function : applyPersistence
+// purpose :
+// =======================================================================
+void OpenGl_Structure::applyPersistence (const Handle(OpenGl_Context)& theContext,
+ const Handle(Graphic3d_TransformPers)& theTrsfPersistence,
+ Standard_Boolean& theOldCastShadows,
+ const Standard_Boolean toEnable) const
+{
+ if (toEnable)
+ {
+ // temporarily disable shadows on non-3d objects
+ theOldCastShadows = theContext->ShaderManager()->SetCastShadows (false);
+
+ theContext->WorldViewState.Push();
+ OpenGl_Mat4& aWorldView = theContext->WorldViewState.ChangeCurrent();
+ theTrsfPersistence->Apply (theContext->Camera(),
+ theContext->ProjectionState.Current(), aWorldView,
+ theContext->VirtualViewport()[2], theContext->VirtualViewport()[3]);
+
+ #if !defined(GL_ES_VERSION_2_0)
+ if (!theContext->IsGlNormalizeEnabled()
+ && theContext->core11ffp != NULL)
+ {
+ const Standard_Real aScale = Graphic3d_TransformUtils::ScaleFactor<Standard_ShortReal> (aWorldView);
+ if (Abs (aScale - 1.0) > Precision::Confusion())
+ {
+ theContext->SetGlNormalizeEnabled (Standard_True);
+ }
+ }
+ #endif
+ }
+ else
+ {
+ theContext->WorldViewState.Pop();
+ theContext->ShaderManager()->SetCastShadows (theOldCastShadows);
+ }
+}
+
//=======================================================================
//function : DumpJson
//purpose :