Midway hittable list inclusion
This commit is contained in:
parent
3aea707982
commit
8c1324c074
6 changed files with 141 additions and 2 deletions
25
hittable.hpp
Normal file
25
hittable.hpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef HITTABLE_H
|
||||
#define HITTABLE_H
|
||||
|
||||
#include "ray.hpp"
|
||||
|
||||
/* Representation of a hitpoint of a ray against a hittable object */
|
||||
struct hit_record {
|
||||
point3 p;
|
||||
vec3 normal;
|
||||
double t;
|
||||
bool front_face;
|
||||
|
||||
inline void set_face_normal(const ray& r, const vec3& outward_normal)
|
||||
{
|
||||
front_face = dot(r.direction, outward_normal) < 0;
|
||||
normal = front_face ? outward_normal : -outward_normal;
|
||||
}
|
||||
};
|
||||
|
||||
/* Virtual class that represents objects who could collide against a ray */
|
||||
struct hittable {
|
||||
virtual bool hit(const ray& r, double t_min, double t_max, hit_record& rec) const = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue