zeus/src/CPlane.cpp

17 lines
446 B
C++
Raw Normal View History

2016-03-04 15:03:26 -08:00
#include "zeus/CPlane.hpp"
2017-09-17 20:02:19 -07:00
2018-12-07 17:16:50 -08:00
namespace zeus {
2017-09-17 20:02:19 -07:00
2018-12-07 17:16:50 -08:00
bool CPlane::rayPlaneIntersection(const CVector3f& from, const CVector3f& to, CVector3f& point) const {
zeus::CVector3f delta = to - from;
if (std::fabs(delta.normalized().dot(normal())) < 0.01f)
return false;
float tmp = -pointToPlaneDist(from) / delta.dot(normal());
if (tmp < -0.f || tmp > 1.0001f)
return false;
point = delta * tmp + from;
return true;
2017-09-17 20:02:19 -07:00
}
2018-12-07 21:23:50 -08:00
} // namespace zeus