Files
ViewDesignEngine/include/vde/collision/ray_intersect.h
T

25 lines
655 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "vde/core/point.h"
#include "vde/core/line.h"
#include "vde/core/triangle.h"
#include <optional>
namespace vde::collision {
struct RayTriResult {
double t; // parameter along ray
double u, v; // barycentric
Point3D point;
};
/// MöllerTrumbore ray-triangle intersection
std::optional<RayTriResult> ray_triangle_intersect(
const Point3D& origin, const Vector3D& dir, const Triangle3D& tri);
inline std::optional<RayTriResult> ray_triangle_intersect(
const Ray3Dd& ray, const Triangle3D& tri) {
return ray_triangle_intersect(ray.origin(), ray.direction(), tri);
}
} // namespace vde::collision