More timing functions
This commit is contained in:
parent
6331a2bf79
commit
321c677da2
12 changed files with 184 additions and 129 deletions
|
|
@ -3,36 +3,28 @@
|
|||
|
||||
#include <math.h>
|
||||
#include <memory>
|
||||
|
||||
/* Utility macros */
|
||||
|
||||
#define TIMED_BLOCK_2(c, flags) rmt_ScopedCPUSample(Counter##c, flags)
|
||||
#define TIMED_BLOCK_1(c, flags) TIMED_BLOCK_2(c, flags)
|
||||
#define TIMED_BLOCK(flags) TIMED_BLOCK_1(__COUNTER__, flags)
|
||||
|
||||
// #define TIMED_BLOCK_(counter, flags) rmt_ScopedCPUSample(counter, flags)
|
||||
// #define TIMED_BLOCK(flags) TIMED_BLOCK_(__COUNTER__, flags)
|
||||
#include "timer.hpp"
|
||||
|
||||
/* Utility functions */
|
||||
double degrees_to_radians(double d)
|
||||
float degrees_to_radians(float d)
|
||||
{
|
||||
return d * M_PI / 180;
|
||||
}
|
||||
|
||||
/* Returns a double in the range [0,1) */
|
||||
inline double random_double()
|
||||
/* Returns a float in the range [0,1) */
|
||||
inline float random_float()
|
||||
{
|
||||
return rand() * (1.0 / RAND_MAX);
|
||||
}
|
||||
|
||||
/* Returns a double in the range [min,max) */
|
||||
inline double random_double(double min, double max)
|
||||
/* Returns a float in the range [min,max) */
|
||||
inline float random_float(float min, float max)
|
||||
{
|
||||
return min + (max-min) * random_double();
|
||||
return min + (max-min) * random_float();
|
||||
}
|
||||
|
||||
/* Clamps a value between [min,max] */
|
||||
inline double clamp(double v, double min, double max)
|
||||
inline float clamp(float v, float min, float max)
|
||||
{
|
||||
return v < min ? min : v > max ? max : v;
|
||||
}
|
||||
|
|
@ -50,7 +42,7 @@ struct hit_record {
|
|||
point3 p;
|
||||
vec3 normal;
|
||||
std::shared_ptr<material> mat_ptr;
|
||||
double t;
|
||||
float t;
|
||||
bool front_face;
|
||||
|
||||
inline void set_face_normal(const ray& r, const vec3& outward_normal)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue