]> OCCT Git - occt.git/commitdiff
0032546: Data Exchange, XCAF - mark material as defined XCAFDoc_VisMaterialPBR::IsDef...
authorkgv <kgv@opencascade.com>
Mon, 30 Aug 2021 17:53:33 +0000 (20:53 +0300)
committersmoskvin <smoskvin@opencascade.com>
Tue, 31 Aug 2021 17:05:37 +0000 (20:05 +0300)
XCAFDoc_VisMaterialCommon and XCAFDoc_VisMaterialPBR default constructors now set IsDefined property to TRUE.
So that it is required to set IsDefined=false explicitly to create an undefined material,
which is done by XCAFDoc_VisMaterial constructor.

Existing application code shouldn't require any modifications in most cases
(IsDefined=true required before to setup material could be now removed).

src/XCAFDoc/XCAFDoc_VisMaterial.cxx
src/XCAFDoc/XCAFDoc_VisMaterial.hxx
src/XCAFDoc/XCAFDoc_VisMaterialCommon.hxx
src/XCAFDoc/XCAFDoc_VisMaterialPBR.hxx

index 847289eb09fce5874cae660c6f6c5cc7c6e463a4..9e223b9f5107d01ac37de19d2d8283b9b3350c39 100644 (file)
@@ -40,7 +40,8 @@ XCAFDoc_VisMaterial::XCAFDoc_VisMaterial()
   myAlphaCutOff (0.5f),
   myFaceCulling (Graphic3d_TypeOfBackfacingModel_Auto)
 {
-  //
+  myPbrMat   .IsDefined = false;
+  myCommonMat.IsDefined = false;
 }
 
 //=======================================================================
index a94a81a5076d9bb1855b719a48c686a51692741b..92456cf631ce77613f9e2d3ecdfafb7652580f48 100644 (file)
@@ -69,29 +69,41 @@ public:
   //! Fill in graphic aspects.
   Standard_EXPORT void FillAspect (const Handle(Graphic3d_Aspects)& theAspect) const;
 
-  //! Return TRUE if metal-roughness PBR material is defined.
+  //! Return TRUE if metal-roughness PBR material is defined; FALSE by default.
   Standard_Boolean HasPbrMaterial() const { return myPbrMat.IsDefined; }
 
   //! Return metal-roughness PBR material.
+  //! Note that default constructor creates an empty material (@sa XCAFDoc_VisMaterialPBR::IsDefined).
   const XCAFDoc_VisMaterialPBR& PbrMaterial() const { return myPbrMat; }
 
   //! Setup metal-roughness PBR material.
   Standard_EXPORT void SetPbrMaterial (const XCAFDoc_VisMaterialPBR& theMaterial);
 
   //! Setup undefined metal-roughness PBR material.
-  void UnsetPbrMaterial() { SetPbrMaterial (XCAFDoc_VisMaterialPBR()); }
+  void UnsetPbrMaterial()
+  {
+    XCAFDoc_VisMaterialPBR anEmpty;
+    anEmpty.IsDefined = false;
+    SetPbrMaterial (anEmpty);
+  }
 
-  //! Return TRUE if common material is defined.
+  //! Return TRUE if common material is defined; FALSE by default.
   Standard_Boolean HasCommonMaterial() const { return myCommonMat.IsDefined; }
 
   //! Return common material.
+  //! Note that default constructor creates an empty material (@sa XCAFDoc_VisMaterialCommon::IsDefined).
   const XCAFDoc_VisMaterialCommon& CommonMaterial() const { return myCommonMat; }
 
   //! Setup common material.
   Standard_EXPORT void SetCommonMaterial (const XCAFDoc_VisMaterialCommon& theMaterial);
 
   //! Setup undefined common material.
-  void UnsetCommonMaterial() { SetCommonMaterial (XCAFDoc_VisMaterialCommon()); }
+  void UnsetCommonMaterial()
+  {
+    XCAFDoc_VisMaterialCommon anEmpty;
+    anEmpty.IsDefined = false;
+    SetCommonMaterial (anEmpty);
+  }
 
   //! Return base color.
   Standard_EXPORT Quantity_ColorRGBA BaseColor() const;
index 22cb88a336dae4de0dc73b8b6bdd1edcf8646dde..88148f2dfa64c856acf069ee45cc67ec2cabfe9c 100644 (file)
@@ -33,7 +33,7 @@ struct XCAFDoc_VisMaterialCommon
   Quantity_Color          EmissiveColor;   //!< emission color
   Standard_ShortReal      Shininess;       //!< shininess value
   Standard_ShortReal      Transparency;    //!< transparency value within [0, 1] range with 0 meaning opaque
-  Standard_Boolean        IsDefined;       //!< defined flag; FALSE by default
+  Standard_Boolean        IsDefined;       //!< defined flag; TRUE by default
 
   //! Empty constructor.
   XCAFDoc_VisMaterialCommon()
@@ -43,7 +43,7 @@ struct XCAFDoc_VisMaterialCommon
     EmissiveColor(0.0, 0.0, 0.0, Quantity_TOC_RGB),
     Shininess (1.0f),
     Transparency (0.0f),
-    IsDefined (Standard_False) {}
+    IsDefined (Standard_True) {}
 
   //! Compare two materials.
   Standard_Boolean IsEqual (const XCAFDoc_VisMaterialCommon& theOther) const
index 39bd90abfb9e3ba20a542f6807f9f73359365fb3..123a815a87a859be6d65c367de15afc1c825114b 100644 (file)
@@ -33,7 +33,7 @@ struct XCAFDoc_VisMaterialPBR
   Standard_ShortReal      Metallic;                 //!< metalness  (or scale factor to the texture) within range [0.0, 1.0]; 1.0 by default
   Standard_ShortReal      Roughness;                //!< roughness  (or scale factor to the texture) within range [0.0, 1.0]; 1.0 by default
   Standard_ShortReal      RefractionIndex;          //!< IOR (index of refraction) within range [1.0, 3.0]; 1.5 by default
-  Standard_Boolean        IsDefined;                //!< defined flag; FALSE by default
+  Standard_Boolean        IsDefined;                //!< defined flag; TRUE by default
 
   //! Empty constructor.
   XCAFDoc_VisMaterialPBR()
@@ -42,7 +42,7 @@ struct XCAFDoc_VisMaterialPBR
     Metallic  (1.0f),
     Roughness (1.0f),
     RefractionIndex (1.5f),
-    IsDefined (Standard_False) {}
+    IsDefined (Standard_True) {}
 
   //! Compare two materials.
   Standard_Boolean IsEqual (const XCAFDoc_VisMaterialPBR& theOther) const