mirror of
https://github.com/AxioDL/zeus.git
synced 2025-06-14 18:43:33 +00:00
19 lines
438 B
C++
19 lines
438 B
C++
#include "zeus/CPlane.hpp"
|
|
|
|
namespace zeus
|
|
{
|
|
|
|
bool CPlane::rayPlaneIntersection(const CVector3f& from, const CVector3f& to, CVector3f& point) const
|
|
{
|
|
zeus::CVector3f delta = to - from;
|
|
if (std::fabs(delta.normalized().dot(vec)) < 0.01f)
|
|
return false;
|
|
float tmp = -pointToPlaneDist(from) / delta.dot(vec);
|
|
if (tmp < -0.f || tmp > 1.0001f)
|
|
return false;
|
|
point = delta * tmp + from;
|
|
return true;
|
|
}
|
|
|
|
}
|