cloudy-raytracer/common/ray.h

49 lines
1 KiB
C
Raw Normal View History

2022-10-28 09:31:13 +02:00
#ifndef RAY_H
#define RAY_H
#include "common/common.h"
#include "common/vector2d.h"
#include "common/vector3d.h"
#include <atomic>
// Forward declaration
class Primitive;
2022-11-17 17:22:37 +01:00
struct Ray
{
2022-10-28 09:31:13 +02:00
friend class Scene;
// Components
Vector3d origin; // o
Vector3d direction; // d
float length = INFINITY; // t
Primitive const *primitive = nullptr;
Vector3d normal;
Vector2d surface;
Vector3d tangent;
Vector3d bitangent;
// Constructor
2022-11-17 17:22:37 +01:00
Ray(Vector3d const &origin = Vector3d(0, 0, 0), Vector3d const &direction = Vector3d(0, 0, 1)) : origin(origin), direction(normalized(direction))
{
2022-11-11 14:27:43 +01:00
++rayCount;
2022-10-28 09:31:13 +02:00
}
2022-11-17 17:22:37 +01:00
inline void setRemainingBounces(int remainingBounces) { this->remainingBounces = remainingBounces; }
2022-11-11 14:27:43 +01:00
inline int getRemainingBounces() const { return remainingBounces; }
static inline void resetRayCount() { rayCount = 0; }
static inline int getRayCount() { return rayCount; }
2022-10-28 09:31:13 +02:00
private:
#ifndef ICG_RAY_BOUNCES
int remainingBounces = 4;
#else
int remainingBounces = ICG_RAY_BOUNCES;
#endif
2022-11-11 14:27:43 +01:00
static int rayCount;
2022-10-28 09:31:13 +02:00
};
#endif