From c135ff2480f4e2aaf05b0206631bb0e1b5d73fad Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 20 May 2013 19:33:20 +0300 Subject: [PATCH] Record distance in SurfacePoint --- source/geometry/hyperbox.h | 7 +++---- source/geometry/hypersphere.h | 1 + source/geometry/surfacepoint.h | 1 + source/geometry/transformedshape.h | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/geometry/hyperbox.h b/source/geometry/hyperbox.h index 7d363f2..10c28d5 100644 --- a/source/geometry/hyperbox.h +++ b/source/geometry/hyperbox.h @@ -83,7 +83,6 @@ inline unsigned HyperBox::get_intersections(const Ray &ray, SurfaceP LinAl::Vector half_dim = dimensions/T(2); unsigned n = 0; - T first_depth = T(); for(unsigned i=0; i::get_intersections(const Ray &ray, SurfaceP points[n].position = p; points[n].normal = LinAl::Vector(); points[n].normal[i] = j; - if(n==0) - first_depth = x; - else if(n==1 && x::get_intersections(const Ray &ray, Surfa { points[n].position = ray.get_start()+ray.get_direction()*x; points[n].normal = normalize(points[n].position); + points[n].distance = x; } ++n; diff --git a/source/geometry/surfacepoint.h b/source/geometry/surfacepoint.h index 251964c..a5bd794 100644 --- a/source/geometry/surfacepoint.h +++ b/source/geometry/surfacepoint.h @@ -14,6 +14,7 @@ struct SurfacePoint { LinAl::Vector position; LinAl::Vector normal; + T distance; }; } // namespace Geometry diff --git a/source/geometry/transformedshape.h b/source/geometry/transformedshape.h index 0125368..34fd298 100644 --- a/source/geometry/transformedshape.h +++ b/source/geometry/transformedshape.h @@ -107,6 +107,7 @@ inline unsigned TransformedShape::get_intersections(const Ray &ray, /* XXX This is not correct for nonuniform scaling. Inverse of the transpose of the upper DxD part of the matrix should be used. */ points[i].normal = transformation.transform(points[i].normal); + points[i].distance = inner_product(points[i].position-ray.get_start(), ray.get_direction()); } } return count; -- 2.43.0