From: Mikko Rasa Date: Mon, 20 May 2013 16:33:20 +0000 (+0300) Subject: Record distance in SurfacePoint X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c135ff2480f4e2aaf05b0206631bb0e1b5d73fad;p=libs%2Fmath.git Record distance in SurfacePoint --- 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;