Add Flip_face.

This commit is contained in:
Faerbit 2020-06-13 22:02:26 +02:00
parent 7699f26cf2
commit d401600f1c

View File

@ -30,4 +30,24 @@ public:
virtual bool bounding_box(double t0, double t1, Aabb& output_box) const = 0; virtual bool bounding_box(double t0, double t1, Aabb& output_box) const = 0;
}; };
class Flip_face : public Hittable {
public:
Flip_face(std::shared_ptr<Hittable> 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<Hittable> ptr;
};
#endif // HITTABLE_H #endif // HITTABLE_H