mirror of
https://github.com/AxioDL/zeus.git
synced 2025-12-17 17:05:30 +00:00
Add CPlane::rayPlaneIntersection
This commit is contained in:
@@ -1 +1,18 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user