Renaming Object to Shape (part 1)

This commit is contained in:
Godzil
2020-02-18 11:40:55 +00:00
parent df4ec9794a
commit 5a4f9f4dc4
12 changed files with 19 additions and 19 deletions

View File

@@ -5,7 +5,7 @@ add_library(rayonnement STATIC)
file(GLOB RAY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
file(GLOB RAY_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/objects/*.cpp)
file(GLOB RAY_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/shapes/*.cpp)
target_include_directories(rayonnement PUBLIC include)
target_sources(rayonnement PRIVATE ${RAY_HEADERS} ${RAY_SOURCES})

View File

@@ -11,16 +11,16 @@
#include <stdlib.h>
class Object;
class Shape;
class Intersection
{
public:
double t;
Object *object;
Shape *object;
public:
Intersection(double t, Object *object) : t(t), object(object) { };
Intersection(double t, Shape *object) : t(t), object(object) { };
bool nothing() { return (this->object == nullptr); };
bool operator==(const Intersection &b) const { return ((this->t == b.t) && (this->object == b.object)); };

View File

@@ -9,7 +9,7 @@
#ifndef DORAYME_OBJECT_H
#define DORAYME_OBJECT_H
class Object;
class Shape;
#include <ray.h>
#include <tuple.h>
@@ -18,7 +18,7 @@ class Object;
#include <material.h>
/* Base class for all object that can be presented in the world */
class Object
class Shape
{
public:
Matrix transformMatrix;
@@ -26,7 +26,7 @@ public:
Material material;
public:
Object();
Shape();
virtual Intersect intersect(Ray r);
virtual Tuple normalAt(Tuple point);

View File

@@ -13,7 +13,7 @@
#include <ray.h>
#include <intersect.h>
class Sphere : public Object
class Sphere : public Shape
{
public:
/* All sphere are at (0, 0, 0) and radius 1 in the object space */

View File

@@ -17,7 +17,7 @@
Intersect::Intersect()
{
this->allocated = MIN_ALLOC;
this->list = (Intersection *)calloc(sizeof(Object *), MIN_ALLOC);
this->list = (Intersection *)calloc(sizeof(Shape *), MIN_ALLOC);
this->num = 0;
}
@@ -26,7 +26,7 @@ void Intersect::add(Intersection i)
if ((this->num + 1) < this->allocated)
{
this->allocated *= 2;
this->list = (Intersection *)realloc(this->list, sizeof(Object *) * this->allocated);
this->list = (Intersection *)realloc(this->list, sizeof(Shape *) * this->allocated);
}
this->list[this->num++] = i;
}

View File

@@ -13,23 +13,23 @@
#include <tuple.h>
#include <intersect.h>
Object::Object()
Shape::Shape()
{
this->transformMatrix = Matrix4().identity();
this->inverseTransform = this->transformMatrix.inverse();
}
Intersect Object::intersect(Ray r)
Intersect Shape::intersect(Ray r)
{
return Intersect();
};
Tuple Object::normalAt(Tuple point)
Tuple Shape::normalAt(Tuple point)
{
return Vector(0, 0, 0);
}
void Object::setTransform(Matrix transform)
void Shape::setTransform(Matrix transform)
{
this->transformMatrix = transform;
this->inverseTransform = transform.inverse();