1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0025811: Visualization - Incorrect texture mapping on faces with reversed orientation

Added section in StdPrs_ShadedShape to correct UV orientation on face triangulation whose orientation is reversed.
Expanded test cases.
This commit is contained in:
drochalo 2023-09-26 10:00:41 +01:00
parent 83bb2a329d
commit 8910dd9f80
2 changed files with 73 additions and 1 deletions

View File

@ -192,6 +192,7 @@ namespace
}
const Standard_Integer aDecal = anArray->VertexNumber();
Standard_Real aMaxX = -FLT_MAX, aMinX = FLT_MAX;
for (Standard_Integer aNodeIter = 1; aNodeIter <= aT->NbNodes(); ++aNodeIter)
{
aPoint = aT->Node (aNodeIter);
@ -199,13 +200,19 @@ namespace
if ((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored)
{
aNorm.Reverse();
if (aT->HasUVNodes())
{
gp_Pnt2d aTmpPnt = aT->UVNode(aNodeIter);
if (aMaxX < aTmpPnt.X()) { aMaxX = aTmpPnt.X(); }
if (aMinX > aTmpPnt.X()) { aMinX = aTmpPnt.X(); }
}
}
if (!aLoc.IsIdentity())
{
aPoint.Transform (aTrsf);
aNorm .Transform (aTrsf);
}
if (theHasTexels && aT->HasUVNodes())
{
const gp_Pnt2d aNode2d = aT->UVNode (aNodeIter);
@ -221,6 +228,18 @@ namespace
}
}
// changes uvs for reversed faces depending on number of vertex
// by flipping the uv coordinates according to face normal
if (((aFace.Orientation() == TopAbs_REVERSED) ^ isMirrored) && aT->HasUVNodes())
{
for (Standard_Integer anIndex = 1; anIndex <= aT->NbNodes(); anIndex++)
{
gp_Pnt2d aTmpPnt = aT->UVNode (anIndex);
aTmpPnt.SetX (aMaxX + aMinX - aTmpPnt.X());
aT->SetUVNode (anIndex, aTmpPnt);
}
}
// Fill array with vertex and edge visibility info
Standard_Integer anIndex[3];
for (Standard_Integer aTriIter = 1; aTriIter <= aT->NbTriangles(); ++aTriIter)

53
tests/v3d/bugs/bug25811 Normal file
View File

@ -0,0 +1,53 @@
puts "========"
puts "0025811: Visualization - Incorrect texture mapping on faces with reversed orientation"
puts "========"
puts ""
pload MODELING VISUALIZATION
vclear
vinit View1
vsetdispmode 1
vaxo
box b 10 10 10
vdisplay b
#dump image off textured box
vtexture b [locate_data_file bug25809_salome.png]
vfit
vdump $imagedir/${casename}_box.png
vviewparams -scale 60.0 -proj 1.0 -1.0 1.0 -up 0.0 0.0 1.0 -at 0 10 0
vrotate 3.14 0 0
vdump $imagedir/${casename}_box2.png
#dump image of capped sphere
vclear
psphere s 15 -60 60 90
vdisplay s
vtexture s [locate_data_file bug25809_salome.png]
vviewparams -scale 40.0 -proj 1.0 1.0 1.0 -up 0.0 0.0 1.0 -at 0 0 0
vfit
vdump $imagedir/${casename}_sphere.png
vrotate 3.14 0 0
vfit
vdump $imagedir/${casename}_sphere2.png
vviewparams -scale 40.0 -proj 1.0 1.0 1.0 -up 1.0 1.0 0.0 -at 0 0 0
vrotate 0 1 0
vfit
vdump $imagedir/${casename}_sphere3.png
vrotate 0 3.14 0
vfit
vdump $imagedir/${casename}_sphere4.png
#dump image off textured cylinder
vclear
pcylinder c 3 10
vdisplay c
vtexture c [locate_data_file bug25809_salome.png]
vviewparams -scale 60.0 -proj 1.0 1.0 1.0 -up 0.0 0.0 1.0 -at 0 0 5
vfit
vdump $imagedir/${casename}_cylinder.png
vviewparams -scale 60.0 -proj 1.0 1.0 1.0 -up 0.0 1.0 0.0 -at 0 0 5
vfit
vdump $imagedir/${casename}_cylinder2.png
vrotate 0 0 3.14
vfit
vdump $imagedir/${casename}_cylinder3.png