src/container.cc
branchpyrit
changeset 91 9d66d323c354
parent 84 6f7fe14782c2
child 92 9af5c039b678
equal deleted inserted replaced
90:f6a72eb99631 91:9d66d323c354
     1 /*
     1 /*
     2  * container.cc: Container class
     2  * container.cc: Container class
     3  *
     3  *
     4  * This file is part of Pyrit Ray Tracer.
     4  * This file is part of Pyrit Ray Tracer.
     5  *
     5  *
     6  * Copyright 2007  Radek Brich
     6  * Copyright 2007, 2008  Radek Brich
     7  *
     7  *
     8  * Permission is hereby granted, free of charge, to any person obtaining a copy
     8  * Permission is hereby granted, free of charge, to any person obtaining a copy
     9  * of this software and associated documentation files (the "Software"), to deal
     9  * of this software and associated documentation files (the "Software"), to deal
    10  * in the Software without restriction, including without limitation the rights
    10  * in the Software without restriction, including without limitation the rights
    11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    32 {
    32 {
    33 	const Float e = Eps;
    33 	const Float e = Eps;
    34 	if (shapes.size() == 0) {
    34 	if (shapes.size() == 0) {
    35 		/* initialize bounding box */
    35 		/* initialize bounding box */
    36 		bbox = aShape->get_bbox();
    36 		bbox = aShape->get_bbox();
    37 		const Vector3 E(e, e, e);
    37 		const Vector E(e, e, e);
    38 		bbox = BBox(bbox.L - E, bbox.H + E);
    38 		bbox = BBox(bbox.L - E, bbox.H + E);
    39 	} else {
    39 	} else {
    40 		/* adjust bounding box */
    40 		/* adjust bounding box */
    41 		BBox shapebb = aShape->get_bbox();
    41 		BBox shapebb = aShape->get_bbox();
    42 		if (shapebb.L.x - e < bbox.L.x)  bbox.L.x = shapebb.L.x - e;
    42 		if (shapebb.L.x - e < bbox.L.x)  bbox.L.x = shapebb.L.x - e;
    58 		if (*shape != origin_shape && (*shape)->intersect(ray, nearest_distance))
    58 		if (*shape != origin_shape && (*shape)->intersect(ray, nearest_distance))
    59 			nearest_shape = *shape;
    59 			nearest_shape = *shape;
    60 	return nearest_shape;
    60 	return nearest_shape;
    61 }
    61 }
    62 
    62 
       
    63 #ifndef NO_SSE
    63 void Container::packet_intersection(const Shape **origin_shapes, const RayPacket &rays,
    64 void Container::packet_intersection(const Shape **origin_shapes, const RayPacket &rays,
    64 	Float *nearest_distances, Shape **nearest_shapes)
    65 	Float *nearest_distances, Shape **nearest_shapes)
    65 {
    66 {
    66 	for (int i = 0; i < 4; i++)
    67 	for (int i = 0; i < 4; i++)
    67 		nearest_shapes[i] = nearest_intersection(origin_shapes[i], rays[i],
    68 		nearest_shapes[i] = nearest_intersection(origin_shapes[i], rays[i],
    68 			nearest_distances[i]);
    69 			nearest_distances[i]);
    69 }
    70 }
       
    71 #endif
    70 
    72 
    71 ostream & Container::dump(ostream &st)
    73 ostream & Container::dump(ostream &st)
    72 {
    74 {
    73 	st << "(container," << shapes.size();
    75 	st << "(container," << shapes.size();
    74 	ShapeList::iterator shape;
    76 	ShapeList::iterator shape;