[FIX] Rename object has shape
This commit is contained in:
@@ -15,7 +15,7 @@ add_library(raytracing
|
||||
src/intersection.cpp
|
||||
src/intersections.cpp
|
||||
src/matrix.cpp
|
||||
src/object.cpp
|
||||
src/shape.cpp
|
||||
src/ray.cpp
|
||||
src/sphere.cpp
|
||||
src/tuple.cpp
|
||||
|
||||
@@ -36,16 +36,16 @@ using namespace Raytracer;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
Intersection::Intersection(void) : m_is_nothing(true), m_distance_t(0.0), m_object()
|
||||
Intersection::Intersection(void) : m_is_nothing(true), m_distance_t(0.0), m_shape()
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
Intersection::Intersection(double a_distance_t, const Object &an_object) :
|
||||
Intersection::Intersection(double a_distance_t, const Shape &a_shape) :
|
||||
m_is_nothing(false),
|
||||
m_distance_t(a_distance_t),
|
||||
m_object(an_object)
|
||||
m_shape(a_shape)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ Intersection::Intersection(double a_distance_t, const Object &an_object) :
|
||||
Intersection::Intersection(Intersection &an_intersection) :
|
||||
m_is_nothing(an_intersection.m_is_nothing),
|
||||
m_distance_t(an_intersection.m_distance_t),
|
||||
m_object(an_intersection.m_object)
|
||||
m_shape(an_intersection.m_shape)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ Intersection::Intersection(Intersection &an_intersection) :
|
||||
Intersection::Intersection(const Intersection &an_intersection) :
|
||||
m_is_nothing(an_intersection.m_is_nothing),
|
||||
m_distance_t(an_intersection.m_distance_t),
|
||||
m_object(an_intersection.m_object)
|
||||
m_shape(an_intersection.m_shape)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ const Intersection &Intersection::operator=(const Intersection &an_intersection)
|
||||
|
||||
m_is_nothing = an_intersection.m_is_nothing;
|
||||
m_distance_t = an_intersection.m_distance_t;
|
||||
m_object = an_intersection.m_object;
|
||||
m_shape = an_intersection.m_shape;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ const Intersection &Intersection::operator=(const Intersection &an_intersection)
|
||||
|
||||
bool Intersection::operator==(const Intersection &an_other) const
|
||||
{
|
||||
return (double_equal(m_distance_t, an_other.m_distance_t) && (m_object == an_other.m_object));
|
||||
return (double_equal(m_distance_t, an_other.m_distance_t) && (m_shape == an_other.m_shape));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -141,9 +141,9 @@ double Intersection::distance_t(void) const
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
const Object &Intersection::object(void) const
|
||||
const Shape &Intersection::object(void) const
|
||||
{
|
||||
return m_object;
|
||||
return m_shape;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#include "object.h"
|
||||
#include "shape.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Raytracer
|
||||
{
|
||||
public:
|
||||
Intersection(void);
|
||||
Intersection(double a_distance_t, const Object &an_object);
|
||||
Intersection(double a_distance_t, const Shape &a_shape);
|
||||
Intersection(Intersection &an_intersection);
|
||||
Intersection(const Intersection &an_intersection);
|
||||
|
||||
@@ -55,14 +55,14 @@ namespace Raytracer
|
||||
bool operator<=(double a_distance) const;
|
||||
|
||||
double distance_t(void) const;
|
||||
const Object &object(void) const;
|
||||
const Shape &object(void) const;
|
||||
bool is_nothing(void);
|
||||
bool is_defined(void);
|
||||
|
||||
private:
|
||||
bool m_is_nothing;
|
||||
double m_distance_t;
|
||||
Object m_object;
|
||||
Shape m_shape;
|
||||
};
|
||||
}; // namespace Raytracer
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* object.cpp
|
||||
* shape.cpp
|
||||
*
|
||||
* Copyright (c) 2024, NADAL Jean-Baptiste. All rights reserved.
|
||||
*
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include "intersections.h"
|
||||
|
||||
#include "object.h"
|
||||
#include "shape.h"
|
||||
|
||||
using namespace Raytracer;
|
||||
|
||||
@@ -38,72 +38,72 @@ using namespace Raytracer;
|
||||
|
||||
#define kNothing 0
|
||||
|
||||
uint32_t Object::s_current_index = 0;
|
||||
uint32_t Shape::s_current_index = 0;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
Object::Object(void) : m_id(kNothing), m_transform(Matrix::identity())
|
||||
Shape::Shape(void) : m_id(kNothing), m_transform(Matrix::identity())
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
Object::Object(Object &a_copy) : m_id(a_copy.m_id), m_transform(Matrix::identity())
|
||||
Shape::Shape(Shape &a_copy) : m_id(a_copy.m_id), m_transform(Matrix::identity())
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
Object::Object(const Object &a_copy) : m_id(a_copy.m_id), m_transform(Matrix::identity())
|
||||
Shape::Shape(const Shape &a_copy) : m_id(a_copy.m_id), m_transform(Matrix::identity())
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
const Object &Object::operator=(const Object &an_other)
|
||||
const Shape &Shape::operator=(const Shape &a_shape)
|
||||
{
|
||||
if (this == &an_other)
|
||||
if (this == &a_shape)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
m_id = an_other.m_id;
|
||||
m_transform = an_other.m_transform;
|
||||
m_id = a_shape.m_id;
|
||||
m_transform = a_shape.m_transform;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
bool Object::operator==(const Object &an_object) const
|
||||
bool Shape::operator==(const Shape &a_shape) const
|
||||
{
|
||||
return (m_id == an_object.m_id) && (m_transform == an_object.m_transform);
|
||||
return (m_id == a_shape.m_id) && (m_transform == a_shape.m_transform);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
bool Object::is_nothing(void)
|
||||
bool Shape::is_nothing(void)
|
||||
{
|
||||
return (m_id == kNothing);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
Matrix &Object::transform(void)
|
||||
Matrix &Shape::transform(void)
|
||||
{
|
||||
return m_transform;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void Object::set_transform(const Matrix &a_transform_matrix)
|
||||
void Shape::set_transform(const Matrix &a_transform_matrix)
|
||||
{
|
||||
m_transform = a_transform_matrix;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
Tuple Object::normal_at(const Tuple &a_point)
|
||||
Tuple Shape::normal_at(const Tuple &a_point)
|
||||
{
|
||||
Tuple the_result = a_point - Tuple::Point(0, 0, 0);
|
||||
return the_result.normalize();
|
||||
@@ -111,7 +111,7 @@ Tuple Object::normal_at(const Tuple &a_point)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
Intersections Object::intersect(Ray &a_ray)
|
||||
Intersections Shape::intersect(Ray &a_ray)
|
||||
{
|
||||
Intersections the_ret;
|
||||
|
||||
@@ -120,7 +120,7 @@ Intersections Object::intersect(Ray &a_ray)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void Object::inc_id(void)
|
||||
void Shape::inc_id(void)
|
||||
{
|
||||
m_id = s_current_index++;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* intersection.h
|
||||
* shape.h
|
||||
*
|
||||
* Copyright (c) 2024, NADAL Jean-Baptiste. All rights reserved.
|
||||
*
|
||||
@@ -23,8 +23,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _RAYTRACER_OBJECT_H
|
||||
#define _RAYTRACER_OBJECT_H
|
||||
#ifndef _RAYTRACER_SHAPE_H
|
||||
#define _RAYTRACER_SHAPE_H
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -41,15 +41,15 @@ namespace Raytracer
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class Object
|
||||
class Shape
|
||||
{
|
||||
public:
|
||||
Object(void);
|
||||
Object(Object &a_copy);
|
||||
Object(const Object &a_copy);
|
||||
Shape(void);
|
||||
Shape(Shape &a_copy);
|
||||
Shape(const Shape &a_copy);
|
||||
|
||||
const Object &operator=(const Object &an_other);
|
||||
bool operator==(const Object &an_object) const;
|
||||
const Shape &operator=(const Shape &a_shape);
|
||||
bool operator==(const Shape &a_shape) const;
|
||||
|
||||
bool is_nothing(void);
|
||||
|
||||
@@ -70,4 +70,4 @@ namespace Raytracer
|
||||
};
|
||||
}; // namespace Raytracer
|
||||
|
||||
#endif // _RAYTRACER_OBJECT_H
|
||||
#endif // _RAYTRACER_SHAPE_H
|
||||
@@ -28,13 +28,13 @@
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#include "object.h"
|
||||
#include "shape.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
namespace Raytracer
|
||||
{
|
||||
class Sphere : public Object
|
||||
class Sphere : public Shape
|
||||
{
|
||||
public:
|
||||
Sphere(void);
|
||||
|
||||
Reference in New Issue
Block a user