Initial commit

This commit is contained in:
CJSatnarine
2024-07-03 15:09:13 -04:00
commit cf96db673c
116 changed files with 824574 additions and 0 deletions

34
hittable.h Normal file
View File

@@ -0,0 +1,34 @@
#ifndef HITTABLE_H
#define HITTABLE_H
#include "rayTracer.h"
class material;
class hitRecord {
public:
point3 p;
vec3 normal;
shared_ptr<material> mat;
double t;
bool frontFace;
void setFaceNormal(const ray& r, const vec3& outwardNormal) {
/*
* Sets the hit record normal vector.
* NOTE: the parameter `outward_normal` is assumed to have unit length.
*/
frontFace = dot(r.direction(), outwardNormal) < 0;
normal = frontFace ? outwardNormal : -outwardNormal;
}
};
class hittable {
public:
virtual ~hittable() = default;
virtual bool hit(const ray& r, interval rayT, hitRecord& rec) const = 0;
};
#endif