include/raytracer.h
branchpyrit
changeset 91 9d66d323c354
parent 90 f6a72eb99631
child 92 9af5c039b678
equal deleted inserted replaced
90:f6a72eb99631 91:9d66d323c354
    37 class Raytracer;
    37 class Raytracer;
    38 
    38 
    39 struct RenderrowData {
    39 struct RenderrowData {
    40 	Raytracer *rt;
    40 	Raytracer *rt;
    41 	int w;
    41 	int w;
    42 	Vector3 eye, dfix, dx, dy;
    42 	Vector eye, dfix, dx, dy;
    43 	Float *iter;
    43 	Float *iter;
    44 };
    44 };
    45 
    45 
    46 /**
    46 /**
    47  * main ray tracer class
    47  * main ray tracer class
    57 	Float ao_distance, ao_angle;
    57 	Float ao_distance, ao_angle;
    58 	int num_threads;
    58 	int num_threads;
    59 	int max_depth;
    59 	int max_depth;
    60 	bool use_packets;
    60 	bool use_packets;
    61 
    61 
    62 	Vector3 SphereDistribute(int i, int n, Float extent, Vector3 &normal);
       
    63 
       
    64 	Sample *sample_queue;
    62 	Sample *sample_queue;
    65 	int sample_queue_pos, sample_queue_size, sample_queue_count;
    63 	int sample_queue_pos, sample_queue_size, sample_queue_count;
    66 	bool end_of_samples;
    64 	bool end_of_samples;
    67 	pthread_mutex_t sample_queue_mutex, sampler_mutex;
    65 	pthread_mutex_t sample_queue_mutex, sampler_mutex;
    68 	pthread_cond_t sample_queue_cond, worker_ready_cond;
    66 	pthread_cond_t sample_queue_cond, worker_ready_cond;
    69 
    67 
    70 	Colour shader_evalulate(const Ray &ray, int depth, Shape *origin_shape,
    68 	Vector SphereDistribute(int i, int n, Float extent, const Vector &normal);
    71 		Float nearest_distance, Shape *nearest_shape);
    69 	Colour PhongShader(const Shape *shape,
       
    70 		const Vector &P, const Vector &N, const Vector &V);
       
    71 	void lightScatter(const Ray &ray, const Shape *shape, int depth,
       
    72 		const Vector &P, const Vector &normal, bool from_inside, Colour &col);
       
    73 #ifndef NO_SSE
       
    74 	VectorPacket PhongShader_packet(const Shape **shapes,
       
    75 		const VectorPacket &P, const VectorPacket &N, const VectorPacket &V);
    72 	void raytracePacket(RayPacket &rays, Colour *results);
    76 	void raytracePacket(RayPacket &rays, Colour *results);
       
    77 #endif
    73 	static void *raytrace_worker(void *d);
    78 	static void *raytrace_worker(void *d);
    74 public:
    79 public:
    75 	Raytracer(): top(NULL), camera(NULL), lights(), bg_colour(0., 0., 0.),
    80 	Raytracer(): top(NULL), camera(NULL), lights(), bg_colour(0., 0., 0.),
    76 		ao_samples(0), num_threads(2), max_depth(3), use_packets(true)
    81 		ao_samples(0), num_threads(2), max_depth(3), use_packets(true)
    77 	{
    82 	{
    87 		pthread_cond_destroy (&sample_queue_cond);
    92 		pthread_cond_destroy (&sample_queue_cond);
    88 		pthread_cond_destroy (&worker_ready_cond);
    93 		pthread_cond_destroy (&worker_ready_cond);
    89 	}
    94 	}
    90 
    95 
    91 	void render();
    96 	void render();
    92 	Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
    97 	Colour raytrace(Ray &ray, int depth, const Shape *origin_shape);
    93 	void addShape(Shape *shape) { top->addShape(shape); };
    98 	void addShape(Shape *shape) { top->addShape(shape); };
    94 	void addLight(Light *light) { lights.push_back(light); };
    99 	void addLight(Light *light) { lights.push_back(light); };
    95 	void setSampler(Sampler *sampl) { sampler = sampl; };
   100 	void setSampler(Sampler *sampl) { sampler = sampl; };
    96 	Sampler *&getSampler() { return sampler; };
   101 	Sampler *&getSampler() { return sampler; };
    97 	void setCamera(Camera *cam) { camera = cam; };
   102 	void setCamera(Camera *cam) { camera = cam; };