src/raytracer.cc
branchpyrit
changeset 84 6f7fe14782c2
parent 83 e3a2a5b26abb
child 86 ce6abe0aeeae
--- a/src/raytracer.cc	Thu Apr 24 18:12:32 2008 +0200
+++ b/src/raytracer.cc	Sun Apr 27 09:44:49 2008 +0200
@@ -74,7 +74,7 @@
 
 // calculate shader function
 // P is point of intersection, N normal in this point
-Colour PhongShader_ambient(Material &mat, Vector3 &P)
+Colour PhongShader_ambient(const Material &mat, const Vector3 &P)
 {
 	Colour col;
 	if (mat.texture)
@@ -92,8 +92,9 @@
  R direction of reflected ray,
  V direction to the viewer
 */
-Colour PhongShader_calculate(Material &mat, Vector3 &P, Vector3 &N, Vector3 &R, Vector3 &V,
-	Light &light)
+Colour PhongShader_calculate(const Material &mat,
+	const Vector3 &P, const Vector3 &N, const Vector3 &R, const Vector3 &V,
+	const Light &light)
 {
 	Colour I = Colour();
 	Vector3 L = light.pos - P;
@@ -116,7 +117,7 @@
 	return I;
 }
 
-Colour Raytracer::shader_evalulate(Ray &ray, int depth, Shape *origin_shape,
+Colour Raytracer::shader_evalulate(const Ray &ray, int depth, Shape *origin_shape,
 	Float nearest_distance, Shape *nearest_shape)
 {
 	Colour col = Colour();
@@ -236,21 +237,18 @@
 	Shape *nearest_shape = top->nearest_intersection(origin_shape, ray, nearest_distance);
 
 	if (nearest_shape == NULL)
-	{
 		return bg_colour;
-	}
 	else
-	{
 		return shader_evalulate(ray, depth, origin_shape, nearest_distance, nearest_shape);
-	}
 }
 
-void Raytracer::raytracePacket(Ray *rays, Colour *results)
+void Raytracer::raytracePacket(RayPacket &rays, Colour *results)
 {
 	Float nearest_distances[4] = {Inf,Inf,Inf,Inf};
 	Shape *nearest_shapes[4];
 	static const Shape *origin_shapes[4] = {NULL, NULL, NULL, NULL};
 	top->packet_intersection(origin_shapes, rays, nearest_distances, nearest_shapes);
+	Ray ray;
 
 	for (int i = 0; i < 4; i++)
 		if (nearest_shapes[i] == NULL)
@@ -267,7 +265,8 @@
 	Sample my_queue[my_queue_size];
 	Colour my_colours[my_queue_size];
 	int my_count;
-	Ray ray, rays[4];
+	Ray ray;
+	RayPacket rays;
 	const bool can_use_packets = (rt->use_packets && rt->sampler->packetableSamples());
 	for (;;)
 	{