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

Pointless pointers deleted and added a special Background-member

parent 796b57fc
No related branches found
No related tags found
No related merge requests found
#include "Scene.h"
Scene::Scene(std::shared_ptr<shapes::Shape> group, cam::CamObs cam,
size_t depth)
: group(group), cam(cam), depth(depth) {
Scene::Scene(const shapes::Group& group, const shapes::Background& bg,
const cam::CamObs& cam, size_t depth)
: group(group), bg(bg), cam(cam), depth(depth) {
}
util::Vec3 Scene::color(float x, float y) const {
......@@ -14,7 +14,10 @@ util::Vec3 Scene::calculateRadiance(const cam::Ray& r, size_t depth) const {
if (depth == 0) {
return util::Vec3(0, 0, 0);
}
std::shared_ptr<cam::Hit> h = group->intersect(r);
std::shared_ptr<cam::Hit> h = group.intersect(r);
if (h == nullptr) {
h = bg.intersect(r);
}
util::Vec3 result;
if (h->scatter()) {
result =
......
#pragma once
#include "../camera/CamObs.h"
#include "../shape/Shape.h"
#include "../shape/Background.h"
#include "../shape/Group.h"
#include "Sampler.h"
class Scene : public util::Sampler {
public:
Scene(std::shared_ptr<shapes::Shape> group, cam::CamObs cam, size_t depth);
Scene(const shapes::Group& group, const shapes::Background& bg,
const cam::CamObs& cam, size_t depth);
util::Vec3 color(float x, float y) const override;
util::Vec3 calculateRadiance(const cam::Ray& r, size_t depth) const;
private:
std::shared_ptr<shapes::Shape> group;
shapes::Background bg;
shapes::Group group;
cam::CamObs cam;
size_t depth;
};
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