summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--object.h2
-rw-r--r--sphere.h9
2 files changed, 6 insertions, 5 deletions
diff --git a/object.h b/object.h
index 7f35237..ab79423 100644
--- a/object.h
+++ b/object.h
@@ -41,7 +41,7 @@ public:
virtual ~object() = default;
// Get this object's material.
- virtual material &get_material() const = 0;
+ virtual const material & get_material() const = 0;
};
diff --git a/sphere.h b/sphere.h
index 8cc1caf..57e59c4 100644
--- a/sphere.h
+++ b/sphere.h
@@ -25,12 +25,13 @@ class material;
class sphere : public object {
vec3d center;
double radius;
- class material &materi;
+ const class material *materi;
public:
sphere() = delete;
- sphere(const vec3d &center, double radius, class material &materi) : center(center), radius(radius), materi(materi) {}
+ sphere(const vec3d center, double radius, const class material &materi)
+ : center(center), radius(radius), materi(&materi) {}
~sphere() override = default;
@@ -39,8 +40,8 @@ public:
return (where - center) / radius;
}
- class material &get_material() const override {
- return materi;
+ const class material &get_material() const override {
+ return *materi;
}
bool hit(const ray3d &r, double &t, double t1, double t2) const override {