Files
omath/include/omath/collision/LineTracer.hpp
Vladislav Alpatov 6d0d267743 now template
2025-03-01 21:11:46 +03:00

39 lines
878 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.
//
// Created by Orange on 11/13/2024.
//
#pragma once
#include "omath/Vector3.hpp"
#include "omath/Triangle.hpp"
namespace omath::collision
{
class Ray
{
public:
Vector3<float> start;
Vector3<float> end;
[[nodiscard]]
Vector3<float> DirectionVector() const;
[[nodiscard]]
Vector3<float> DirectionVectorNormalized() const;
};
class LineTracer
{
public:
LineTracer() = delete;
[[nodiscard]]
static bool CanTraceLine(const Ray& ray, const Triangle<Vector3<float>>& triangle);
// Realization of MöllerTrumbore intersection algorithm
// https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
[[nodiscard]]
static Vector3<float> GetRayHitPoint(const Ray& ray, const Triangle<Vector3<float>>& triangle);
};
}