From 114db5a5ce6d25b3d5dd460e0e14a6fdc5c90cb0 Mon Sep 17 00:00:00 2001 From: kgv Date: Tue, 16 Mar 2021 20:58:39 +0300 Subject: [PATCH] 0032218: Visualization - move V3d_View::ShadingModel() property to Graphic3d_RenderingParams --- src/Graphic3d/Graphic3d_CView.cxx | 4 +--- src/Graphic3d/Graphic3d_CView.hxx | 3 +-- src/Graphic3d/Graphic3d_RenderingParams.cxx | 1 + src/Graphic3d/Graphic3d_RenderingParams.hxx | 3 +++ src/OpenGl/OpenGl_View.cxx | 10 +++++----- src/OpenGl/OpenGl_View_Raytrace.cxx | 2 +- src/OpenGl/OpenGl_Workspace.cxx | 4 ++-- src/V3d/V3d_View.cxx | 1 - src/V3d/V3d_Viewer.cxx | 4 +--- src/V3d/V3d_Viewer.hxx | 5 ++--- 10 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/Graphic3d/Graphic3d_CView.cxx b/src/Graphic3d/Graphic3d_CView.cxx index 6a6fb08211..2a2a20820b 100644 --- a/src/Graphic3d/Graphic3d_CView.cxx +++ b/src/Graphic3d/Graphic3d_CView.cxx @@ -32,7 +32,6 @@ Graphic3d_CView::Graphic3d_CView (const Handle(Graphic3d_StructureManager)& theM myIsInComputedMode (Standard_False), myIsActive (Standard_False), myIsRemoved (Standard_False), - myShadingModel (Graphic3d_TOSM_FRAGMENT), myBackfacing (Graphic3d_TypeOfBackfacingModel_Auto), myVisualization (Graphic3d_TOV_WIREFRAME), myUnitFactor (1.0) @@ -1098,7 +1097,7 @@ void Graphic3d_CView::SetShadingModel (Graphic3d_TypeOfShadingModel theModel) throw Standard_ProgramError ("Graphic3d_CView::SetShadingModel() - attempt to set invalid Shading Model!"); } - myShadingModel = theModel; + myRenderParams.ShadingModel = theModel; } // ======================================================================= @@ -1441,7 +1440,6 @@ void Graphic3d_CView::DumpJson (Standard_OStream& theOStream, Standard_Integer t OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsActive) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsRemoved) - OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myShadingModel) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVisualization) OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myBackXRCamera.get()) diff --git a/src/Graphic3d/Graphic3d_CView.hxx b/src/Graphic3d/Graphic3d_CView.hxx index 4f87d9b116..8e17165b7e 100644 --- a/src/Graphic3d/Graphic3d_CView.hxx +++ b/src/Graphic3d/Graphic3d_CView.hxx @@ -100,7 +100,7 @@ public: public: //! Returns default Shading Model of the view; Graphic3d_TOSM_FRAGMENT by default. - Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; } + Graphic3d_TypeOfShadingModel ShadingModel() const { return myRenderParams.ShadingModel; } //! Sets default Shading Model of the view. //! Will throw an exception on attempt to set Graphic3d_TOSM_DEFAULT. @@ -570,7 +570,6 @@ protected: Standard_Boolean myIsInComputedMode; Standard_Boolean myIsActive; Standard_Boolean myIsRemoved; - Graphic3d_TypeOfShadingModel myShadingModel; Graphic3d_TypeOfBackfacingModel myBackfacing; Graphic3d_TypeOfVisualization myVisualization; diff --git a/src/Graphic3d/Graphic3d_RenderingParams.cxx b/src/Graphic3d/Graphic3d_RenderingParams.cxx index dbf05ea1b2..57a941386f 100644 --- a/src/Graphic3d/Graphic3d_RenderingParams.cxx +++ b/src/Graphic3d/Graphic3d_RenderingParams.cxx @@ -24,6 +24,7 @@ void Graphic3d_RenderingParams::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const { OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Method) + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, ShadingModel) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, TransparencyMethod) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, LineFeather) diff --git a/src/Graphic3d/Graphic3d_RenderingParams.hxx b/src/Graphic3d/Graphic3d_RenderingParams.hxx index 48aebdef11..602967d2a0 100644 --- a/src/Graphic3d/Graphic3d_RenderingParams.hxx +++ b/src/Graphic3d/Graphic3d_RenderingParams.hxx @@ -22,6 +22,7 @@ #include #include #include +#include #include //! Helper class to store rendering parameters. @@ -94,6 +95,7 @@ public: //! Creates default rendering parameters. Graphic3d_RenderingParams() : Method (Graphic3d_RM_RASTERIZATION), + ShadingModel (Graphic3d_TOSM_FRAGMENT), TransparencyMethod (Graphic3d_RTM_BLEND_UNORDERED), LineFeather (1.0f), // PBR parameters @@ -186,6 +188,7 @@ public: public: Graphic3d_RenderingMode Method; //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default + Graphic3d_TypeOfShadingModel ShadingModel; //!< specified default shading model, Graphic3d_TOSM_FRAGMENT by default Graphic3d_RenderTransparentMethod TransparencyMethod; //!< specifies rendering method for transparent graphics Standard_ShortReal LineFeather; //!< line feater width in pixels (> 0.0), 1.0 by default; //! high values produce blurred results, small values produce sharp (aliased) edges diff --git a/src/OpenGl/OpenGl_View.cxx b/src/OpenGl/OpenGl_View.cxx index c386352b10..2dbf9ce7e8 100644 --- a/src/OpenGl/OpenGl_View.cxx +++ b/src/OpenGl/OpenGl_View.cxx @@ -1162,8 +1162,8 @@ bool OpenGl_View::prepareFrameBuffers (Graphic3d_Camera::Projection& theProj) } // process PBR environment - if (myShadingModel == Graphic3d_TOSM_PBR - || myShadingModel == Graphic3d_TOSM_PBR_FACET) + if (myRenderParams.ShadingModel == Graphic3d_TOSM_PBR + || myRenderParams.ShadingModel == Graphic3d_TOSM_PBR_FACET) { if (!myPBREnvironment.IsNull() && myPBREnvironment->SizesAreDifferent (myRenderParams.PbrEnvPow2Size, @@ -1396,7 +1396,7 @@ bool OpenGl_View::prepareFrameBuffers (Graphic3d_Camera::Projection& theProj) } // allocate shadow maps - const Handle(Graphic3d_LightSet)& aLights = myShadingModel == Graphic3d_TOSM_UNLIT ? myNoShadingLight : myLights; + const Handle(Graphic3d_LightSet)& aLights = myRenderParams.ShadingModel == Graphic3d_TOSM_UNLIT ? myNoShadingLight : myLights; if (!aLights.IsNull()) { aLights->UpdateRevision(); @@ -2135,7 +2135,7 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection, myBVHSelector.CacheClipPtsProjections(); const Handle(OpenGl_ShaderManager)& aManager = aContext->ShaderManager(); - const Handle(Graphic3d_LightSet)& aLights = myShadingModel == Graphic3d_TOSM_UNLIT ? myNoShadingLight : myLights; + const Handle(Graphic3d_LightSet)& aLights = myRenderParams.ShadingModel == Graphic3d_TOSM_UNLIT ? myNoShadingLight : myLights; Standard_Size aLightsRevision = 0; if (!aLights.IsNull()) { @@ -2203,7 +2203,7 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection, } #endif - aManager->SetShadingModel (OpenGl_ShaderManager::PBRShadingModelFallback (myShadingModel, checkPBRAvailability())); + aManager->SetShadingModel (OpenGl_ShaderManager::PBRShadingModelFallback (myRenderParams.ShadingModel, checkPBRAvailability())); // Redraw 3d scene if (theProjection == Graphic3d_Camera::Projection_MonoLeftEye) diff --git a/src/OpenGl/OpenGl_View_Raytrace.cxx b/src/OpenGl/OpenGl_View_Raytrace.cxx index c3cb44a7ce..399fb56375 100644 --- a/src/OpenGl/OpenGl_View_Raytrace.cxx +++ b/src/OpenGl/OpenGl_View_Raytrace.cxx @@ -2424,7 +2424,7 @@ Standard_Boolean OpenGl_View::updateRaytraceLightSources (const OpenGl_Mat4& the { std::vector aLightSources; Graphic3d_Vec4 aNewAmbient (0.0f); - if (myShadingModel != Graphic3d_TOSM_UNLIT + if (myRenderParams.ShadingModel != Graphic3d_TOSM_UNLIT && !myLights.IsNull()) { aNewAmbient.SetValues (myLights->AmbientColor().rgb(), 0.0f); diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index fc595a42dc..0f4ec8f698 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -340,8 +340,8 @@ const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects (bool theToBindTextures) myGlContext->BindTextures (aTextureSet, Handle(OpenGl_ShaderProgram)()); } - if ((myView->myShadingModel == Graphic3d_TOSM_PBR - || myView->myShadingModel == Graphic3d_TOSM_PBR_FACET) + if ((myView->ShadingModel() == Graphic3d_TOSM_PBR + || myView->ShadingModel() == Graphic3d_TOSM_PBR_FACET) && !myView->myPBREnvironment.IsNull() && myView->myPBREnvironment->IsNeededToBeBound()) { diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index 08b4a03584..058d40caed 100644 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -96,7 +96,6 @@ V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const V3d_TypeOfView th SetCamera (aCamera); SetAxis (0.,0.,0.,1.,1.,1.); SetVisualization (theViewer->DefaultVisualization()); - SetShadingModel (theViewer->DefaultShadingModel()); SetTwist (0.); SetAt (0.,0.,0.); SetProj (theViewer->DefaultViewProj()); diff --git a/src/V3d/V3d_Viewer.cxx b/src/V3d/V3d_Viewer.cxx index af7faed0a4..4306c26a9a 100644 --- a/src/V3d/V3d_Viewer.cxx +++ b/src/V3d/V3d_Viewer.cxx @@ -47,7 +47,6 @@ V3d_Viewer::V3d_Viewer (const Handle(Graphic3d_GraphicDriver)& theDriver) myViewSize (1000.0), myViewProj (V3d_XposYnegZpos), myVisualization (V3d_ZBUFFER), - myShadingModel (Graphic3d_TOSM_VERTEX), myDefaultTypeOfView (V3d_ORTHOGRAPHIC), myComputedMode (Standard_True), myDefaultComputedMode (Standard_False), @@ -58,7 +57,7 @@ V3d_Viewer::V3d_Viewer (const Handle(Graphic3d_GraphicDriver)& theDriver) myGridEcho (Standard_True), myGridEchoLastVert (ShortRealLast(), ShortRealLast(), ShortRealLast()) { - // + myDefaultRenderingParams.ShadingModel = Graphic3d_TOSM_VERTEX; } // ======================================================================== @@ -901,7 +900,6 @@ void V3d_Viewer::DumpJson (Standard_OStream& theOStream, Standard_Integer theDep OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myViewSize) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myViewProj) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVisualization) - OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myShadingModel) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDefaultTypeOfView) OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDefaultRenderingParams) diff --git a/src/V3d/V3d_Viewer.hxx b/src/V3d/V3d_Viewer.hxx index 73c59c9af3..a51543ea06 100644 --- a/src/V3d/V3d_Viewer.hxx +++ b/src/V3d/V3d_Viewer.hxx @@ -167,10 +167,10 @@ public: void SetDefaultVisualization (const V3d_TypeOfVisualization theType) { myVisualization = theType; } //! Returns the default type of Shading - Graphic3d_TypeOfShadingModel DefaultShadingModel() const { return myShadingModel; } + Graphic3d_TypeOfShadingModel DefaultShadingModel() const { return myDefaultRenderingParams.ShadingModel; } //! Gives the default type of SHADING. - void SetDefaultShadingModel (const Graphic3d_TypeOfShadingModel theType) { myShadingModel = theType; } + void SetDefaultShadingModel (const Graphic3d_TypeOfShadingModel theType) { myDefaultRenderingParams.ShadingModel = theType; } //! Returns the default type of View (orthographic or perspective projection) to be returned by CreateView() method. V3d_TypeOfView DefaultTypeOfView() const { return myDefaultTypeOfView; } @@ -516,7 +516,6 @@ private: Standard_Real myViewSize; V3d_TypeOfOrientation myViewProj; V3d_TypeOfVisualization myVisualization; - Graphic3d_TypeOfShadingModel myShadingModel; V3d_TypeOfView myDefaultTypeOfView; Graphic3d_RenderingParams myDefaultRenderingParams;