src/kdtree.cc
branchpyrit
changeset 95 ca7d4c665531
parent 93 96d65f841791
child 103 3b3257a410fe
--- a/src/kdtree.cc	Thu May 08 09:21:25 2008 +0200
+++ b/src/kdtree.cc	Sat May 10 14:29:37 2008 +0200
@@ -35,10 +35,10 @@
 class ShapeBound
 {
 public:
-	Shape *shape;
+	const Shape *shape;
 	Float pos;
 	bool end;
-	ShapeBound(Shape *ashape, const Float apos, const bool aend):
+	ShapeBound(const Shape *ashape, const Float apos, const bool aend):
 		shape(ashape), pos(apos), end(aend) {};
 	friend bool operator<(const ShapeBound& a, const ShapeBound& b)
 	{
@@ -204,7 +204,7 @@
 }
 
 /* algorithm by Vlastimil Havran, Heuristic Ray Shooting Algorithms, appendix C */
-Shape *KdTree::nearest_intersection(const Shape *origin_shape, const Ray &ray,
+const Shape *KdTree::nearest_intersection(const Shape *origin_shape, const Ray &ray,
 	Float &nearest_distance)
 {
 	Float a, b; /* entry/exit signed distance */
@@ -309,7 +309,7 @@
 		}
 
 		/* current node is the leaf . . . empty or full */
-		Shape *nearest_shape = NULL;
+		const Shape *nearest_shape = NULL;
 		Float dist = stack[exit].t;
 		ShapeList::iterator shape;
 		for (shape = node->getShapes()->begin(); shape != node->getShapes()->end(); shape++)
@@ -346,7 +346,7 @@
 };
 
 void KdTree::packet_intersection(const Shape* const* origin_shapes, const RayPacket &rays,
-		Float *nearest_distances, Shape **nearest_shapes)
+		Float *nearest_distances, const Shape **nearest_shapes)
 {
 	mfloat4 a, b; /* entry/exit signed distance */
 	mfloat4 t;    /* signed distance to the splitting plane */
@@ -545,13 +545,13 @@
 	return st;
 }
 
-ostream & KdTree::dump(ostream &st)
+ostream & KdTree::dump(ostream &st) const
 {
 	if (!built)
 		return Container::dump(st);
 
 	st << "(kdtree," << shapes.size();
-	ShapeList::iterator shape;
+	ShapeList::const_iterator shape;
 	for (shape = shapes.begin(); shape != shapes.end(); shape++)
 	{
 		int idx;