-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbbox.h
46 lines (32 loc) · 745 Bytes
/
bbox.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef BBOX_H_
#define BBOX_H_
#include <iostream>
#include <iomanip>
#include <glm/glm.hpp>
//#include "primitive.h"
#include "ray.h"
#include "intersection_record.h"
class BBox
{
public:
BBox()
{};
BBox( const glm::dvec3 &min,
const glm::dvec3 &max ) :
min_{ min },
max_{ max },
centroid_{ 0.5 * ( min_ + max_ ) }
{};
~BBox( void ){};
double getArea( void ) const;
bool intersect( const Ray &ray ) const;
BBox operator + ( const BBox &rhs ) const
{
return BBox{ glm::min( min_, rhs.min_ ),
glm::max( max_, rhs.max_ ) };
}
glm::dvec3 min_;
glm::dvec3 max_;
glm::dvec3 centroid_;
};
#endif /*BBOX_H_*/