Skip to content
Snippets Groups Projects
Commit f0f24511 authored by Yoel's avatar Yoel
Browse files

Refactored the hit class to be a surfacepoint

parent 07504f40
No related branches found
No related tags found
No related merge requests found
...@@ -5,27 +5,9 @@ ...@@ -5,27 +5,9 @@
namespace cam { namespace cam {
Hit::Hit(const util::Vec3& hit, const util::Vec3& n, float t, Hit::Hit(const util::Vec3& hit, const util::Vec3& n, float t,
const std::shared_ptr<material::Material>& material) const std::shared_ptr<material::Material>& material)
: hit(hit), n(n), t(t), material(material) { : util::SurfacePoint(hit, n, material), t(t) {
}
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);
}
util::Vec3 Hit::albedo() const {
return material->albedo(0, 0);
}
util::Vec3 Hit::emission() const {
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 { float Hit::scalar() const {
return t; return t;
} }
......
#pragma once #pragma once
#include "../material/Material.h" #include "../material/Material.h"
#include "../tools/SurfacePoint.h"
#include "Ray.h" #include "Ray.h"
namespace cam { namespace cam {
class Hit { class Hit : public util::SurfacePoint {
public: public:
Hit(const util::Vec3& hit, const util::Vec3& n, float t, Hit(const util::Vec3& hit, const util::Vec3& n, float t,
const std::shared_ptr<material::Material>& material); const std::shared_ptr<material::Material>& material);
Ray scattered_ray(const Ray& inc_ray) const;
util::Vec3 albedo() const; // TODO TexelPos
util::Vec3 emission() const; // TODO TexelPos
bool scatter() const;
util::Vec3 hitpoint() const;
util::Vec3 normal() const;
float scalar() const; float scalar() const;
// Attributes
// TODO TexelPos
std::shared_ptr<material::Material> material;
private: private:
util::Vec3 hit, n;
float t; float t;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment