/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: include/domains/graphics/frustum/frustum.hpp

*/

#ifndef SGX_DOMAIN_GRAPHICS_FRUSTUM_HPP
#define SGX_DOMAIN_GRAPHICS_FRUSTUM_HPP	1

class CViewFrustum
{
public:
	SGX_INLINE tBOOL isInside(const sgxVector3 &pos, const tREAL32 radius) const
	{
		for(int i = 0; i < 6; i++ )
		{
			tREAL32 dist = m_FrustumPlanes[i].Distance(pos);

			if (dist <= -radius) {
				return FALSE;
			}
		}

		// The point was inside of the frustum (In front of ALL the sides of the frustum)
		return TRUE;
	}

	tBOOL	isInside(const sgxVector3 &pos) const;
	tBOOL	isInside(const sgxMatrix43 &transform) const;
	tBOOL	isInside(const sgxPrimitivePolygon &poly) const;
	tBOOL	isInside(const sgxPrimitivePolygon &poly, const sgxMatrix43 &transform) const;
	tBOOL	isAllInside(const sgxPrimitivePolygon &poly, const sgxMatrix43 &transform) const;

	void	recalculateFrustumPlanes(const sgxMatrix44 &ProjectViewTransform);

private:
	sgxPlane	m_FrustumPlanes[6];

};

#endif /* SGX_DOMAIN_GRAPHICS_FRUSTUM_HPP */
