Skip to content
Snippets Groups Projects
Hit.cpp 760 B
Newer Older
Postea's avatar
Postea committed
#include "Hit.h"
Yoel's avatar
Yoel committed

Postea's avatar
Postea committed
#include <limits>

namespace cam {
Yoel's avatar
Yoel committed
Hit::Hit(const util::Vec3& hit, const util::Vec3& n, float t,
         const std::shared_ptr<material::Material>& material)
    : hit(hit), n(n), t(t), material(material) {
Yoel's avatar
Yoel committed
Ray Hit::scattered_ray(const Ray& inc_ray) const {
	return Ray(hit, material->scattered_d(inc_ray.d, n),
	           std::numeric_limits<float>::epsilon(), inc_ray.tmax, true);
Yoel's avatar
Yoel committed
	return material->albedo(0, 0);
Yoel's avatar
Yoel committed
	return material->emission(0, 0);
bool Hit::scatter() const {
	return material->scatter();
}
util::Vec3 Hit::hitpoint() const {
	return hit;
}
util::Vec3 Hit::normal() const {
	return n;
}
float Hit::scalar() const {
	return t;
}
Yoel's avatar
Yoel committed
}  // namespace cam