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/.DS_Store | Bin 8196 -> 0 bytes src/illuminate/illuminate.cpp | 2 +- src/intersect/intersect.cpp | 8 +++++--- src/raytracer/raytracer.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) delete mode 100644 src/.DS_Store (limited to 'src') diff --git a/src/.DS_Store b/src/.DS_Store deleted file mode 100644 index 5d99fdf..0000000 Binary files a/src/.DS_Store and /dev/null differ diff --git a/src/illuminate/illuminate.cpp b/src/illuminate/illuminate.cpp index a651924..d031e6d 100644 --- a/src/illuminate/illuminate.cpp +++ b/src/illuminate/illuminate.cpp @@ -93,4 +93,4 @@ glm::vec4 RayTracer::illuminatePixel( illumination += reflect(intersectionWorld, normalWorld, incidentDir, shape, scene, depth + 1); return illumination; -} \ No newline at end of file +} 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); diff --git a/src/raytracer/raytracer.cpp b/src/raytracer/raytracer.cpp index 3db0faa..65f898d 100644 --- a/src/raytracer/raytracer.cpp +++ b/src/raytracer/raytracer.cpp @@ -99,7 +99,7 @@ glm::vec4 RayTracer::getPixelFromRay( continue; } - auto newIntersectionWorld = shape.ctm * newIntersectionObj; + auto newIntersectionWorld = Vec4Ops::transformPoint4(newIntersectionObj,shape.ctm,shape.translation4d); float newDist = glm::distance(newIntersectionWorld, pWorld); if ( newDist < minDist // closer intersection -- cgit v1.2.3-70-g09d2