Object::get_material returns a pointer instead of a reference

This commit is contained in:
Eryn Wells 2014-07-19 14:09:47 -07:00
parent b62949416b
commit 68d0083ba8
3 changed files with 8 additions and 8 deletions

View file

@ -100,11 +100,11 @@ Shape::~Shape()
* *
* Get and set the Material applied to this shape. * Get and set the Material applied to this shape.
*/ */
Material & Material*
Shape::get_material() Shape::get_material()
const const
{ {
return *material; return material;
} }
void void

View file

@ -42,7 +42,7 @@ public:
Shape(Vector3 o); Shape(Vector3 o);
virtual ~Shape(); virtual ~Shape();
Material &get_material() const; Material* get_material() const;
void set_material(Material *mat); void set_material(Material *mat);
virtual int does_intersect(const Ray &ray, float **t) const = 0; virtual int does_intersect(const Ray &ray, float **t) const = 0;

View file

@ -219,8 +219,8 @@ Scene::trace_ray(const Ray &ray,
return out_color; return out_color;
} }
Material shape_material = intersected_shape->get_material(); Material* shape_material = intersected_shape->get_material();
Color shape_color = shape_material.get_diffuse_color(); Color shape_color = shape_material->get_diffuse_color();
Vector3 intersection = ray.parameterize(nearest_t); Vector3 intersection = ray.parameterize(nearest_t);
Vector3 normal = intersected_shape->compute_normal(intersection); Vector3 normal = intersected_shape->compute_normal(intersection);
@ -241,7 +241,7 @@ Scene::trace_ray(const Ray &ray,
ldotn = 0.0; ldotn = 0.0;
} }
diffuse_level = shape_material.get_diffuse_level(); diffuse_level = shape_material->get_diffuse_level();
ambient_level = 1.0 - diffuse_level; ambient_level = 1.0 - diffuse_level;
shadow_ray = Ray(intersection, light_direction); shadow_ray = Ray(intersection, light_direction);
@ -269,8 +269,8 @@ Scene::trace_ray(const Ray &ray,
* Specular lighting. (Reflections, etc.) * Specular lighting. (Reflections, etc.)
*/ */
float specular_level = shape_material.get_specular_level(); float specular_level = shape_material->get_specular_level();
const Color &specular_color = shape_material.get_specular_color(); 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: * Compute the reflection ray. Computing the direction of the reflection ray is done by the following formula: