1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0025276: Visualization - Lighting is broken if some kinds of transformation applied to a shape

In order to solve the problem, triangle vertices order is inverted in
mirrored mesh (triangulation). Mesh considered to be mirrored if its
transformation matrix determinant is less than 0.

To handle AIS object mirror transformations "Mirrored" flag stored in
OpenGl_Structure. If this flag is enabled, glFrontFace (GL_CW) applied
before the draw call.

New DRAW commands for visualization level transformations added.
This commit is contained in:
duv
2014-09-26 14:41:51 +04:00
committed by bugmaster
parent c60370656c
commit 7d9e854bdc
9 changed files with 402 additions and 77 deletions

View File

@@ -149,6 +149,10 @@ namespace
continue;
}
const gp_Trsf& aTrsf = aLoc.Transformation();
// Determinant of transform matrix less then 0 means that mirror transform applied.
Standard_Boolean isMirrored = aTrsf.VectorialPart().Determinant() < 0;
Poly_Connect aPolyConnect (aT);
// Extracts vertices & normals from nodes
const TColgp_Array1OfPnt& aNodes = aT->Nodes();
@@ -170,7 +174,8 @@ namespace
if (!aLoc.IsIdentity())
{
aPoint.Transform (aTrsf);
aNormals (aNodeIter).Transform (aTrsf);
aNormals (aNodeIter) = aNormals (aNodeIter).Transformed (aTrsf);
}
if (theHasTexels && aUVNodes.Upper() == aNodes.Upper())
@@ -190,7 +195,7 @@ namespace
Standard_Integer anIndex[3];
for (Standard_Integer aTriIter = 1; aTriIter <= aT->NbTriangles(); ++aTriIter)
{
if (aFace.Orientation() == TopAbs_REVERSED)
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
{
aTriangles (aTriIter).Get (anIndex[0], anIndex[2], anIndex[1]);
}