From a3dbfab54b70a3888810dc2e237a14ce2ba1f2b2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 17 Oct 2022 17:58:57 +0200 Subject: [PATCH] - return some invalid but recognizable magic value when IntersectLines is being passed two collinear lines. This actually should check if the two lines are identical but since this is rather expensive and rarely needed it's better handled by returning a distinct value the caller can handle if needed. --- source/common/utility/geometry.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/utility/geometry.h b/source/common/utility/geometry.h index 882a87eed..cbe0fc72d 100644 --- a/source/common/utility/geometry.h +++ b/source/common/utility/geometry.h @@ -141,7 +141,7 @@ inline double InterceptLineSegments(double v2x, double v2y, double v2dx, double double den = v1dy * v2dx - v1dx * v2dy; if (den == 0) - return 0; // parallel + return -2 * (double)FLT_MAX; // parallel (return a magic value different from everything else, just in case it needs to be handled) if (forcansee && den < 0) // cansee does this added check here, aside from that its logic is virtually the same. return -1; // hitting the backside