34 const float EPSILON = 0.0000001f;
35 vec3 edge1, edge2, h, s, q;
41 if (
a > -EPSILON &&
a < EPSILON)
46 if (u < 0.0f || u > 1.0f)
50 if (v < 0.0f || u + v > 1.0f)
53 float t = f *
dot(edge2, q);
54 if (t > EPSILON && t < nearest_t)
88 [[nodiscard]]
bool Intersect(
float &nearest_t,
Ray const &ray)
const
88 [[nodiscard]]
bool Intersect(
float &nearest_t,
Ray const &ray)
const {
…}
Represents a geometric ray in 3D space.
vec3 PointAtParameter(float t) const
Computes a point along the ray based on the given parameter.
constexpr vec3 const & origin() const noexcept
Retrieves the ray's origin (const version).
constexpr vec3 const & direction() const noexcept
Retrieves the ray's direction (const version).
Provides various mathematical utilities, vector operations, and custom hash specializations.
Contains mathematical utility functions and classes.
constexpr T dot(qua< T > const &left, qua< U > const &right) noexcept
Computes the dot product of two quaternions.
constexpr vec< 3, T > cross(qua< T > const &left, vec< 3, U > const &right) noexcept
Cross product between quaternion and vector.
Represents the data of a ray's intersection with an object.
float t
The intersection parameter.
vec3 point
The 3D point of intersection.
Represents a triangle defined by three 3D points.
bool Intersect(float &nearest_t, Ray const &ray) const
Determines if a ray intersects with this triangle.
bool Intersect(Intersection &nearest, Ray const &ray) const
Determines if a ray intersects with this triangle and updates intersection details.
vec3 b
Second vertex of the triangle.
vec3 c
Third vertex of the triangle.
vec3 a
First vertex of the triangle.
static bool Intersect(vec3 const &p0, vec3 const &p1, vec3 const &p2, float &nearest_t, Ray const &ray)
Determines if a ray intersects with the triangle using its vertices.
static bool Intersect(vec3 const &p0, vec3 const &p1, vec3 const &p2, Intersection &nearest, Ray const &ray)
Determines if a ray intersects with the triangle and updates intersection details.