Sample scene for CSG \o/

This commit is contained in:
Godzil
2020-03-06 21:55:32 +00:00
parent b5ee92c544
commit 57eff4830e
15 changed files with 147 additions and 72 deletions

View File

@@ -132,12 +132,12 @@ Canvas::~Canvas()
}
}
void Canvas::putPixel(uint32_t x, uint32_t y, Tuple colour)
void Canvas::putPixel(uint32_t x, uint32_t y, Tuple c)
{
uint32_t offset = y * this->stride + x * BytePP;
this->bitmap[offset + 0] = MAX(MIN(colour.x * 255, 255), 0);
this->bitmap[offset + 1] = MAX(MIN(colour.y * 255, 255), 0);
this->bitmap[offset + 2] = MAX(MIN(colour.z * 255, 255), 0);
this->bitmap[offset + 0] = MAX(MIN(c.x * 255, 255), 0);
this->bitmap[offset + 1] = MAX(MIN(c.y * 255, 255), 0);
this->bitmap[offset + 2] = MAX(MIN(c.z * 255, 255), 0);
}
Colour Canvas::getPixel(uint32_t x, uint32_t y)

View File

@@ -42,6 +42,8 @@ protected:
public:
CSG(OperationType operation, Shape *left, Shape *right);
Intersect intersect(Ray r);
bool includes(Shape *b);
void updateTransform();

View File

@@ -45,7 +45,7 @@ Computation Intersection::prepareComputation(Ray r, Intersect *xs)
if ((xs != nullptr) && (xs->hit().object->material.transparency > 0))
{
List containers;
int j, k;
int j;
for (j = 0 ; j < xs->count() ; j++)
{

View File

@@ -40,6 +40,11 @@ Intersect CSG::localIntersect(Ray r)
return ret;
}
Intersect CSG::intersect(Ray r)
{
return localIntersect(r);
}
Tuple CSG::localNormalAt(Tuple point, Intersection *hit)
{
return Vector(1, 0, 0);

View File

@@ -18,11 +18,11 @@ Group::Group() : Shape(SHAPE_GROUP)
{
stats.addGroup();
this->allocatedObjectCount = MIN_ALLOC;
this->objectList = (Shape **)calloc(sizeof(Shape *), MIN_ALLOC);
this->objectList = (Shape **)calloc(sizeof(Shape **), MIN_ALLOC);
this->objectCount = 0;
this->allocatedUnboxableObjectCount = MIN_ALLOC;
this->unboxableObjectList = (Shape **)calloc(sizeof(Shape *), MIN_ALLOC);
this->unboxableObjectList = (Shape **)calloc(sizeof(Shape **), MIN_ALLOC);
this->unboxableObjectCount = 0;
}

View File

@@ -41,7 +41,6 @@ double Light::intensityAt(World &w, Tuple point)
}
}
return total / this->samples;
break;
}
}

View File

@@ -299,7 +299,6 @@ static int parseFaceVertex(char *buf, uint32_t &v, uint32_t &vt, uint32_t &vn)
{
uint32_t bufPos = 0;
uint32_t lineLength = strlen(buf);
char *tmp = buf;
vt = INT32_MAX;
vn = INT32_MAX;
int ret = 0;