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"
#define _USE_MATH_DEFINES
#include <limits>
#include "../material/BackgroundMaterial.h"
#include "math.h"
namespace shapes {
Background::Background(const std::shared_ptr<material::Material>& material)
: material(material) {
Background::Background(const std::shared_ptr<util::Sampler>& sampler)
: 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 {
return std::optional<cam::Hit>({r(std::numeric_limits<float>::infinity()),
util::Vec3({}),
{},
std::numeric_limits<float>::infinity(),
material});
}
// Not used
std::pair<float, float> Background::texture_coordinates(
const util::Vec3& pos) const {
return std::pair<float, float>({});
}
auto hit = Sphere::intersect(r);
if (hit)
hit = std::optional<cam::Hit>(
{{hit->point(), -hit->normal(), hit->texel(), hit->scalar(),
hit->material}});
return hit;
}*/
util::AxisAlignedBoundingBox Background::bounds() const {
return util::AxisAlignedBoundingBox();
......
#pragma once
#include "../sampling/Sampler.h"
#include "Shape.h"
#include "Sphere.h"
namespace shapes {
class Background : public Shape {
class Background : public Sphere {
public:
Background(const std::shared_ptr<material::Material>& material);
std::optional<cam::Hit> intersect(const cam::Ray& r) const override;
std::pair<float, float> Background::texture_coordinates(
const util::Vec3& pos) const override;
Background(const std::shared_ptr<util::Sampler>& sampler);
// We should have to flip the normal, but it does not matter
// std::optional<cam::Hit> intersect(const cam::Ray& r) const override;
util::AxisAlignedBoundingBox bounds() const override;
private:
std::shared_ptr<material::Material> material;
};
} // 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