void TextureBrick::compute_edge_rays_tex(BBox &bbox)
	{
		// set up vertices
		Point corner[8];
		corner[0] = bbox.min();
		corner[1] = Point(bbox.min().x(), bbox.min().y(), bbox.max().z());
		corner[2] = Point(bbox.min().x(), bbox.max().y(), bbox.min().z());
		corner[3] = Point(bbox.min().x(), bbox.max().y(), bbox.max().z());
		corner[4] = Point(bbox.max().x(), bbox.min().y(), bbox.min().z());
		corner[5] = Point(bbox.max().x(), bbox.min().y(), bbox.max().z());
		corner[6] = Point(bbox.max().x(), bbox.max().y(), bbox.min().z());
		corner[7] = bbox.max();

		// set up edges
		tex_edge_[0] = Ray(corner[0], corner[2] - corner[0]);
		tex_edge_[1] = Ray(corner[2], corner[6] - corner[2]);
		tex_edge_[2] = Ray(corner[4], corner[6] - corner[4]);
		tex_edge_[3] = Ray(corner[0], corner[4] - corner[0]);
		tex_edge_[4] = Ray(corner[1], corner[3] - corner[1]);
		tex_edge_[5] = Ray(corner[3], corner[7] - corner[3]);
		tex_edge_[6] = Ray(corner[5], corner[7] - corner[5]);
		tex_edge_[7] = Ray(corner[1], corner[5] - corner[1]);
		tex_edge_[8] = Ray(corner[0], corner[1] - corner[0]);
		tex_edge_[9] = Ray(corner[2], corner[3] - corner[2]);
		tex_edge_[10] = Ray(corner[6], corner[7] - corner[6]);
		tex_edge_[11] = Ray(corner[4], corner[5] - corner[4]);
	}
Exemple #2
0
 static std::size_t calcTick(
         const Point& point,
         const BBox& bbox,
         const std::size_t depth)
 {
     return
         std::floor(
                 (point.z - bbox.min().z) * (1ULL << depth) /
                 (bbox.max().z - bbox.min().z));
 }
Exemple #3
0
Shape* BVH::buildBranch(Shape** shapes, int shape_size, int axis) {
    if (shape_size == 1) {return shapes[0];}
    else if (shape_size == 2) {return new BVH(shapes[0], shapes[1]);}
    
    //find midpoint of bbox to use as qsplit pivot
    BBox box = shapes[0] -> boundingBox(0.0f, 0.0f);
    for (int i = 1; i < shape_size; i++) {
        box = surround(box, shapes[i] -> boundingBox(0.0f, 0.0f));
    }
    Vector3 pivot = (box.max() + box.min()) / 2.0f;
    
    //split according to correct axis
    int midpt = QSplit::qsplit(shapes, shape_size, pivot[axis], axis);
    
    //create new bounding volume
    Shape* left = buildBranch(shapes, midpt, (axis + 1) % 3);
    Shape* right = buildBranch(&shapes[midpt], shape_size - midpt, (axis + 1) %3);
    return new BVH(left, right, box);
}
Exemple #4
0
inline bool operator==(const BBox& lhs, const BBox& rhs)
{
    return lhs.min() == rhs.min() && lhs.max() == rhs.max();
}