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

Make Background inherit from Sphere

parent 1fe1fcb5
No related branches found
No related tags found
No related merge requests found
#include "Background.h" #include "Background.h"
#define _USE_MATH_DEFINES
#include <limits> #include <limits>
#include "../material/BackgroundMaterial.h"
#include "math.h"
namespace shapes { namespace shapes {
Background::Background(const std::shared_ptr<material::Material>& material) Background::Background(const std::shared_ptr<util::Sampler>& sampler)
: material(material) { : Sphere(100, std::make_shared<material::BackgroundMaterial>(sampler)) {
} }
// TODO TEXELS // Thit intersect method rightly flips the normal.But the normal is never used
// for non scatter materials, so we do not flip the normal
/*
std::optional<cam::Hit> Background::intersect(const cam::Ray& r) const { std::optional<cam::Hit> Background::intersect(const cam::Ray& r) const {
return std::optional<cam::Hit>({r(std::numeric_limits<float>::infinity()), auto hit = Sphere::intersect(r);
util::Vec3({}), if (hit)
{}, hit = std::optional<cam::Hit>(
std::numeric_limits<float>::infinity(), {{hit->point(), -hit->normal(), hit->texel(), hit->scalar(),
material}); hit->material}});
} return hit;
// Not used }*/
std::pair<float, float> Background::texture_coordinates(
const util::Vec3& pos) const {
return std::pair<float, float>({});
}
util::AxisAlignedBoundingBox Background::bounds() const { util::AxisAlignedBoundingBox Background::bounds() const {
return util::AxisAlignedBoundingBox(); return util::AxisAlignedBoundingBox();
......
#pragma once #pragma once
#include "../sampling/Sampler.h"
#include "Shape.h" #include "Shape.h"
#include "Sphere.h"
namespace shapes { namespace shapes {
class Background : public Shape { class Background : public Sphere {
public: public:
Background(const std::shared_ptr<material::Material>& material); Background(const std::shared_ptr<util::Sampler>& sampler);
std::optional<cam::Hit> intersect(const cam::Ray& r) const override; // We should have to flip the normal, but it does not matter
std::pair<float, float> Background::texture_coordinates( // std::optional<cam::Hit> intersect(const cam::Ray& r) const override;
const util::Vec3& pos) const override;
util::AxisAlignedBoundingBox bounds() const override; util::AxisAlignedBoundingBox bounds() const override;
private:
std::shared_ptr<material::Material> material;
}; };
} // namespace shapes } // namespace shapes
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