diff --git a/src/object.cc b/src/object.cc index 1c09bfa..f786ed6 100644 --- a/src/object.cc +++ b/src/object.cc @@ -100,11 +100,11 @@ Shape::~Shape() * * Get and set the Material applied to this shape. */ -Material & +Material* Shape::get_material() const { - return *material; + return material; } void diff --git a/src/object.h b/src/object.h index f143fbc..cda86ad 100644 --- a/src/object.h +++ b/src/object.h @@ -42,7 +42,7 @@ public: Shape(Vector3 o); virtual ~Shape(); - Material &get_material() const; + Material* get_material() const; void set_material(Material *mat); virtual int does_intersect(const Ray &ray, float **t) const = 0; diff --git a/src/scene.cc b/src/scene.cc index df94d50..1ce68f8 100644 --- a/src/scene.cc +++ b/src/scene.cc @@ -219,8 +219,8 @@ Scene::trace_ray(const Ray &ray, return out_color; } - Material shape_material = intersected_shape->get_material(); - Color shape_color = shape_material.get_diffuse_color(); + Material* shape_material = intersected_shape->get_material(); + Color shape_color = shape_material->get_diffuse_color(); Vector3 intersection = ray.parameterize(nearest_t); Vector3 normal = intersected_shape->compute_normal(intersection); @@ -241,7 +241,7 @@ Scene::trace_ray(const Ray &ray, ldotn = 0.0; } - diffuse_level = shape_material.get_diffuse_level(); + diffuse_level = shape_material->get_diffuse_level(); ambient_level = 1.0 - diffuse_level; shadow_ray = Ray(intersection, light_direction); @@ -269,8 +269,8 @@ Scene::trace_ray(const Ray &ray, * Specular lighting. (Reflections, etc.) */ - float specular_level = shape_material.get_specular_level(); - const Color &specular_color = shape_material.get_specular_color(); + float specular_level = shape_material->get_specular_level(); + const Color &specular_color = shape_material->get_specular_color(); /* * Compute the reflection ray. Computing the direction of the reflection ray is done by the following formula: