From d401600f1ca282ec4872e58baf8fb36a43161488 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Sat, 13 Jun 2020 22:02:26 +0200 Subject: [PATCH] Add Flip_face. --- hittable.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hittable.h b/hittable.h index 2d40de3..79c6e1f 100644 --- a/hittable.h +++ b/hittable.h @@ -30,4 +30,24 @@ public: virtual bool bounding_box(double t0, double t1, Aabb& output_box) const = 0; }; +class Flip_face : public Hittable { + public: + Flip_face(std::shared_ptr p) : ptr(p) {} + + virtual bool hit(const Ray &r, double tmin, double tmax, hit_record &rec) const { + if (!ptr->hit(r, tmin, tmax, rec)) + return false; + + rec.front_face = !rec.front_face; + return true; + } + + virtual bool bounding_box(double t0, double t1, Aabb& output_box) const { + return ptr->bounding_box(t0, t1, output_box); + } + + private: + std::shared_ptr ptr; +}; + #endif // HITTABLE_H