Add sphere->frustum and point->frustum intersection tests

This commit is contained in:
Phillip Stephens 2016-07-26 13:13:26 -07:00
parent b6a1241678
commit 08d2925689
1 changed files with 23 additions and 2 deletions

View File

@ -88,8 +88,7 @@ public:
inline bool aabbFrustumTest(const CAABox& aabb) const
{
CVector3f vmin, vmax;
int i;
for (i = 0; i < 6; ++i)
for (uint32_t i = 0; i < 6; ++i)
{
const CPlane& plane = planes[i];
@ -132,6 +131,28 @@ public:
}
return true;
}
inline bool sphereFrustumTest(const CSphere& sphere)
{
for (uint32_t i = 0 ; i<6 ; ++i)
{
float dadot = planes[i].vec.dot(sphere.position);
if ((dadot + planes[i].d + sphere.radius) < 0)
return false;
}
return true;
}
inline bool pointFrustumTest(const CVector3f& point)
{
for (uint32_t i = 0 ; i<6 ; ++i)
{
float dadot = planes[i].vec.dot(point);
if ((dadot + planes[i].d) < 0)
return false;
}
return true;
}
};
}
#endif // CFRUSTUM_HPP