From 416916310a3c6dba86f8a34123c3070899cd570d Mon Sep 17 00:00:00 2001 From: clyne Date: Mon, 14 Feb 2022 08:08:02 -0700 Subject: [PATCH] Fixed #3018 - Artifacts in slice renderer kalundquist data (#3019) Floating point round off error in VAPoR::BarycentricCoordsTri() --- lib/vdc/vizutil.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/vdc/vizutil.cpp b/lib/vdc/vizutil.cpp index 07089437c1..2f2deea870 100644 --- a/lib/vdc/vizutil.cpp +++ b/lib/vdc/vizutil.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "vapor/VAssert.h" #include @@ -186,6 +187,11 @@ bool VAPoR::BarycentricCoordsTri(const double verts[], const double pt[], double lambda[2] = (d00 * d21 - d01 * d20) / denom; lambda[0] = 1.0f - lambda[1] - lambda[2]; + const double epsilon = std::numeric_limits::epsilon(); + if ((lambda[0] < 0.0) && ((lambda[0] + epsilon) >= 0.0)) lambda[0] = 0.0; + if ((lambda[1] < 0.0) && ((lambda[1] + epsilon) >= 0.0)) lambda[1] = 0.0; + if ((lambda[2] < 0.0) && ((lambda[2] + epsilon) >= 0.0)) lambda[2] = 0.0; + return (lambda[0] >= 0.0 && lambda[1] >= 0.0 && lambda[2] >= 0.0); }