From b97325c1ccd2b297459d6593a352c9d64641cc59 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 16 Oct 2007 19:46:22 +0000 Subject: [PATCH] more fixes --- panda/src/mathutil/plane_src.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/panda/src/mathutil/plane_src.cxx b/panda/src/mathutil/plane_src.cxx index 73e0861d9c..65ec2b9ad4 100644 --- a/panda/src/mathutil/plane_src.cxx +++ b/panda/src/mathutil/plane_src.cxx @@ -136,8 +136,21 @@ intersects_parabola(FLOATTYPE &t1, FLOATTYPE &t2, FLOATTYPE c = normal.dot(parabola.get_c()) + _v.v._3; if (IS_NEARLY_ZERO(a)) { - // No intersection. - return false; + // It's not quadratic. The equation is actually: + // b * t + c == 0. + // Which means: + // t = -c / b. + + if (IS_NEARLY_ZERO(b)) { + // It's not even linear. The parabola must be completely + // parallel to the plane, or if c == 0, it's completely within + // the plane. In both cases, we'll call it no intersection. + return false; + } + + t1 = -c / b; + t2 = t1; + return true; } // Now use the quadratic equation to solve for t.