Fix some stupidity on my part.

master
Andrew Copland 2014-10-11 16:23:41 +01:00
parent d122d9d30d
commit a4fe3c8895
2 changed files with 5 additions and 7 deletions

View File

@ -26,27 +26,25 @@ bool SSphere::HorizonCulling(const vector3d& view, const SSphere& obj) const
const double D2 = O2C.Length();
const double R1 = m_radius;
const double R2 = obj.m_radius;
const double iD1 = 1.0f / D1;
const double iD2 = 1.0f / D2;
const double iD1 = 1.0 / D1;
const double iD2 = 1.0 / D2;
O1C *= iD1;
O2C *= iD2;
const double K = O1C.Dot(O2C);
if( K > 0.85 )
return true;
const double K1 = R1 * iD1;
const double K2 = R2 * iD2;
bool status = true;
if ( K > K1 * K2 )
{
status = (-2.0f * K * K1 * K2 + K1 * K1 + K2 * K2 < 1.0f - K * K);
status = (-2.0 * K * K1 * K2 + K1 * K1 + K2 * K2) < (1.0 - K * K);
}
const double y = R1 * R1 * iD1;
const vector3d P = m_centre - y * O1C;
const vector3d N = -O1C;
SPlane plane(N, P);
const SPlane plane(N, P);
status = status || (plane.DistanceToPoint(obj.m_centre) > obj.m_radius);
return status;

View File

@ -17,7 +17,7 @@ struct SSphere {
double m_radius;
// Adapted from Ysaneya here: http://www.gamedev.net/blog/73/entry-1666972-horizon-culling/
bool SSphere::HorizonCulling(const vector3d& view, const SSphere& obj) const;
bool HorizonCulling(const vector3d& view, const SSphere& obj) const;
};
#endif /* _SPHERE_H */