Skip to content

Commit 7951cda

Browse files
committed
[hist3d] use epsilon in DrawFaceMode2
There order of triangles drawing defined by calculated Z value. For many triangles such Z value is very close to each other and "flip" on different platforms because of float precision. To exclude such flipping, add minimal epsilon in Z comparasion. When both Z are close to each other render order of triangles is not important
1 parent 7ca45b6 commit 7951cda

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

hist/histpainter/src/TPainter3dAlgorithms.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const Double_t kRad = TMath::ATan(1)*Double_t(4)/Double_t(180);
4444
const Double_t kFdel = 0.;
4545
const Double_t kDel = 0.0001;
4646
const Double_t kEps = 1e-9; // exclude such small segments
47+
const Double_t kEpsFaceMode2 = 1e-12; // minimal Z change in DrawFaceMode2
4748
const Int_t kNiso = 4;
4849
const Int_t kNmaxp = kNiso*13;
4950
const Int_t kNmaxt = kNiso*12;
@@ -478,7 +479,10 @@ void TPainter3dAlgorithms::DrawFaceMode2(Int_t *, Double_t *xyz, Int_t np, Int_t
478479
Int_t k1 = 0, k2 = 2;
479480
Double_t z1 = (x[k1+1] - x[k1+0])*(y[k1+2] - y[k1+1]) - (y[k1+1] - y[k1+0])*(x[k1+2] - x[k1+1]);
480481
Double_t z2 = (x[k2+1] - x[k2+0])*(y[k2+2] - y[k2+1]) - (y[k2+1] - y[k2+0])*(x[k2+2] - x[k2+1]);
481-
if (z1 > z2) { k1 = 2; k2 = 0; }
482+
// S.Linev Exclude flipping around same z
483+
// only by 'significant' difference change rendering order
484+
if (z1 > z2 + kEpsFaceMode2) { k1 = 2; k2 = 0; }
485+
482486
FillPolygon(3, &p3[3*k1], &ttt[k1]);
483487
if (fMesh == 1) { // Draw border
484488
gPad->PaintPolyLine(3, &x[k1], &y[k1]);

0 commit comments

Comments
 (0)