diff -r f9fad94cd0cc -r 4d192e13ee84 src/raytracer.cc --- a/src/raytracer.cc Fri Nov 23 01:24:33 2007 +0100 +++ b/src/raytracer.cc Fri Nov 23 16:14:38 2007 +0100 @@ -52,17 +52,6 @@ return Vector3(x, y, z); } -inline Shape *Raytracer::nearest_intersection(const Shape *origin_shape, const Ray &ray, - float &nearest_distance) -{ - Shape *nearest_shape = NULL; - ShapeList::iterator shape; - for (shape = top->shapes.begin(); shape != top->shapes.end(); shape++) - if (*shape != origin_shape && (*shape)->intersect(ray, nearest_distance)) - nearest_shape = *shape; - return nearest_shape; -} - // ---- tyto dve funkce budou v budouci verzi metody objektu PhongShader // calculate shader function @@ -104,7 +93,7 @@ Colour Raytracer::raytrace(Ray &ray, int depth, Shape *origin_shape) { float nearest_distance = FLT_MAX; //Infinity - Shape *nearest_shape = nearest_intersection(origin_shape, ray, nearest_distance); + Shape *nearest_shape = top->nearest_intersection(origin_shape, ray, nearest_distance); if (nearest_shape == NULL) { return bg_colour; @@ -124,7 +113,7 @@ if ((*light)->shadows) { Ray shadow_ray = Ray(P, L); float dist = FLT_MAX; - if (nearest_intersection(nearest_shape, shadow_ray, dist)) + if (top->nearest_intersection(nearest_shape, shadow_ray, dist)) continue; } @@ -155,7 +144,7 @@ Vector3 dir = SphereDistribute(i, ao_samples, ao_angle, normal); Ray ao_ray = Ray(P, dir); float dist = ao_distance; - Shape *shape_in_way = nearest_intersection(nearest_shape, ao_ray, dist); + Shape *shape_in_way = top->nearest_intersection(nearest_shape, ao_ray, dist); if (shape_in_way == NULL) miss += 1.0; else