From 88ac9032e4a53407c569d6eb7c67619924daf296 Mon Sep 17 00:00:00 2001 From: Fate Bussey Date: Wed, 13 Dec 2023 13:50:26 -0500 Subject: cone intersection fixes ONGOING --- src/intersect/intersect.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/intersect') diff --git a/src/intersect/intersect.cpp b/src/intersect/intersect.cpp index 69512e3..71cae49 100644 --- a/src/intersect/intersect.cpp +++ b/src/intersect/intersect.cpp @@ -59,7 +59,7 @@ glm::vec4 intersectCone( isHit = false; float t = FINF; // updated to 4d - // x^2 + y^2 - z^2 - w^2= 0, conic top + // x^2 + z^2 - y^2 - w^2= 0, conic top float radius = 0.5f; float a = d.x*d.x + d.z*d.z - .25f*(d.y*d.y) - .25f*(d[3]*d[3]); float b = 2.f*(p.x*d.x + p.z*d.z) - .5f*(p.y*d.y) + .25f*d.y - .5f*(p[3]*d[3]) + .25f*d[3]; @@ -97,7 +97,8 @@ glm::vec4 intersectCone( auto pwBase = p + twBase * d; if ( twBase > 0 && - pwBase.x*pwBase.x + pwBase.z*pwBase.z <= pwBase.y*pwBase.y + pwBase.x*pwBase.x + pwBase.z*pwBase.z <= pwBase.y*pwBase.y -.25f && + pwBase.y >= -.5f && pwBase.y <= .5f ) { t = std::min(t, twBase); @@ -108,7 +109,8 @@ glm::vec4 intersectCone( auto pyBase = p + tyBase * d; if ( tyBase > 0 && - pyBase.x*pyBase.x + pyBase.z*pyBase.z <= pyBase[3]*pyBase[3] + pyBase.x*pyBase.x + pyBase.z*pyBase.z <= pyBase[3]*pyBase[3] -.25f && + pyBase[3] >= -.5f && pyBase[3] <= .5f ) { t = std::min(t, tyBase); -- cgit v1.2.3-70-g09d2