1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0032188: Visualization, Graphic3d_Aspects - define backface culling using Graphic3d_TypeOfBackfacingModel

Graphic3d_Aspects::ToSuppressBackFaces() bool flag has been replaced by
Graphic3d_Aspects::FaceCulling() property defined by Graphic3d_TypeOfBackfacingModel enumeration.

Graphic3d_TypeOfBackfacingModel_Auto corresponds to old ToSuppressBackFaces()==TRUE;
Graphic3d_TypeOfBackfacingModel_DoubleSided corresponds to old ToSuppressBackFaces()==FALSE;
Graphic3d_TypeOfBackfacingModel_BackCulled allows enabling back face culling regardless of Graphic3d_Group::IsClosed() flag.

XCAFDoc_VisMaterial::IsDoubleSided() bool flag has been replaced by
XCAFDoc_VisMaterial::FaceCulling() property defined by Graphic3d_TypeOfBackfacingModel enumeration.

glTF reader now maps "doubleSided" material flag into
Graphic3d_TypeOfBackfacingModel_BackCulled (forced back face culling) and
Graphic3d_TypeOfBackfacingModel_Auto (e.g. practically doubleSided as there is no closed/open info in glTF).

glTF writer by default writes materials as "doubleSided" save the Graphic3d_TypeOfBackfacingModel_BackCulled property set
(in future, extra logic might written for automatically defining singleSided materials for Solid B-Rep objects).

Removed obsolete unused types V3d_TypeOfPickCamera, V3d_TypeOfPickLight, V3d_TypeOfRepresentation, and V3d_Coordinate.
Deprecated types V3d_TypeOfBackfacingModel, V3d_TypeOfLight, and V3d_TypeOfShadingModel.
This commit is contained in:
kgv
2021-03-01 23:25:21 +03:00
committed by bugmaster
parent 42ddd0028c
commit 7fd4958d45
28 changed files with 202 additions and 255 deletions

View File

@@ -252,11 +252,15 @@ Standard_Boolean XmlMXCAFDoc_VisMaterialDriver::Paste (const XmlObjMgt_Persisten
Handle(XCAFDoc_VisMaterial) aMat = Handle(XCAFDoc_VisMaterial)::DownCast(theTarget);
const XmlObjMgt_DOMString aDoubleSidedStr = theSource.Element().getAttribute (::IsDoubleSided());
Standard_Integer isDoubleSided = 1;
aDoubleSidedStr.GetInteger (isDoubleSided);
Standard_Integer aDoubleSidedInt = 1;
aDoubleSidedStr.GetInteger (aDoubleSidedInt);
Standard_ShortReal anAlphaCutOff = 0.5f;
readReal (theSource, ::AlphaCutOff(), anAlphaCutOff);
aMat->SetDoubleSided (isDoubleSided != 0);
aMat->SetFaceCulling (aDoubleSidedInt == 1
? Graphic3d_TypeOfBackfacingModel_DoubleSided
: (aDoubleSidedInt == 2
? Graphic3d_TypeOfBackfacingModel_BackCulled
: Graphic3d_TypeOfBackfacingModel_Auto));
aMat->SetAlphaMode (alphaModeFromString (theSource.Element().getAttribute (::AlphaMode()).GetString()), anAlphaCutOff);
Quantity_ColorRGBA aBaseColor;
@@ -303,8 +307,12 @@ void XmlMXCAFDoc_VisMaterialDriver::Paste (const Handle(TDF_Attribute)& theSourc
XmlObjMgt_SRelocationTable& ) const
{
Handle(XCAFDoc_VisMaterial) aMat = Handle(XCAFDoc_VisMaterial)::DownCast(theSource);
theTarget.Element().setAttribute (::IsDoubleSided(), aMat->IsDoubleSided() ? 1 : 0);
Standard_Integer aDoubleSidedInt = aMat->FaceCulling() == Graphic3d_TypeOfBackfacingModel_DoubleSided
? 1
: (aMat->FaceCulling() == Graphic3d_TypeOfBackfacingModel_BackCulled
? 2
: 0);
theTarget.Element().setAttribute (::IsDoubleSided(), aDoubleSidedInt);
theTarget.Element().setAttribute (::AlphaMode(), alphaModeToString (aMat->AlphaMode()));
writeReal (theTarget, ::AlphaCutOff(), aMat->AlphaCutOff());
if (aMat->HasPbrMaterial())