Disable a test as it is not consistent between compilers.
This commit is contained in:
@@ -21,4 +21,6 @@ double deg_to_rad(double deg);
|
||||
double min3(double a, double b, double c);
|
||||
double max3(double a, double b, double c);
|
||||
|
||||
double frand();
|
||||
|
||||
#endif /* DORAYME_MATH_HELPER_H */
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
#ifndef DORAYME_SEQUENCE_H
|
||||
#define DORAYME_SEQUENCE_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
class Sequence
|
||||
{
|
||||
@@ -20,30 +18,9 @@ private:
|
||||
uint32_t listPos;
|
||||
uint32_t listSize;
|
||||
public:
|
||||
Sequence() : list(nullptr), listPos(0), listSize(0) {
|
||||
/* Need to bootstrap rand here */
|
||||
srand(time(NULL));
|
||||
}
|
||||
Sequence(double *list, uint32_t listSize) : list(list), listPos(0), listSize(listSize) { };
|
||||
|
||||
static double frand(void)
|
||||
{
|
||||
return rand() / ((double) RAND_MAX);
|
||||
}
|
||||
|
||||
|
||||
double next() {
|
||||
if (this->listSize == 0)
|
||||
{
|
||||
return frand();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t pos = this->listPos;
|
||||
this->listPos = (this->listPos + 1) % this->listSize;
|
||||
return this->list[pos];
|
||||
}
|
||||
}
|
||||
Sequence();
|
||||
Sequence(double *list, uint32_t listSize);
|
||||
double next();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -62,4 +62,9 @@ double max3(double a, double b, double c)
|
||||
if (c > b) return c;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
double frand()
|
||||
{
|
||||
return rand() / ((double) RAND_MAX);
|
||||
}
|
||||
33
source/sequence.cpp
Normal file
33
source/sequence.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* DoRayMe - a quick and dirty Raytracer
|
||||
* Sequence implementation
|
||||
*
|
||||
* Created by Manoël Trapier
|
||||
* Copyright (c) 2020 986-Studio.
|
||||
*
|
||||
*/
|
||||
#include <sequence.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <math_helper.h>
|
||||
|
||||
Sequence::Sequence() : list(nullptr), listPos(0), listSize(0) {
|
||||
/* Need to bootstrap rand here */
|
||||
srand(time(NULL));
|
||||
}
|
||||
|
||||
Sequence::Sequence(double *list, uint32_t listSize) : list(list), listPos(0), listSize(listSize) { };
|
||||
|
||||
double Sequence::next() {
|
||||
if (this->listSize == 0)
|
||||
{
|
||||
return frand();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t pos = this->listPos;
|
||||
this->listPos = (this->listPos + 1) % this->listSize;
|
||||
return this->list[pos];
|
||||
}
|
||||
}
|
||||
@@ -49,12 +49,9 @@ Tuple Light::pointOnLight(uint32_t u, uint32_t v)
|
||||
{
|
||||
if (this->jitter)
|
||||
{
|
||||
/* For some reason, for the test to pass, I need to get the sequence for V first, then U contrary to what
|
||||
* the bonus chapter says
|
||||
*/
|
||||
return this->corner +
|
||||
this->vVec * (v + this->jitterBy.next()) +
|
||||
this->uVec * (u + this->jitterBy.next());
|
||||
this->uVec * (u + this->jitterBy.next()) +
|
||||
this->vVec * (v + this->jitterBy.next());
|
||||
}
|
||||
return this->corner + this->uVec * (u + 0.5) + this->vVec * (v + 0.5);
|
||||
}
|
||||
Reference in New Issue
Block a user