src/container.cc
branchpyrit
changeset 72 7c3f38dff082
parent 44 3763b26244f0
child 74 09aedbf5f95f
equal deleted inserted replaced
71:4fedf7290929 72:7c3f38dff082
    31 {
    31 {
    32 	shapes.push_back(aShape);
    32 	shapes.push_back(aShape);
    33 	if (shapes.size() == 0) {
    33 	if (shapes.size() == 0) {
    34 		/* initialize bounding box */
    34 		/* initialize bounding box */
    35 		bbox = aShape->get_bbox();
    35 		bbox = aShape->get_bbox();
       
    36 		Vector3 eps(Eps,Eps,Eps);
       
    37 		bbox = BBox(bbox.L - eps, bbox.H + eps);
    36 	} else {
    38 	} else {
    37 		/* adjust bounding box */
    39 		/* adjust bounding box */
    38 		BBox shapebb = aShape->get_bbox();
    40 		BBox shapebb = aShape->get_bbox();
    39 		if (shapebb.L.x < bbox.L.x)  bbox.L.x = shapebb.L.x;
    41 		if (shapebb.L.x - Eps < bbox.L.x)  bbox.L.x = shapebb.L.x - Eps;
    40 		if (shapebb.L.y < bbox.L.y)  bbox.L.y = shapebb.L.y;
    42 		if (shapebb.L.y - Eps < bbox.L.y)  bbox.L.y = shapebb.L.y - Eps;
    41 		if (shapebb.L.z < bbox.L.z)  bbox.L.z = shapebb.L.z;
    43 		if (shapebb.L.z - Eps < bbox.L.z)  bbox.L.z = shapebb.L.z - Eps;
    42 		if (shapebb.H.x > bbox.H.x)  bbox.H.x = shapebb.H.x;
    44 		if (shapebb.H.x + Eps > bbox.H.x)  bbox.H.x = shapebb.H.x + Eps;
    43 		if (shapebb.H.y > bbox.H.y)  bbox.H.y = shapebb.H.y;
    45 		if (shapebb.H.y + Eps > bbox.H.y)  bbox.H.y = shapebb.H.y + Eps;
    44 		if (shapebb.H.z > bbox.H.z)  bbox.H.z = shapebb.H.z;
    46 		if (shapebb.H.z + Eps > bbox.H.z)  bbox.H.z = shapebb.H.z + Eps;
    45 	}
    47 	}
    46 };
    48 };
    47 
    49 
    48 Shape *Container::nearest_intersection(const Shape *origin_shape, const Ray &ray,
    50 Shape *Container::nearest_intersection(const Shape *origin_shape, const Ray &ray,
    49         Float &nearest_distance)
    51         Float &nearest_distance)