--- a/src/raytracer.cc Thu May 08 09:21:25 2008 +0200
+++ b/src/raytracer.cc Sat May 10 14:29:37 2008 +0200
@@ -152,7 +152,7 @@
// ambient
acc = colour * ambient;
- Shape *shadow_shapes[4];
+ const Shape *shadow_shapes[4];
vector<Light*>::iterator light;
for (light = lights.begin(); light != lights.end(); light++)
{
@@ -200,14 +200,6 @@
Float refl = shape->material->reflectivity;
const Float cos_i = - dot(normal, ray.dir);
- // reflection
- if (refl > 0.01)
- {
- Vector newdir = ray.dir + 2.0f * cos_i * normal;
- Ray newray = Ray(P, newdir);
- refl_col = raytrace(newray, depth + 1, shape);
- }
-
// refraction
if (trans > 0.01)
{
@@ -245,6 +237,15 @@
trans_col = raytrace(newray, depth + 1, NULL);
}
}
+
+ // reflection
+ if (refl > 0.01)
+ {
+ Vector newdir = ray.dir + 2.0f * cos_i * normal;
+ Ray newray = Ray(P, newdir);
+ refl_col = raytrace(newray, depth + 1, shape);
+ }
+
col = (1-refl-trans)*col + refl*refl_col + trans*trans_col;
}
@@ -257,7 +258,7 @@
Vector dir = SphereDistribute(i, ao_samples, ao_angle, normal);
Ray ao_ray = Ray(P, dir);
Float dist = ao_distance;
- Shape *shape_in_way = top->nearest_intersection(shape, ao_ray, dist);
+ const Shape *shape_in_way = top->nearest_intersection(shape, ao_ray, dist);
if (shape_in_way == NULL)
miss += 1.0;
else
@@ -271,7 +272,7 @@
Colour Raytracer::raytrace(Ray &ray, int depth, const Shape *origin_shape)
{
Float nearest_distance = Inf;
- Shape *nearest_shape = top->nearest_intersection(origin_shape, ray, nearest_distance);
+ const Shape *nearest_shape = top->nearest_intersection(origin_shape, ray, nearest_distance);
if (nearest_shape == NULL)
return bg_colour;
@@ -303,7 +304,7 @@
mfloat4 m_nearest_distances;
};
mfloat4 mask;
- Shape *nearest_shapes[4];
+ const Shape *nearest_shapes[4];
static const Shape *origin_shapes[4] = {NULL, NULL, NULL, NULL};
m_nearest_distances = mInf;
@@ -351,12 +352,7 @@
}
#endif
-#ifdef MSVC
-__declspec(noreturn)
-#else
-__attribute__((noreturn))
-#endif
-void *Raytracer::raytrace_worker(void *d)
+NORETURN void *Raytracer::raytrace_worker(void *d)
{
static const int my_queue_size = 256;
Raytracer *rt = (Raytracer*)d;