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 min3(double a, double b, double c);
|
||||||
double max3(double a, double b, double c);
|
double max3(double a, double b, double c);
|
||||||
|
|
||||||
|
double frand();
|
||||||
|
|
||||||
#endif /* DORAYME_MATH_HELPER_H */
|
#endif /* DORAYME_MATH_HELPER_H */
|
||||||
|
|||||||
@@ -9,9 +9,7 @@
|
|||||||
#ifndef DORAYME_SEQUENCE_H
|
#ifndef DORAYME_SEQUENCE_H
|
||||||
#define DORAYME_SEQUENCE_H
|
#define DORAYME_SEQUENCE_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
class Sequence
|
class Sequence
|
||||||
{
|
{
|
||||||
@@ -20,30 +18,9 @@ private:
|
|||||||
uint32_t listPos;
|
uint32_t listPos;
|
||||||
uint32_t listSize;
|
uint32_t listSize;
|
||||||
public:
|
public:
|
||||||
Sequence() : list(nullptr), listPos(0), listSize(0) {
|
Sequence();
|
||||||
/* Need to bootstrap rand here */
|
Sequence(double *list, uint32_t listSize);
|
||||||
srand(time(NULL));
|
double next();
|
||||||
}
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,3 +63,8 @@ double max3(double a, double b, double c)
|
|||||||
}
|
}
|
||||||
return b;
|
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)
|
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 +
|
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);
|
return this->corner + this->uVec * (u + 0.5) + this->vVec * (v + 0.5);
|
||||||
}
|
}
|
||||||
@@ -148,6 +148,8 @@ TEST(LightTest, The_area_light_intensity_function)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* This test is not reliable */
|
||||||
TEST(LightTest, Finding_a_single_point_on_a_jittered_area_light)
|
TEST(LightTest, Finding_a_single_point_on_a_jittered_area_light)
|
||||||
{
|
{
|
||||||
Tuple corner = Point(0, 0, 0);
|
Tuple corner = Point(0, 0, 0);
|
||||||
@@ -184,6 +186,7 @@ TEST(LightTest, Finding_a_single_point_on_a_jittered_area_light)
|
|||||||
ASSERT_EQ(tp, testResults[i]);
|
ASSERT_EQ(tp, testResults[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST(LightTest, The_area_light_with_jittered_samples)
|
TEST(LightTest, The_area_light_with_jittered_samples)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user