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

SingleGroup now gets a LightShape instead of jsut a shape. It effectively...

SingleGroup now gets a LightShape instead of jsut a shape. It effectively splits the LightShape back in Light and Shape. Also provides a transform
parent d48df1ae
No related branches found
No related tags found
No related merge requests found
...@@ -5,11 +5,12 @@ ...@@ -5,11 +5,12 @@
namespace shapes { namespace shapes {
SingleGroup::SingleGroup(const util::Transformation& transform, SingleGroup::SingleGroup(const util::Transformation& transform,
std::shared_ptr<Shape> shape) std::shared_ptr<LightShape> shape)
: shape(shape), transform(transform) { : shape(shape), transform(transform) {
boundingVolume = shape->bounds() * transform.toWorld; boundingVolume = shape->bounds() * transform.toWorld;
} }
SingleGroup::SingleGroup(const util::Mat4& matrix, std::shared_ptr<Shape> shape) SingleGroup::SingleGroup(const util::Mat4& matrix,
std::shared_ptr<LightShape> shape)
: shape(shape), transform(util::Transformation(matrix)) { : shape(shape), transform(util::Transformation(matrix)) {
boundingVolume = shape->bounds() * transform.toWorld; boundingVolume = shape->bounds() * transform.toWorld;
} }
...@@ -37,4 +38,8 @@ util::AxisAlignedBoundingBox SingleGroup::bounds() const { ...@@ -37,4 +38,8 @@ util::AxisAlignedBoundingBox SingleGroup::bounds() const {
return boundingVolume; return boundingVolume;
} }
util::SurfacePoint SingleGroup::sampleLight() const {
return shape->sampleLight();
}
} // namespace shapes } // namespace shapes
\ No newline at end of file
...@@ -2,21 +2,23 @@ ...@@ -2,21 +2,23 @@
#include "../tools/Mat4.h" #include "../tools/Mat4.h"
#include "../tools/Transformation.h" #include "../tools/Transformation.h"
#include "Shape.h" #include "LightShape.h"
namespace shapes { namespace shapes {
class SingleGroup : public Shape { class SingleGroup : public Shape, public Light {
public: public:
SingleGroup(const util::Transformation& trans, SingleGroup(const util::Transformation& trans,
std::shared_ptr<Shape> shape); std::shared_ptr<LightShape> shape);
SingleGroup(const util::Mat4& matrix, std::shared_ptr<Shape> shape); SingleGroup(const util::Mat4& matrix, std::shared_ptr<LightShape> shape);
std::optional<cam::Hit> intersect(const cam::Ray& r) const override; std::optional<cam::Hit> intersect(const cam::Ray& r) const override;
util::AxisAlignedBoundingBox bounds() const override; util::AxisAlignedBoundingBox bounds() const override;
util::SurfacePoint sampleLight() const override;
private: private:
util::AxisAlignedBoundingBox boundingVolume; util::AxisAlignedBoundingBox boundingVolume;
std::shared_ptr<Shape> shape; std::shared_ptr<LightShape> shape;
util::Transformation transform; util::Transformation transform;
}; };
} // 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