# HG changeset patch # User Radek Brich # Date 1195751410 -3600 # Node ID e6567b740c5eddc0afebddac6036589b454885cb # Parent bf17f9f84c916ffb4fac1959ef6924573b3e5379 fixed virtual method get_bbox() for all shapes, default thread num changed to 4 diff -r bf17f9f84c91 -r e6567b740c5e src/raytracer.cc --- a/src/raytracer.cc Thu Nov 22 17:53:34 2007 +0100 +++ b/src/raytracer.cc Thu Nov 22 18:10:10 2007 +0100 @@ -230,7 +230,7 @@ vy = starty; #ifdef PTHREADS - int num_threads = 2; + int num_threads = 4; printf("* pthreads enabled, using %d threads\n", num_threads); pthread_t threads[num_threads]; for (int t = 0; t < num_threads; t++) diff -r bf17f9f84c91 -r e6567b740c5e src/scene.cc --- a/src/scene.cc Thu Nov 22 17:53:34 2007 +0100 +++ b/src/scene.cc Thu Nov 22 18:10:10 2007 +0100 @@ -71,6 +71,18 @@ return false; } +BBox Sphere::get_bbox() +{ + BBox bbox = BBox(); + bbox.L.x = center.x - radius; + bbox.L.y = center.y - radius; + bbox.L.z = center.z - radius; + bbox.R.x = center.x + radius; + bbox.R.y = center.y + radius; + bbox.R.z = center.z + radius; + return bbox; +} + bool Plane::intersect(const Ray &ray, float &dist) { float dir = dot(N, ray.dir); @@ -85,6 +97,11 @@ return false; } +BBox Plane::get_bbox() +{ + return BBox(); +} + // this initialization and following intersection methods implements // Fast Triangle Intersection algorithm from // http://www.mpi-inf.mpg.de/~wald/PhD/ diff -r bf17f9f84c91 -r e6567b740c5e src/scene.h --- a/src/scene.h Thu Nov 22 17:53:34 2007 +0100 +++ b/src/scene.h Thu Nov 22 18:10:10 2007 +0100 @@ -94,7 +94,7 @@ // normal at point P virtual Vector3 normal(Vector3 &P) = 0; - virtual BBox get_bbox(); + virtual BBox get_bbox() = 0; }; class Sphere: public Shape @@ -111,6 +111,7 @@ bool intersect(const Ray &ray, float &dist); bool intersect_all(const Ray &ray, float dist, vector &allts); Vector3 normal(Vector3 &P) { return (P - center) * inv_radius; }; + BBox get_bbox(); }; class Plane: public Shape @@ -126,6 +127,7 @@ bool intersect(const Ray &ray, float &dist); bool intersect_all(const Ray &ray, float dist, vector &allts) {return false;}; Vector3 normal(Vector3 &) { return N; }; + BBox get_bbox(); }; class Triangle: public Shape