From c7c4f8f82c66cfe89b72d176ee51dab8bd30dc95 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Sun, 20 Dec 2020 21:59:33 +0100 Subject: Add hittable interface and hit infos on hit --- include/hittable.hpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 include/hittable.hpp (limited to 'include/hittable.hpp') diff --git a/include/hittable.hpp b/include/hittable.hpp new file mode 100644 index 0000000..4978e57 --- /dev/null +++ b/include/hittable.hpp @@ -0,0 +1,23 @@ +#ifndef __HITTABLE_HPP_ +#define __HITTABLE_HPP_ + +#include "ray.hpp" + +struct hit_info { + double t; + point3 point; + vec3 normal; + bool front_face; + + inline void set_face_normal(const ray& r, const vec3& outward_normal) { + front_face = r.direction.dot(outward_normal) < 0.0; + normal = front_face ? outward_normal : -outward_normal; + } +}; + +class hittable { + public: + virtual bool hit(const ray& r, double t_min, double t_max, struct hit_info& info) const = 0; +}; + +#endif // !__HITTABLE_HPP_ -- cgit v1.3