]> OCCT Git - occt.git/commitdiff
0032218: Visualization - move V3d_View::ShadingModel() property to Graphic3d_Renderin...
authorkgv <kgv@opencascade.com>
Tue, 16 Mar 2021 17:58:39 +0000 (20:58 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 17 Mar 2021 16:41:25 +0000 (19:41 +0300)
src/Graphic3d/Graphic3d_CView.cxx
src/Graphic3d/Graphic3d_CView.hxx
src/Graphic3d/Graphic3d_RenderingParams.cxx
src/Graphic3d/Graphic3d_RenderingParams.hxx
src/OpenGl/OpenGl_View.cxx
src/OpenGl/OpenGl_View_Raytrace.cxx
src/OpenGl/OpenGl_Workspace.cxx
src/V3d/V3d_View.cxx
src/V3d/V3d_Viewer.cxx
src/V3d/V3d_Viewer.hxx

index 6a6fb0821128b8d69ff8118268bd4f34892f5b85..2a2a20820b78ef2501c9d4d46dfbdd69521c598d 100644 (file)
@@ -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())
index 4f87d9b116ad3aa5679129403fcbaa36c947134e..8e17165b7e4770cd0b537eed8704d702d9af32be 100644 (file)
@@ -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;
 
index dbf05ea1b29cdd6441c9307b20b783752eaf7a2b..57a941386f423782f2a420a44f9248be1198fb0d 100644 (file)
@@ -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)
 
index 48aebdef11d8f4a97d1e4a18c49aa61ce2c36ad0..602967d2a011de435e5d070390c489e9d94e488e 100644 (file)
@@ -22,6 +22,7 @@
 #include <Graphic3d_RenderingMode.hxx>
 #include <Graphic3d_StereoMode.hxx>
 #include <Graphic3d_ToneMappingMethod.hxx>
+#include <Graphic3d_TypeOfShadingModel.hxx>
 #include <Graphic3d_Vec4.hxx>
 
 //! 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
index c386352b10760e77c433ea24db92ed3ce67e2f72..2dbf9ce7e802027688f6b74e352469aee4f4b164 100644 (file)
@@ -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)
index c3cb44a7ce04a004e22b67e25e8a8316487bf055..399fb5637556810b955a703f9d4edb4b7f7a560e 100644 (file)
@@ -2424,7 +2424,7 @@ Standard_Boolean OpenGl_View::updateRaytraceLightSources (const OpenGl_Mat4& the
 {
   std::vector<Handle(Graphic3d_CLight)> 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);
index fc595a42dc4b744c0514fe9a8b6cc05790934fa6..0f4ec8f69811272ef0a8fedc5edcc69376251690 100644 (file)
@@ -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())
   {
index 08b4a0358474a5b84226542be7acf6861d00f6fe..058d40caed583c6f6277c674e9cd5e137d94c278 100644 (file)
@@ -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());
index af7faed0a40e70166b5e4047ecb054f997f5d186..4306c26a9aa2ff54d81f5ed1c92b2c396662a0c9 100644 (file)
@@ -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)
index 73c59c9af3d6ca9e81b1a56a937d92ad2106ac0f..a51543ea06bd2d0cbc86f0f6fd95eaeeb773a8af 100644 (file)
@@ -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;